Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/just_gtfs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlga Khlopkova <mesozoic.drones@gmail.com>2020-06-19 10:32:07 +0300
committerGitHub <noreply@github.com>2020-06-19 10:32:07 +0300
commit07d343eed8fc6e4753cf016a2cef2ae7b172fdb8 (patch)
tree35e08151fd3845d9f9dd8fa80ddbaf39036563e6
parent9a2366a1c76ff74db24db0a69162ad8cd9b0a275 (diff)
Unit tests for different quotes combinations.
Co-authored-by: ldo2 <ldo2.msiu@gmail.com>
-rw-r--r--tests/unit_tests.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/unit_tests.cpp b/tests/unit_tests.cpp
index 134f8df..e43af3d 100644
--- a/tests/unit_tests.cpp
+++ b/tests/unit_tests.cpp
@@ -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");