c-resources/CPlusPlus20ForProgrammers-m.../examples/libraries/rapidcsv/tests/test066.cpp

34 lines
637 B
C++
Raw Normal View History

2024-04-09 06:45:18 +00:00
// test066.cpp - test UTF-8 Byte order mark skipping
#include "rapidcsv.h"
#include "unittest.h"
int main()
{
int rv = 0;
std::string csvWithBom =
"\xef\xbb\xbfID\n"
"1\n"
;
std::string path = unittest::TempPath();
unittest::WriteFile(path, csvWithBom);
try
{
rapidcsv::Document doc(path, rapidcsv::LabelParams(0, -1));
unittest::ExpectEqual(size_t, doc.GetRowCount(), 1);
unittest::ExpectEqual(std::string, doc.GetColumn<std::string>("ID")[0], "1");
}
catch (const std::exception& ex)
{
std::cout << ex.what() << std::endl;
rv = 1;
}
unittest::DeleteFile(path);
return rv;
}