diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-05-08 13:30:19 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-11-07 16:41:37 +0000 |
commit | 367530b6495a455ad53827bce7f331419ed2ab83 (patch) | |
tree | 89485bf948505efeff9f7c99253724b617ad3fda /test | |
parent | Initial commit where writing objects back out to JSON (diff) | |
download | ilt-367530b6495a455ad53827bce7f331419ed2ab83.tar.bz2 ilt-367530b6495a455ad53827bce7f331419ed2ab83.tar.xz ilt-367530b6495a455ad53827bce7f331419ed2ab83.zip |
Update tests to coverage encoding strings
Fixes char (byte) type lookup.
Diffstat (limited to 'test')
-rw-r--r-- | test/test-persistence.cpp | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/test/test-persistence.cpp b/test/test-persistence.cpp index 547396b..ab16166 100644 --- a/test/test-persistence.cpp +++ b/test/test-persistence.cpp @@ -257,23 +257,25 @@ BOOST_FIXTURE_TEST_CASE(load_shared_object_null, JPP) } using svs = std::tuple<const char * const, std::string_view>; -BOOST_DATA_TEST_CASE_F(JPP, load_strings, - boost::unit_test::data::make<svs>({ - {R"J("")J", ""}, - {R"J("non empty")J", "non empty"}, - {R"J("new\nline")J", "new\nline"}, - {R"J("quote\"mark")J", "quote\"mark"}, - {R"J("tab\t")J", "tab\t"}, - {R"J("back\bspace?")J", "back\bspace?"}, - {R"J("form\ffeed?")J", "form\ffeed?"}, - {R"J("forward\/slash")J", "forward/slash"}, - {R"J("\u00a5 yen")J", "¥ yen"}, - {R"J("gbp \u00a3")J", "gbp £"}, - {R"J("\u007E tilde")J", "~ tilde"}, - {R"J("\u056b ARMENIAN SMALL LETTER INI")J", "ի ARMENIAN SMALL LETTER INI"}, - {R"J("\u0833 SAMARITAN PUNCTUATION BAU")J", "࠳ SAMARITAN PUNCTUATION BAU"}, - }), - in, exp) +auto const TEST_STRINGS = boost::unit_test::data::make<svs>({ + {R"J("")J", ""}, + {R"J("non empty")J", "non empty"}, + {R"J("new\nline")J", "new\nline"}, + {R"J("quote\"mark")J", "quote\"mark"}, + {R"J("tab\t")J", "tab\t"}, + {R"J("back\bspace?")J", "back\bspace?"}, + {R"J("form\ffeed?")J", "form\ffeed?"}, + {R"J("a \u0007 bell")J", "a \a bell"}, +}); +auto const TEST_STRINGS_DECODE_ONLY = boost::unit_test::data::make<svs>({ + {R"J("forward\/slash")J", "forward/slash"}, + {R"J("\u00a5 yen")J", "¥ yen"}, + {R"J("gbp \u00a3")J", "gbp £"}, + {R"J("\u007E tilde")J", "~ tilde"}, + {R"J("\u056b ARMENIAN SMALL LETTER INI")J", "ի ARMENIAN SMALL LETTER INI"}, + {R"J("\u0833 SAMARITAN PUNCTUATION BAU")J", "࠳ SAMARITAN PUNCTUATION BAU"}, +}); +BOOST_DATA_TEST_CASE_F(JPP, load_strings, TEST_STRINGS + TEST_STRINGS_DECODE_ONLY, in, exp) { std::stringstream str {in}; BOOST_CHECK_EQUAL(loadState<std::string>(str), exp); @@ -346,3 +348,11 @@ BOOST_FIXTURE_TEST_CASE(write_test_loaded_shared, JPP) // BOOST_CHECK_EQUAL(ss.str(), // R"({"@typeid":"SharedTestObject","sptr":{"@typeid":"SubObject","@id":"someid"},"ssptr":"someid"})"); } + +BOOST_DATA_TEST_CASE(write_special_strings, TEST_STRINGS, exp, in) +{ + std::stringstream ss; + std::string copy(in); + Persistence::JsonWritePersistence {ss}.saveState(copy); + BOOST_CHECK_EQUAL(ss.str(), exp); +} |