BSON: throw json.exception.out_of_range.409 in case a key to be serialized to BSON contains a U+0000

This commit is contained in:
Julian Becker 2018-10-16 20:42:00 +02:00
parent daa3ca8a2e
commit 978c3c4116
5 changed files with 30 additions and 2 deletions

View file

@ -91,6 +91,16 @@ TEST_CASE("BSON")
}
}
SECTION("keys containing code-point U+0000 cannot be serialized to BSON")
{
json j =
{
{ std::string("en\0try", 6), true }
};
REQUIRE_THROWS_AS(json::to_bson(j), json::out_of_range);
CHECK_THROWS_WITH(json::to_bson(j), "[json.exception.out_of_range.409] BSON key cannot contain code point U+0000");
}
SECTION("objects")
{
SECTION("empty object")