mirror of
https://github.com/nlohmann/json.git
synced 2025-07-29 23:01:16 +03:00
♿ improved error messages for binary formats #1288
This commit is the equivalent of #1282 for CBOR, MessagePack, and UBJSON.
This commit is contained in:
@ -831,14 +831,14 @@ TEST_CASE("CBOR")
|
||||
{
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0xf9})), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0xf9})),
|
||||
"[json.exception.parse_error.110] parse error at byte 2: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR number: unexpected end of input");
|
||||
CHECK(json::from_cbor(std::vector<uint8_t>({0xf9}), true, false).is_discarded());
|
||||
}
|
||||
SECTION("only one byte follows")
|
||||
{
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0xf9, 0x7c})), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0xf9, 0x7c})),
|
||||
"[json.exception.parse_error.110] parse error at byte 3: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR number: unexpected end of input");
|
||||
CHECK(json::from_cbor(std::vector<uint8_t>({0xf9, 0x7c}), true, false).is_discarded());
|
||||
}
|
||||
}
|
||||
@ -1314,7 +1314,7 @@ TEST_CASE("CBOR")
|
||||
{
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>()), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>()),
|
||||
"[json.exception.parse_error.110] parse error at byte 1: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 1: syntax error while parsing CBOR value: unexpected end of input");
|
||||
CHECK(json::from_cbor(std::vector<uint8_t>(), true, false).is_discarded());
|
||||
}
|
||||
|
||||
@ -1346,53 +1346,53 @@ TEST_CASE("CBOR")
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0xBF, 0x61, 0X61})), json::parse_error&);
|
||||
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x18})),
|
||||
"[json.exception.parse_error.110] parse error at byte 2: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x19})),
|
||||
"[json.exception.parse_error.110] parse error at byte 2: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x19, 0x00})),
|
||||
"[json.exception.parse_error.110] parse error at byte 3: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x1a})),
|
||||
"[json.exception.parse_error.110] parse error at byte 2: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x1a, 0x00})),
|
||||
"[json.exception.parse_error.110] parse error at byte 3: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x1a, 0x00, 0x00})),
|
||||
"[json.exception.parse_error.110] parse error at byte 4: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x1a, 0x00, 0x00, 0x00})),
|
||||
"[json.exception.parse_error.110] parse error at byte 5: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing CBOR number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x1b})),
|
||||
"[json.exception.parse_error.110] parse error at byte 2: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00})),
|
||||
"[json.exception.parse_error.110] parse error at byte 3: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00})),
|
||||
"[json.exception.parse_error.110] parse error at byte 4: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00})),
|
||||
"[json.exception.parse_error.110] parse error at byte 5: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing CBOR number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00})),
|
||||
"[json.exception.parse_error.110] parse error at byte 6: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 6: syntax error while parsing CBOR number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00})),
|
||||
"[json.exception.parse_error.110] parse error at byte 7: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 7: syntax error while parsing CBOR number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})),
|
||||
"[json.exception.parse_error.110] parse error at byte 8: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing CBOR number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})),
|
||||
"[json.exception.parse_error.110] parse error at byte 9: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 9: syntax error while parsing CBOR number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x62})),
|
||||
"[json.exception.parse_error.110] parse error at byte 2: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR string: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x62, 0x60})),
|
||||
"[json.exception.parse_error.110] parse error at byte 3: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR string: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x7F})),
|
||||
"[json.exception.parse_error.110] parse error at byte 2: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR string: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x7F, 0x60})),
|
||||
"[json.exception.parse_error.110] parse error at byte 3: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR string: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x82, 0x01})),
|
||||
"[json.exception.parse_error.110] parse error at byte 3: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR value: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x9F, 0x01})),
|
||||
"[json.exception.parse_error.110] parse error at byte 3: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR value: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0xBF, 0x61, 0x61, 0xF5})),
|
||||
"[json.exception.parse_error.110] parse error at byte 5: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing CBOR string: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0xA1, 0x61, 0x61})),
|
||||
"[json.exception.parse_error.110] parse error at byte 4: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR value: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0xBF, 0x61, 0x61})),
|
||||
"[json.exception.parse_error.110] parse error at byte 4: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR value: unexpected end of input");
|
||||
|
||||
CHECK(json::from_cbor(std::vector<uint8_t>({0x18}), true, false).is_discarded());
|
||||
CHECK(json::from_cbor(std::vector<uint8_t>({0x19}), true, false).is_discarded());
|
||||
@ -1426,12 +1426,12 @@ TEST_CASE("CBOR")
|
||||
{
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1c})), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x1c})),
|
||||
"[json.exception.parse_error.112] parse error at byte 1: error reading CBOR; last byte: 0x1C");
|
||||
"[json.exception.parse_error.112] parse error at byte 1: syntax error while parsing CBOR value: invalid byte: 0x1C");
|
||||
CHECK(json::from_cbor(std::vector<uint8_t>({0x1c}), true, false).is_discarded());
|
||||
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0xf8})), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0xf8})),
|
||||
"[json.exception.parse_error.112] parse error at byte 1: error reading CBOR; last byte: 0xF8");
|
||||
"[json.exception.parse_error.112] parse error at byte 1: syntax error while parsing CBOR value: invalid byte: 0xF8");
|
||||
CHECK(json::from_cbor(std::vector<uint8_t>({0xf8}), true, false).is_discarded());
|
||||
}
|
||||
|
||||
@ -1491,7 +1491,7 @@ TEST_CASE("CBOR")
|
||||
{
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0xa1, 0xff, 0x01})), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0xa1, 0xff, 0x01})),
|
||||
"[json.exception.parse_error.113] parse error at byte 2: expected a CBOR string; last byte: 0xFF");
|
||||
"[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing CBOR string: expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0xFF");
|
||||
CHECK(json::from_cbor(std::vector<uint8_t>({0xa1, 0xff, 0x01}), true, false).is_discarded());
|
||||
}
|
||||
|
||||
@ -1509,7 +1509,7 @@ TEST_CASE("CBOR")
|
||||
{
|
||||
CHECK_THROWS_AS(json::from_cbor(vec), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_cbor(vec),
|
||||
"[json.exception.parse_error.110] parse error at byte 2: expected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR value: expected end of input; last byte: 0xF6");
|
||||
CHECK(json::from_cbor(vec, true, false).is_discarded());
|
||||
}
|
||||
}
|
||||
|
@ -1124,7 +1124,7 @@ TEST_CASE("MessagePack")
|
||||
{
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>()), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>()),
|
||||
"[json.exception.parse_error.110] parse error at byte 1: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 1: syntax error while parsing MessagePack value: unexpected end of input");
|
||||
CHECK(json::from_msgpack(std::vector<uint8_t>(), true, false).is_discarded());
|
||||
}
|
||||
|
||||
@ -1151,43 +1151,43 @@ TEST_CASE("MessagePack")
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0x81, 0xa1, 0x61})), json::parse_error&);
|
||||
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>({0x87})),
|
||||
"[json.exception.parse_error.110] parse error at byte 2: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack string: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>({0xcc})),
|
||||
"[json.exception.parse_error.110] parse error at byte 2: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>({0xcd})),
|
||||
"[json.exception.parse_error.110] parse error at byte 2: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>({0xcd, 0x00})),
|
||||
"[json.exception.parse_error.110] parse error at byte 3: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing MessagePack number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>({0xce})),
|
||||
"[json.exception.parse_error.110] parse error at byte 2: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>({0xce, 0x00})),
|
||||
"[json.exception.parse_error.110] parse error at byte 3: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing MessagePack number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>({0xce, 0x00, 0x00})),
|
||||
"[json.exception.parse_error.110] parse error at byte 4: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing MessagePack number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>({0xce, 0x00, 0x00, 0x00})),
|
||||
"[json.exception.parse_error.110] parse error at byte 5: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing MessagePack number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>({0xcf})),
|
||||
"[json.exception.parse_error.110] parse error at byte 2: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00})),
|
||||
"[json.exception.parse_error.110] parse error at byte 3: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing MessagePack number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00, 0x00})),
|
||||
"[json.exception.parse_error.110] parse error at byte 4: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing MessagePack number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00, 0x00, 0x00})),
|
||||
"[json.exception.parse_error.110] parse error at byte 5: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing MessagePack number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00, 0x00, 0x00, 0x00})),
|
||||
"[json.exception.parse_error.110] parse error at byte 6: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 6: syntax error while parsing MessagePack number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00})),
|
||||
"[json.exception.parse_error.110] parse error at byte 7: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 7: syntax error while parsing MessagePack number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})),
|
||||
"[json.exception.parse_error.110] parse error at byte 8: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing MessagePack number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})),
|
||||
"[json.exception.parse_error.110] parse error at byte 9: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 9: syntax error while parsing MessagePack number: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>({0xa5, 0x68, 0x65})),
|
||||
"[json.exception.parse_error.110] parse error at byte 4: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing MessagePack string: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>({0x92, 0x01})),
|
||||
"[json.exception.parse_error.110] parse error at byte 3: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing MessagePack value: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>({0x81, 0xa1, 0x61})),
|
||||
"[json.exception.parse_error.110] parse error at byte 4: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing MessagePack value: unexpected end of input");
|
||||
|
||||
CHECK(json::from_msgpack(std::vector<uint8_t>({0x87}), true, false).is_discarded());
|
||||
CHECK(json::from_msgpack(std::vector<uint8_t>({0xcc}), true, false).is_discarded());
|
||||
@ -1216,12 +1216,12 @@ TEST_CASE("MessagePack")
|
||||
{
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xc1})), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>({0xc1})),
|
||||
"[json.exception.parse_error.112] parse error at byte 1: error reading MessagePack; last byte: 0xC1");
|
||||
"[json.exception.parse_error.112] parse error at byte 1: syntax error while parsing MessagePack value: invalid byte: 0xC1");
|
||||
CHECK(json::from_msgpack(std::vector<uint8_t>({0xc6}), true, false).is_discarded());
|
||||
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xc6})), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>({0xc6})),
|
||||
"[json.exception.parse_error.112] parse error at byte 1: error reading MessagePack; last byte: 0xC6");
|
||||
"[json.exception.parse_error.112] parse error at byte 1: syntax error while parsing MessagePack value: invalid byte: 0xC6");
|
||||
CHECK(json::from_msgpack(std::vector<uint8_t>({0xc6}), true, false).is_discarded());
|
||||
}
|
||||
|
||||
@ -1249,7 +1249,7 @@ TEST_CASE("MessagePack")
|
||||
{
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0x81, 0xff, 0x01})), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>({0x81, 0xff, 0x01})),
|
||||
"[json.exception.parse_error.113] parse error at byte 2: expected a MessagePack string; last byte: 0xFF");
|
||||
"[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing MessagePack string: expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0xFF");
|
||||
CHECK(json::from_msgpack(std::vector<uint8_t>({0x81, 0xff, 0x01}), true, false).is_discarded());
|
||||
}
|
||||
|
||||
@ -1266,7 +1266,7 @@ TEST_CASE("MessagePack")
|
||||
{
|
||||
CHECK_THROWS_AS(json::from_msgpack(vec), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_msgpack(vec),
|
||||
"[json.exception.parse_error.110] parse error at byte 2: expected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack value: expected end of input; last byte: 0xC0");
|
||||
CHECK(json::from_msgpack(vec, true, false).is_discarded());
|
||||
}
|
||||
}
|
||||
|
@ -930,7 +930,7 @@ TEST_CASE("regression tests")
|
||||
std::vector<uint8_t> vec {0x65, 0xf5, 0x0a, 0x48, 0x21};
|
||||
CHECK_THROWS_AS(json::from_cbor(vec), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_cbor(vec),
|
||||
"[json.exception.parse_error.110] parse error at byte 6: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 6: syntax error while parsing CBOR string: unexpected end of input");
|
||||
}
|
||||
|
||||
SECTION("issue #407 - Heap-buffer-overflow (OSS-Fuzz issue 343)")
|
||||
@ -939,31 +939,31 @@ TEST_CASE("regression tests")
|
||||
std::vector<uint8_t> vec1 {0xcb, 0x8f, 0x0a};
|
||||
CHECK_THROWS_AS(json::from_msgpack(vec1), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_msgpack(vec1),
|
||||
"[json.exception.parse_error.110] parse error at byte 4: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing MessagePack number: unexpected end of input");
|
||||
|
||||
// related test case: incomplete float32
|
||||
std::vector<uint8_t> vec2 {0xca, 0x8f, 0x0a};
|
||||
CHECK_THROWS_AS(json::from_msgpack(vec2), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_msgpack(vec2),
|
||||
"[json.exception.parse_error.110] parse error at byte 4: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing MessagePack number: unexpected end of input");
|
||||
|
||||
// related test case: incomplete Half-Precision Float (CBOR)
|
||||
std::vector<uint8_t> vec3 {0xf9, 0x8f};
|
||||
CHECK_THROWS_AS(json::from_cbor(vec3), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_cbor(vec3),
|
||||
"[json.exception.parse_error.110] parse error at byte 3: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR number: unexpected end of input");
|
||||
|
||||
// related test case: incomplete Single-Precision Float (CBOR)
|
||||
std::vector<uint8_t> vec4 {0xfa, 0x8f, 0x0a};
|
||||
CHECK_THROWS_AS(json::from_cbor(vec4), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_cbor(vec4),
|
||||
"[json.exception.parse_error.110] parse error at byte 4: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR number: unexpected end of input");
|
||||
|
||||
// related test case: incomplete Double-Precision Float (CBOR)
|
||||
std::vector<uint8_t> vec5 {0xfb, 0x8f, 0x0a};
|
||||
CHECK_THROWS_AS(json::from_cbor(vec5), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_cbor(vec5),
|
||||
"[json.exception.parse_error.110] parse error at byte 4: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR number: unexpected end of input");
|
||||
}
|
||||
|
||||
SECTION("issue #408 - Heap-buffer-overflow (OSS-Fuzz issue 344)")
|
||||
@ -972,7 +972,7 @@ TEST_CASE("regression tests")
|
||||
std::vector<uint8_t> vec1 {0x87};
|
||||
CHECK_THROWS_AS(json::from_msgpack(vec1), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_msgpack(vec1),
|
||||
"[json.exception.parse_error.110] parse error at byte 2: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack string: unexpected end of input");
|
||||
|
||||
// more test cases for MessagePack
|
||||
for (auto b :
|
||||
@ -1006,10 +1006,10 @@ TEST_CASE("regression tests")
|
||||
std::vector<uint8_t> vec2;
|
||||
CHECK_THROWS_AS(json::from_cbor(vec2), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_cbor(vec2),
|
||||
"[json.exception.parse_error.110] parse error at byte 1: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 1: syntax error while parsing CBOR value: unexpected end of input");
|
||||
CHECK_THROWS_AS(json::from_msgpack(vec2), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_msgpack(vec2),
|
||||
"[json.exception.parse_error.110] parse error at byte 1: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 1: syntax error while parsing MessagePack value: unexpected end of input");
|
||||
}
|
||||
|
||||
SECTION("issue #411 - Heap-buffer-overflow (OSS-Fuzz issue 366)")
|
||||
@ -1018,19 +1018,19 @@ TEST_CASE("regression tests")
|
||||
std::vector<uint8_t> vec1 {0x7f};
|
||||
CHECK_THROWS_AS(json::from_cbor(vec1), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_cbor(vec1),
|
||||
"[json.exception.parse_error.110] parse error at byte 2: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR string: unexpected end of input");
|
||||
|
||||
// related test case: empty array (indefinite length)
|
||||
std::vector<uint8_t> vec2 {0x9f};
|
||||
CHECK_THROWS_AS(json::from_cbor(vec2), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_cbor(vec2),
|
||||
"[json.exception.parse_error.110] parse error at byte 2: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR value: unexpected end of input");
|
||||
|
||||
// related test case: empty map (indefinite length)
|
||||
std::vector<uint8_t> vec3 {0xbf};
|
||||
CHECK_THROWS_AS(json::from_cbor(vec3), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_cbor(vec3),
|
||||
"[json.exception.parse_error.110] parse error at byte 2: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR string: unexpected end of input");
|
||||
}
|
||||
|
||||
SECTION("issue #412 - Heap-buffer-overflow (OSS-Fuzz issue 367)")
|
||||
@ -1058,25 +1058,25 @@ TEST_CASE("regression tests")
|
||||
};
|
||||
CHECK_THROWS_AS(json::from_cbor(vec), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_cbor(vec),
|
||||
"[json.exception.parse_error.113] parse error at byte 2: expected a CBOR string; last byte: 0x98");
|
||||
"[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing CBOR string: expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x98");
|
||||
|
||||
// related test case: nonempty UTF-8 string (indefinite length)
|
||||
std::vector<uint8_t> vec1 {0x7f, 0x61, 0x61};
|
||||
CHECK_THROWS_AS(json::from_cbor(vec1), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_cbor(vec1),
|
||||
"[json.exception.parse_error.110] parse error at byte 4: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR string: unexpected end of input");
|
||||
|
||||
// related test case: nonempty array (indefinite length)
|
||||
std::vector<uint8_t> vec2 {0x9f, 0x01};
|
||||
CHECK_THROWS_AS(json::from_cbor(vec2), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_cbor(vec2),
|
||||
"[json.exception.parse_error.110] parse error at byte 3: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR value: unexpected end of input");
|
||||
|
||||
// related test case: nonempty map (indefinite length)
|
||||
std::vector<uint8_t> vec3 {0xbf, 0x61, 0x61, 0x01};
|
||||
CHECK_THROWS_AS(json::from_cbor(vec3), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_cbor(vec3),
|
||||
"[json.exception.parse_error.110] parse error at byte 5: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing CBOR string: unexpected end of input");
|
||||
}
|
||||
|
||||
SECTION("issue #414 - compare with literal 0)")
|
||||
@ -1111,7 +1111,7 @@ TEST_CASE("regression tests")
|
||||
};
|
||||
CHECK_THROWS_AS(json::from_cbor(vec1), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_cbor(vec1),
|
||||
"[json.exception.parse_error.113] parse error at byte 13: expected a CBOR string; last byte: 0xB4");
|
||||
"[json.exception.parse_error.113] parse error at byte 13: syntax error while parsing CBOR string: expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0xB4");
|
||||
|
||||
// related test case: double-precision
|
||||
std::vector<uint8_t> vec2
|
||||
@ -1125,7 +1125,7 @@ TEST_CASE("regression tests")
|
||||
};
|
||||
CHECK_THROWS_AS(json::from_cbor(vec2), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_cbor(vec2),
|
||||
"[json.exception.parse_error.113] parse error at byte 13: expected a CBOR string; last byte: 0xB4");
|
||||
"[json.exception.parse_error.113] parse error at byte 13: syntax error while parsing CBOR string: expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0xB4");
|
||||
}
|
||||
|
||||
SECTION("issue #452 - Heap-buffer-overflow (OSS-Fuzz issue 585)")
|
||||
|
@ -1299,7 +1299,7 @@ TEST_CASE("UBJSON")
|
||||
{
|
||||
CHECK_THROWS_AS(json::from_ubjson(vec), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vec),
|
||||
"[json.exception.parse_error.110] parse error at byte 2: expected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing UBJSON value: expected end of input; last byte: 0x5A");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1308,7 +1308,7 @@ TEST_CASE("UBJSON")
|
||||
// larger than max int64
|
||||
json j = 9223372036854775808llu;
|
||||
CHECK_THROWS_AS(json::to_ubjson(j), json::out_of_range&);
|
||||
CHECK_THROWS_WITH(json::to_ubjson(j), "[json.exception.out_of_range.407] number overflow serializing 9223372036854775808");
|
||||
CHECK_THROWS_WITH(json::to_ubjson(j), "[json.exception.out_of_range.407] integer number 9223372036854775808 cannot be represented by UBJSON as it does not fit int64");
|
||||
}
|
||||
|
||||
SECTION("excessive size")
|
||||
@ -1529,7 +1529,7 @@ TEST_CASE("UBJSON")
|
||||
{
|
||||
CHECK_THROWS_AS(json::from_ubjson(std::vector<uint8_t>()), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(std::vector<uint8_t>()),
|
||||
"[json.exception.parse_error.110] parse error at byte 1: unexpected end of input");
|
||||
"[json.exception.parse_error.110] parse error at byte 1: syntax error while parsing UBJSON value: unexpected end of input");
|
||||
}
|
||||
|
||||
SECTION("char")
|
||||
@ -1538,14 +1538,14 @@ TEST_CASE("UBJSON")
|
||||
{
|
||||
std::vector<uint8_t> v = {'C'};
|
||||
CHECK_THROWS_AS(json::from_ubjson(v), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.110] parse error at byte 2: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing UBJSON char: unexpected end of input");
|
||||
}
|
||||
|
||||
SECTION("byte out of range")
|
||||
{
|
||||
std::vector<uint8_t> v = {'C', 130};
|
||||
CHECK_THROWS_AS(json::from_ubjson(v), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.113] parse error at byte 2: byte after 'C' must be in range 0x00..0x7F; last byte: 0x82");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing UBJSON char: byte after 'C' must be in range 0x00..0x7F; last byte: 0x82");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1555,14 +1555,14 @@ TEST_CASE("UBJSON")
|
||||
{
|
||||
std::vector<uint8_t> v = {'S'};
|
||||
CHECK_THROWS_AS(json::from_ubjson(v), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.110] parse error at byte 2: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing UBJSON value: unexpected end of input");
|
||||
}
|
||||
|
||||
SECTION("invalid byte")
|
||||
{
|
||||
std::vector<uint8_t> v = {'S', '1', 'a'};
|
||||
CHECK_THROWS_AS(json::from_ubjson(v), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.113] parse error at byte 2: expected a UBJSON string; last byte: 0x31");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing UBJSON string: expected length type specification (U, i, I, l, L); last byte: 0x31");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1572,7 +1572,7 @@ TEST_CASE("UBJSON")
|
||||
{
|
||||
std::vector<uint8_t> v = {'[', '$', 'i', 2};
|
||||
CHECK_THROWS_AS(json::from_ubjson(v), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.112] parse error at byte 4: expected '#' after UBJSON type information; last byte: 0x02");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.112] parse error at byte 4: syntax error while parsing UBJSON size: expected '#' after type information; last byte: 0x02");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1580,17 +1580,17 @@ TEST_CASE("UBJSON")
|
||||
{
|
||||
std::vector<uint8_t> vS = {'S'};
|
||||
CHECK_THROWS_AS(json::from_ubjson(vS), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vS), "[json.exception.parse_error.110] parse error at byte 2: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vS), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing UBJSON value: unexpected end of input");
|
||||
CHECK(json::from_ubjson(vS, true, false).is_discarded());
|
||||
|
||||
std::vector<uint8_t> v = {'S', 'i', '2', 'a'};
|
||||
CHECK_THROWS_AS(json::from_ubjson(v), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.110] parse error at byte 5: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing UBJSON string: unexpected end of input");
|
||||
CHECK(json::from_ubjson(v, true, false).is_discarded());
|
||||
|
||||
std::vector<uint8_t> vC = {'C'};
|
||||
CHECK_THROWS_AS(json::from_ubjson(vC), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vC), "[json.exception.parse_error.110] parse error at byte 2: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vC), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing UBJSON char: unexpected end of input");
|
||||
CHECK(json::from_ubjson(vC, true, false).is_discarded());
|
||||
}
|
||||
|
||||
@ -1598,32 +1598,32 @@ TEST_CASE("UBJSON")
|
||||
{
|
||||
std::vector<uint8_t> vU = {'[', '#', 'U'};
|
||||
CHECK_THROWS_AS(json::from_ubjson(vU), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vU), "[json.exception.parse_error.110] parse error at byte 4: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vU), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON number: unexpected end of input");
|
||||
CHECK(json::from_ubjson(vU, true, false).is_discarded());
|
||||
|
||||
std::vector<uint8_t> vi = {'[', '#', 'i'};
|
||||
CHECK_THROWS_AS(json::from_ubjson(vi), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vi), "[json.exception.parse_error.110] parse error at byte 4: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vi), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON number: unexpected end of input");
|
||||
CHECK(json::from_ubjson(vi, true, false).is_discarded());
|
||||
|
||||
std::vector<uint8_t> vI = {'[', '#', 'I'};
|
||||
CHECK_THROWS_AS(json::from_ubjson(vI), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vI), "[json.exception.parse_error.110] parse error at byte 4: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vI), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON number: unexpected end of input");
|
||||
CHECK(json::from_ubjson(vI, true, false).is_discarded());
|
||||
|
||||
std::vector<uint8_t> vl = {'[', '#', 'l'};
|
||||
CHECK_THROWS_AS(json::from_ubjson(vl), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vl), "[json.exception.parse_error.110] parse error at byte 4: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vl), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON number: unexpected end of input");
|
||||
CHECK(json::from_ubjson(vl, true, false).is_discarded());
|
||||
|
||||
std::vector<uint8_t> vL = {'[', '#', 'L'};
|
||||
CHECK_THROWS_AS(json::from_ubjson(vL), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vL), "[json.exception.parse_error.110] parse error at byte 4: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vL), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON number: unexpected end of input");
|
||||
CHECK(json::from_ubjson(vL, true, false).is_discarded());
|
||||
|
||||
std::vector<uint8_t> v0 = {'[', '#', 'T', ']'};
|
||||
CHECK_THROWS_AS(json::from_ubjson(v0), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(v0), "[json.exception.parse_error.113] parse error at byte 3: byte after '#' must denote a number type; last byte: 0x54");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(v0), "[json.exception.parse_error.113] parse error at byte 3: syntax error while parsing UBJSON size: expected length type specification (U, i, I, l, L) after '#'; last byte: 0x54");
|
||||
CHECK(json::from_ubjson(v0, true, false).is_discarded());
|
||||
}
|
||||
|
||||
@ -1631,17 +1631,17 @@ TEST_CASE("UBJSON")
|
||||
{
|
||||
std::vector<uint8_t> v0 = {'[', '$'};
|
||||
CHECK_THROWS_AS(json::from_ubjson(v0), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(v0), "[json.exception.parse_error.110] parse error at byte 3: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(v0), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing UBJSON type: unexpected end of input");
|
||||
CHECK(json::from_ubjson(v0, true, false).is_discarded());
|
||||
|
||||
std::vector<uint8_t> vi = {'[', '$', '#'};
|
||||
CHECK_THROWS_AS(json::from_ubjson(vi), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vi), "[json.exception.parse_error.110] parse error at byte 4: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vi), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON value: unexpected end of input");
|
||||
CHECK(json::from_ubjson(vi, true, false).is_discarded());
|
||||
|
||||
std::vector<uint8_t> vT = {'[', '$', 'T'};
|
||||
CHECK_THROWS_AS(json::from_ubjson(vT), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vT), "[json.exception.parse_error.110] parse error at byte 4: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vT), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON value: unexpected end of input");
|
||||
CHECK(json::from_ubjson(vT, true, false).is_discarded());
|
||||
}
|
||||
|
||||
@ -1649,17 +1649,17 @@ TEST_CASE("UBJSON")
|
||||
{
|
||||
std::vector<uint8_t> vST = {'[', '$', 'i', '#', 'i', 2, 1};
|
||||
CHECK_THROWS_AS(json::from_ubjson(vST), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vST), "[json.exception.parse_error.110] parse error at byte 8: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vST), "[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing UBJSON number: unexpected end of input");
|
||||
CHECK(json::from_ubjson(vST, true, false).is_discarded());
|
||||
|
||||
std::vector<uint8_t> vS = {'[', '#', 'i', 2, 'i', 1};
|
||||
CHECK_THROWS_AS(json::from_ubjson(vS), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vS), "[json.exception.parse_error.110] parse error at byte 7: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vS), "[json.exception.parse_error.110] parse error at byte 7: syntax error while parsing UBJSON value: unexpected end of input");
|
||||
CHECK(json::from_ubjson(vS, true, false).is_discarded());
|
||||
|
||||
std::vector<uint8_t> v = {'[', 'i', 2, 'i', 1};
|
||||
CHECK_THROWS_AS(json::from_ubjson(v), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.110] parse error at byte 6: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.110] parse error at byte 6: syntax error while parsing UBJSON value: unexpected end of input");
|
||||
CHECK(json::from_ubjson(v, true, false).is_discarded());
|
||||
}
|
||||
|
||||
@ -1667,42 +1667,42 @@ TEST_CASE("UBJSON")
|
||||
{
|
||||
std::vector<uint8_t> vST = {'{', '$', 'i', '#', 'i', 2, 'i', 1, 'a', 1};
|
||||
CHECK_THROWS_AS(json::from_ubjson(vST), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vST), "[json.exception.parse_error.110] parse error at byte 11: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vST), "[json.exception.parse_error.110] parse error at byte 11: syntax error while parsing UBJSON value: unexpected end of input");
|
||||
CHECK(json::from_ubjson(vST, true, false).is_discarded());
|
||||
|
||||
std::vector<uint8_t> vT = {'{', '$', 'i', 'i', 1, 'a', 1};
|
||||
CHECK_THROWS_AS(json::from_ubjson(vT), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vT), "[json.exception.parse_error.112] parse error at byte 4: expected '#' after UBJSON type information; last byte: 0x69");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vT), "[json.exception.parse_error.112] parse error at byte 4: syntax error while parsing UBJSON size: expected '#' after type information; last byte: 0x69");
|
||||
CHECK(json::from_ubjson(vT, true, false).is_discarded());
|
||||
|
||||
std::vector<uint8_t> vS = {'{', '#', 'i', 2, 'i', 1, 'a', 'i', 1};
|
||||
CHECK_THROWS_AS(json::from_ubjson(vS), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vS), "[json.exception.parse_error.110] parse error at byte 10: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vS), "[json.exception.parse_error.110] parse error at byte 10: syntax error while parsing UBJSON value: unexpected end of input");
|
||||
CHECK(json::from_ubjson(vS, true, false).is_discarded());
|
||||
|
||||
std::vector<uint8_t> v = {'{', 'i', 1, 'a', 'i', 1};
|
||||
CHECK_THROWS_AS(json::from_ubjson(v), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.110] parse error at byte 7: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.110] parse error at byte 7: syntax error while parsing UBJSON value: unexpected end of input");
|
||||
CHECK(json::from_ubjson(v, true, false).is_discarded());
|
||||
|
||||
std::vector<uint8_t> v2 = {'{', 'i', 1, 'a', 'i', 1, 'i'};
|
||||
CHECK_THROWS_AS(json::from_ubjson(v2), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(v2), "[json.exception.parse_error.110] parse error at byte 8: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(v2), "[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing UBJSON number: unexpected end of input");
|
||||
CHECK(json::from_ubjson(v2, true, false).is_discarded());
|
||||
|
||||
std::vector<uint8_t> v3 = {'{', 'i', 1, 'a'};
|
||||
CHECK_THROWS_AS(json::from_ubjson(v3), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(v3), "[json.exception.parse_error.110] parse error at byte 5: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(v3), "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing UBJSON value: unexpected end of input");
|
||||
CHECK(json::from_ubjson(v3, true, false).is_discarded());
|
||||
|
||||
std::vector<uint8_t> vST1 = {'{', '$', 'd', '#', 'i', 2, 'i', 1, 'a'};
|
||||
CHECK_THROWS_AS(json::from_ubjson(vST1), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vST1), "[json.exception.parse_error.110] parse error at byte 10: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vST1), "[json.exception.parse_error.110] parse error at byte 10: syntax error while parsing UBJSON number: unexpected end of input");
|
||||
CHECK(json::from_ubjson(vST1, true, false).is_discarded());
|
||||
|
||||
std::vector<uint8_t> vST2 = {'{', '#', 'i', 2, 'i', 1, 'a'};
|
||||
CHECK_THROWS_AS(json::from_ubjson(vST2), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vST2), "[json.exception.parse_error.110] parse error at byte 8: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_ubjson(vST2), "[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing UBJSON value: unexpected end of input");
|
||||
CHECK(json::from_ubjson(vST2, true, false).is_discarded());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user