1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-29 23:01:16 +03:00

BSON: Improved documentation and error handling/reporting

This commit is contained in:
Julian Becker
2018-10-07 07:52:12 +02:00
parent e8730e5e82
commit 81f4b34e06
6 changed files with 421 additions and 120 deletions

View File

@ -708,3 +708,22 @@ TEST_CASE("Incomplete BSON INPUT 4")
}
TEST_CASE("Unsupported BSON input")
{
std::vector<uint8_t> bson =
{
0x0C, 0x00, 0x00, 0x00, // size (little endian)
0xFF, // entry type: Min key (not supported yet)
'e', 'n', 't', 'r', 'y', '\x00',
0x00 // end marker
};
CHECK_THROWS_WITH(json::from_bson(bson),
"[json.exception.parse_error.114] parse error at 5: Unsupported BSON record type 0xFF");
CHECK(json::from_bson(bson, true, false).is_discarded());
SaxCountdown scp(0);
CHECK(not json::sax_parse(bson, &scp, json::input_format_t::bson));
}