From 6678eb2b4a1eab6c555c90a4d4a95907df1e909c Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 2 Apr 2018 15:38:49 +0200 Subject: [PATCH] :white_check_mark: improved test coverage #1031 --- test/src/unit-wstring.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/src/unit-wstring.cpp b/test/src/unit-wstring.cpp index a9f2c194..37cf42db 100644 --- a/test/src/unit-wstring.cpp +++ b/test/src/unit-wstring.cpp @@ -62,6 +62,15 @@ TEST_CASE("wide strings") } } + SECTION("invalid std::wstring") + { + if (wstring_is_utf16()) + { + std::wstring w = L"\"\xDBFF"; + CHECK_THROWS_AS(json::parse(w), json::parse_error&); + } + } + SECTION("std::u16string") { if (u16string_is_utf16()) @@ -72,6 +81,15 @@ TEST_CASE("wide strings") } } + SECTION("invalid std::u16string") + { + if (wstring_is_utf16()) + { + std::u16string w = u"\"\xDBFF"; + CHECK_THROWS_AS(json::parse(w), json::parse_error&); + } + } + SECTION("std::u32string") { if (u32string_is_utf32()) @@ -81,4 +99,13 @@ TEST_CASE("wide strings") CHECK(j.dump() == "[12.2,\"Ⴥaäö💤🧢\"]"); } } + + SECTION("invalid std::u32string") + { + if (u32string_is_utf32()) + { + std::u32string w = U"\"\x110000"; + CHECK_THROWS_AS(json::parse(w), json::parse_error&); + } + } }