mirror of
https://github.com/nlohmann/json.git
synced 2026-11-09 14:01:47 +00:00
Fix the msgpack 2^32-1 element recovery test on 32-bit targets
On a 32-bit target (clang-cl Win32) 0xFFFFFFFF elements exceed the array's max_size(), so the array is rejected before it is started and the recovered value is null rather than an empty array. Expect that. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
1 file changed
+4
-1
@@ -380,9 +380,12 @@ TEST_CASE("regression test - #3989 SAX parse_error() returning true")
|
||||
CHECK(cbor_map.errors == 1);
|
||||
CHECK(cbor_map.value == json({{"a", nullptr}}));
|
||||
|
||||
// 2^32-1 elements: on a 32-bit target this exceeds the array's max_size(),
|
||||
// so the array is rejected before it is started and the value stays null
|
||||
const auto msgpack_array = parse_binary_recovering({0xDD, 0xFF, 0xFF, 0xFF, 0xFF}, json::input_format_t::msgpack);
|
||||
const bool msgpack_array_fits = json::array_t().max_size() >= 0xFFFFFFFFu;
|
||||
CHECK(msgpack_array.errors == 1);
|
||||
CHECK(msgpack_array.value == json::array());
|
||||
CHECK(msgpack_array.value == (msgpack_array_fits ? json::array() : json(nullptr)));
|
||||
|
||||
const auto msgpack_map = parse_binary_recovering({0x81, 0xA1, 'a', 0x92, 0x01}, json::input_format_t::msgpack);
|
||||
CHECK(msgpack_map.errors == 1);
|
||||
|
||||
Reference in new issue
Block a user