Unit tests for different quotes combinations.

Co-authored-by: ldo2 <ldo2.msiu@gmail.com>
This commit is contained in:
Olga Khlopkova 2020-06-19 10:32:07 +03:00 committed by GitHub
parent 9a2366a1c7
commit 07d343eed8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -180,6 +180,37 @@ TEST_CASE("Read quoted empty values")
CHECK_EQ(res[0], "");
CHECK_EQ(res[1], "");
}
TEST_CASE("Read quoted quote")
{
const auto res = CsvParser::split_record(",\"\"\"\"");
REQUIRE_EQ(res.size(), 2);
CHECK_EQ(res[0], "");
CHECK_EQ(res[1], "\"");
}
TEST_CASE("Read quoted double quote")
{
const auto res = CsvParser::split_record(",\"\"\"\"\"\"");
REQUIRE_EQ(res.size(), 2);
CHECK_EQ(res[0], "");
CHECK_EQ(res[1], "\"\"");
}
TEST_CASE("Read quoted values with quotes in begin")
{
const auto res = CsvParser::split_record(",\"\"\"Name\"\" and some other\"");
REQUIRE_EQ(res.size(), 2);
CHECK_EQ(res[0], "");
CHECK_EQ(res[1], "\"Name\" and some other");
}
TEST_CASE("Read quoted values with quotes at end")
{
const auto res = CsvParser::split_record(",\"Text and \"\"Name\"\"\"");
REQUIRE_EQ(res.size(), 2);
CHECK_EQ(res[0], "");
CHECK_EQ(res[1], "Text and \"Name\"");
}
TEST_SUITE_END();
TEST_SUITE_BEGIN("Read & write");