improved test coverage #1031

This commit is contained in:
Niels Lohmann 2018-04-02 15:38:49 +02:00
parent 16c5bfeaad
commit 6678eb2b4a
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69

View file

@ -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&);
}
}
}