diff options
Diffstat (limited to 'toolsrc/src/vcpkg-test/json.cpp')
| -rw-r--r-- | toolsrc/src/vcpkg-test/json.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/toolsrc/src/vcpkg-test/json.cpp b/toolsrc/src/vcpkg-test/json.cpp index 90a3537ab..0b9941861 100644 --- a/toolsrc/src/vcpkg-test/json.cpp +++ b/toolsrc/src/vcpkg-test/json.cpp @@ -80,6 +80,49 @@ TEST_CASE ("JSON parse strings", "[json]") REQUIRE(res.get()->first.string() == grin); } +TEST_CASE ("JSON parse strings with escapes", "[json]") +{ + auto res = Json::parse(R"("\t")"); + REQUIRE(res); + REQUIRE(res.get()->first.is_string()); + REQUIRE(res.get()->first.string() == "\t"); + + res = Json::parse(R"("\\")"); + REQUIRE(res); + REQUIRE(res.get()->first.is_string()); + REQUIRE(res.get()->first.string() == "\\"); + + res = Json::parse(R"("\/")"); + REQUIRE(res); + REQUIRE(res.get()->first.is_string()); + REQUIRE(res.get()->first.string() == "/"); + + res = Json::parse(R"("\b")"); + REQUIRE(res); + REQUIRE(res.get()->first.is_string()); + REQUIRE(res.get()->first.string() == "\b"); + + res = Json::parse(R"("\f")"); + REQUIRE(res); + REQUIRE(res.get()->first.is_string()); + REQUIRE(res.get()->first.string() == "\f"); + + res = Json::parse(R"("\n")"); + REQUIRE(res); + REQUIRE(res.get()->first.is_string()); + REQUIRE(res.get()->first.string() == "\n"); + + res = Json::parse(R"("\r")"); + REQUIRE(res); + REQUIRE(res.get()->first.is_string()); + REQUIRE(res.get()->first.string() == "\r"); + + res = Json::parse(R"("This is a \"test\", hopefully it worked")"); + REQUIRE(res); + REQUIRE(res.get()->first.is_string()); + REQUIRE(res.get()->first.string() == R"(This is a "test", hopefully it worked)"); +} + TEST_CASE ("JSON parse integers", "[json]") { auto res = Json::parse("0"); |
