Skip to content

Commit

Permalink
Unit tests for different quotes combinations.
Browse files Browse the repository at this point in the history
Co-authored-by: ldo2 <[email protected]>
  • Loading branch information
mesozoic-drones and ldo2 authored Jun 19, 2020
1 parent 9a2366a commit 07d343e
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/unit_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 07d343e

Please sign in to comment.