🔨 a lot of restructuring
- removed uncached input stream adapter; it was too slow anyway - implemented a class binary_read which parses CBOR based on input adapters - in the CBOR parser, numbers are created via memcpy to avoid undefined behavior
This commit is contained in:
parent
3a5cf9bd0a
commit
89efe627fe
4 changed files with 948 additions and 423 deletions
|
|
@ -1166,35 +1166,35 @@ TEST_CASE("CBOR")
|
|||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error);
|
||||
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x18})),
|
||||
"[json.exception.parse_error.110] parse error at 2: cannot read 1 bytes from vector");
|
||||
"[json.exception.parse_error.110] parse error at 2: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x19})),
|
||||
"[json.exception.parse_error.110] parse error at 2: cannot read 2 bytes from vector");
|
||||
"[json.exception.parse_error.110] parse error at 2: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x19, 0x00})),
|
||||
"[json.exception.parse_error.110] parse error at 2: cannot read 2 bytes from vector");
|
||||
"[json.exception.parse_error.110] parse error at 3: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x1a})),
|
||||
"[json.exception.parse_error.110] parse error at 2: cannot read 4 bytes from vector");
|
||||
"[json.exception.parse_error.110] parse error at 2: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x1a, 0x00})),
|
||||
"[json.exception.parse_error.110] parse error at 2: cannot read 4 bytes from vector");
|
||||
"[json.exception.parse_error.110] parse error at 3: 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 2: cannot read 4 bytes from vector");
|
||||
"[json.exception.parse_error.110] parse error at 4: 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 2: cannot read 4 bytes from vector");
|
||||
"[json.exception.parse_error.110] parse error at 5: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x1b})),
|
||||
"[json.exception.parse_error.110] parse error at 2: cannot read 8 bytes from vector");
|
||||
"[json.exception.parse_error.110] parse error at 2: unexpected end of input");
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00})),
|
||||
"[json.exception.parse_error.110] parse error at 2: cannot read 8 bytes from vector");
|
||||
"[json.exception.parse_error.110] parse error at 3: 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 2: cannot read 8 bytes from vector");
|
||||
"[json.exception.parse_error.110] parse error at 4: 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 2: cannot read 8 bytes from vector");
|
||||
"[json.exception.parse_error.110] parse error at 5: 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 2: cannot read 8 bytes from vector");
|
||||
"[json.exception.parse_error.110] parse error at 6: 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 2: cannot read 8 bytes from vector");
|
||||
"[json.exception.parse_error.110] parse error at 7: 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 2: cannot read 8 bytes from vector");
|
||||
"[json.exception.parse_error.110] parse error at 8: 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 2: cannot read 8 bytes from vector");
|
||||
"[json.exception.parse_error.110] parse error at 9: unexpected end of input");
|
||||
}
|
||||
|
||||
SECTION("unsupported bytes")
|
||||
|
|
@ -1756,7 +1756,7 @@ TEST_CASE("examples from RFC 7049 Appendix A")
|
|||
CHECK(json::parse("\"\\ud800\\udd51\"") == json::from_cbor(std::vector<uint8_t>({0x64, 0xf0, 0x90, 0x85, 0x91})));
|
||||
|
||||
// indefinite length strings
|
||||
CHECK(json::parse("\"streaming\"") == json::from_cbor(std::vector<uint8_t>({0x7f, 0x65, 0x73, 0x74, 0x72, 0x65, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x67, 0xff})));
|
||||
CHECK(json::parse("\"streaming\"") == json::from_cbor(std::vector<uint8_t>({0x7f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x69, 0x6e, 0x67, 0xff})));
|
||||
}
|
||||
|
||||
SECTION("arrays")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue