mirror of
https://github.com/nlohmann/json.git
synced 2024-07-04 21:36:57 +02:00
🚨 fix warnings
This commit is contained in:
parent
af8c6e7aa9
commit
c026e1a475
|
@ -867,8 +867,9 @@ TEST_CASE("Negative size of binary value")
|
||||||
|
|
||||||
0x00 // end marker
|
0x00 // end marker
|
||||||
};
|
};
|
||||||
CHECK_THROWS_AS(json::from_bson(input), json::parse_error);
|
json _;
|
||||||
CHECK_THROWS_WITH(json::from_bson(input), "[json.exception.parse_error.112] parse error at byte 15: syntax error while parsing BSON binary: byte array length cannot be negative, is -1");
|
CHECK_THROWS_AS(_ = json::from_bson(input), json::parse_error);
|
||||||
|
CHECK_THROWS_WITH(_ = json::from_bson(input), "[json.exception.parse_error.112] parse error at byte 15: syntax error while parsing BSON binary: byte array length cannot be negative, is -1");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Unsupported BSON input")
|
TEST_CASE("Unsupported BSON input")
|
||||||
|
|
|
@ -1591,14 +1591,16 @@ TEST_CASE("CBOR")
|
||||||
{
|
{
|
||||||
// array with three empty byte strings
|
// array with three empty byte strings
|
||||||
std::vector<std::uint8_t> input = {0x83, 0x40, 0x40, 0x40};
|
std::vector<std::uint8_t> input = {0x83, 0x40, 0x40, 0x40};
|
||||||
CHECK_NOTHROW(json::from_cbor(input));
|
json _;
|
||||||
|
CHECK_NOTHROW(_ = json::from_cbor(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("binary in object")
|
SECTION("binary in object")
|
||||||
{
|
{
|
||||||
// object mapping "foo" to empty byte string
|
// object mapping "foo" to empty byte string
|
||||||
std::vector<std::uint8_t> input = {0xA1, 0x63, 0x66, 0x6F, 0x6F, 0x40};
|
std::vector<std::uint8_t> input = {0xA1, 0x63, 0x66, 0x6F, 0x6F, 0x40};
|
||||||
CHECK_NOTHROW(json::from_cbor(input));
|
json _;
|
||||||
|
CHECK_NOTHROW(_ = json::from_cbor(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("SAX callback with binary")
|
SECTION("SAX callback with binary")
|
||||||
|
@ -2551,8 +2553,9 @@ TEST_CASE("Tagged values")
|
||||||
v_tagged.insert(v_tagged.begin(), b);
|
v_tagged.insert(v_tagged.begin(), b);
|
||||||
|
|
||||||
// check that parsing fails in error mode
|
// check that parsing fails in error mode
|
||||||
CHECK_THROWS_AS(json::from_cbor(v_tagged), json::parse_error);
|
json _;
|
||||||
CHECK_THROWS_AS(json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::error), json::parse_error);
|
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error);
|
||||||
|
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::error), json::parse_error);
|
||||||
|
|
||||||
// check that parsing succeeds and gets original value in ignore mode
|
// check that parsing succeeds and gets original value in ignore mode
|
||||||
auto j_tagged = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore);
|
auto j_tagged = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore);
|
||||||
|
@ -2570,8 +2573,9 @@ TEST_CASE("Tagged values")
|
||||||
v_tagged.insert(v_tagged.begin(), 0xD8); // tag
|
v_tagged.insert(v_tagged.begin(), 0xD8); // tag
|
||||||
|
|
||||||
// check that parsing fails in error mode
|
// check that parsing fails in error mode
|
||||||
CHECK_THROWS_AS(json::from_cbor(v_tagged), json::parse_error);
|
json _;
|
||||||
CHECK_THROWS_AS(json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::error), json::parse_error);
|
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error);
|
||||||
|
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::error), json::parse_error);
|
||||||
|
|
||||||
// check that parsing succeeds and gets original value in ignore mode
|
// check that parsing succeeds and gets original value in ignore mode
|
||||||
auto j_tagged = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore);
|
auto j_tagged = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore);
|
||||||
|
@ -2585,9 +2589,10 @@ TEST_CASE("Tagged values")
|
||||||
v_tagged.insert(v_tagged.begin(), 0xD8); // tag
|
v_tagged.insert(v_tagged.begin(), 0xD8); // tag
|
||||||
|
|
||||||
// check that parsing fails in all modes
|
// check that parsing fails in all modes
|
||||||
CHECK_THROWS_AS(json::from_cbor(v_tagged), json::parse_error);
|
json _;
|
||||||
CHECK_THROWS_AS(json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::error), json::parse_error);
|
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error);
|
||||||
CHECK_THROWS_AS(json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore), json::parse_error);
|
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::error), json::parse_error);
|
||||||
|
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore), json::parse_error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2602,8 +2607,9 @@ TEST_CASE("Tagged values")
|
||||||
v_tagged.insert(v_tagged.begin(), 0xD9); // tag
|
v_tagged.insert(v_tagged.begin(), 0xD9); // tag
|
||||||
|
|
||||||
// check that parsing fails in error mode
|
// check that parsing fails in error mode
|
||||||
CHECK_THROWS_AS(json::from_cbor(v_tagged), json::parse_error);
|
json _;
|
||||||
CHECK_THROWS_AS(json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::error), json::parse_error);
|
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error);
|
||||||
|
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::error), json::parse_error);
|
||||||
|
|
||||||
// check that parsing succeeds and gets original value in ignore mode
|
// check that parsing succeeds and gets original value in ignore mode
|
||||||
auto j_tagged = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore);
|
auto j_tagged = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore);
|
||||||
|
@ -2618,9 +2624,10 @@ TEST_CASE("Tagged values")
|
||||||
v_tagged.insert(v_tagged.begin(), 0xD9); // tag
|
v_tagged.insert(v_tagged.begin(), 0xD9); // tag
|
||||||
|
|
||||||
// check that parsing fails in all modes
|
// check that parsing fails in all modes
|
||||||
CHECK_THROWS_AS(json::from_cbor(v_tagged), json::parse_error);
|
json _;
|
||||||
CHECK_THROWS_AS(json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::error), json::parse_error);
|
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error);
|
||||||
CHECK_THROWS_AS(json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore), json::parse_error);
|
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::error), json::parse_error);
|
||||||
|
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore), json::parse_error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2637,8 +2644,9 @@ TEST_CASE("Tagged values")
|
||||||
v_tagged.insert(v_tagged.begin(), 0xDA); // tag
|
v_tagged.insert(v_tagged.begin(), 0xDA); // tag
|
||||||
|
|
||||||
// check that parsing fails in error mode
|
// check that parsing fails in error mode
|
||||||
CHECK_THROWS_AS(json::from_cbor(v_tagged), json::parse_error);
|
json _;
|
||||||
CHECK_THROWS_AS(json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::error), json::parse_error);
|
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error);
|
||||||
|
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::error), json::parse_error);
|
||||||
|
|
||||||
// check that parsing succeeds and gets original value in ignore mode
|
// check that parsing succeeds and gets original value in ignore mode
|
||||||
auto j_tagged = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore);
|
auto j_tagged = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore);
|
||||||
|
@ -2655,9 +2663,10 @@ TEST_CASE("Tagged values")
|
||||||
v_tagged.insert(v_tagged.begin(), 0xDA); // tag
|
v_tagged.insert(v_tagged.begin(), 0xDA); // tag
|
||||||
|
|
||||||
// check that parsing fails in all modes
|
// check that parsing fails in all modes
|
||||||
CHECK_THROWS_AS(json::from_cbor(v_tagged), json::parse_error);
|
json _;
|
||||||
CHECK_THROWS_AS(json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::error), json::parse_error);
|
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error);
|
||||||
CHECK_THROWS_AS(json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore), json::parse_error);
|
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::error), json::parse_error);
|
||||||
|
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore), json::parse_error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2678,8 +2687,9 @@ TEST_CASE("Tagged values")
|
||||||
v_tagged.insert(v_tagged.begin(), 0xDB); // tag
|
v_tagged.insert(v_tagged.begin(), 0xDB); // tag
|
||||||
|
|
||||||
// check that parsing fails in error mode
|
// check that parsing fails in error mode
|
||||||
CHECK_THROWS_AS(json::from_cbor(v_tagged), json::parse_error);
|
json _;
|
||||||
CHECK_THROWS_AS(json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::error), json::parse_error);
|
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error);
|
||||||
|
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::error), json::parse_error);
|
||||||
|
|
||||||
// check that parsing succeeds and gets original value in ignore mode
|
// check that parsing succeeds and gets original value in ignore mode
|
||||||
auto j_tagged = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore);
|
auto j_tagged = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore);
|
||||||
|
@ -2700,9 +2710,10 @@ TEST_CASE("Tagged values")
|
||||||
v_tagged.insert(v_tagged.begin(), 0xDB); // tag
|
v_tagged.insert(v_tagged.begin(), 0xDB); // tag
|
||||||
|
|
||||||
// check that parsing fails in all modes
|
// check that parsing fails in all modes
|
||||||
CHECK_THROWS_AS(json::from_cbor(v_tagged), json::parse_error);
|
json _;
|
||||||
CHECK_THROWS_AS(json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::error), json::parse_error);
|
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error);
|
||||||
CHECK_THROWS_AS(json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore), json::parse_error);
|
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::error), json::parse_error);
|
||||||
|
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore), json::parse_error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2717,8 +2728,9 @@ TEST_CASE("Tagged values")
|
||||||
CHECK(vec == std::vector<std::uint8_t> {0xA1, 0x66, 0x62, 0x69, 0x6E, 0x61, 0x72, 0x79, 0xD8, 0x2A, 0x44, 0xCA, 0xFE, 0xBA, 0xBE});
|
CHECK(vec == std::vector<std::uint8_t> {0xA1, 0x66, 0x62, 0x69, 0x6E, 0x61, 0x72, 0x79, 0xD8, 0x2A, 0x44, 0xCA, 0xFE, 0xBA, 0xBE});
|
||||||
|
|
||||||
// parse error when parsing tagged value
|
// parse error when parsing tagged value
|
||||||
CHECK_THROWS_AS(json::from_cbor(vec), json::parse_error);
|
json _;
|
||||||
CHECK_THROWS_WITH(json::from_cbor(vec), "[json.exception.parse_error.112] parse error at byte 9: syntax error while parsing CBOR value: invalid byte: 0xD8");
|
CHECK_THROWS_AS(_ = json::from_cbor(vec), json::parse_error);
|
||||||
|
CHECK_THROWS_WITH(_ = json::from_cbor(vec), "[json.exception.parse_error.112] parse error at byte 9: syntax error while parsing CBOR value: invalid byte: 0xD8");
|
||||||
|
|
||||||
// binary without subtype when tags are ignored
|
// binary without subtype when tags are ignored
|
||||||
json jb = json::from_cbor(vec, true, true, json::cbor_tag_handler_t::ignore);
|
json jb = json::from_cbor(vec, true, true, json::cbor_tag_handler_t::ignore);
|
||||||
|
|
|
@ -1879,7 +1879,8 @@ TEST_CASE("parser class")
|
||||||
|
|
||||||
SECTION("error messages for comments")
|
SECTION("error messages for comments")
|
||||||
{
|
{
|
||||||
CHECK_THROWS_WITH_AS(json::parse("/a", nullptr, true, true), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid comment; expecting '/' or '*' after '/'; last read: '/a'", json::parse_error);
|
json _;
|
||||||
CHECK_THROWS_WITH_AS(json::parse("/*", nullptr, true, true), "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid comment; missing closing '*/'; last read: '/*<U+0000>'", json::parse_error);
|
CHECK_THROWS_WITH_AS(_ = json::parse("/a", nullptr, true, true), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid comment; expecting '/' or '*' after '/'; last read: '/a'", json::parse_error);
|
||||||
|
CHECK_THROWS_WITH_AS(_ = json::parse("/*", nullptr, true, true), "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid comment; missing closing '*/'; last read: '/*<U+0000>'", json::parse_error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -537,7 +537,8 @@ TEST_CASE("deserialization")
|
||||||
SECTION("with empty range")
|
SECTION("with empty range")
|
||||||
{
|
{
|
||||||
std::vector<uint8_t> v;
|
std::vector<uint8_t> v;
|
||||||
CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
json _;
|
||||||
|
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
||||||
CHECK(!json::accept(std::begin(v), std::end(v)));
|
CHECK(!json::accept(std::begin(v), std::end(v)));
|
||||||
|
|
||||||
SaxEventLogger l;
|
SaxEventLogger l;
|
||||||
|
@ -553,7 +554,8 @@ TEST_CASE("deserialization")
|
||||||
SECTION("case 1")
|
SECTION("case 1")
|
||||||
{
|
{
|
||||||
uint8_t v[] = {'\"', 'a', 'a', 'a', 'a', 'a', 'a', '\\', 'u'};
|
uint8_t v[] = {'\"', 'a', 'a', 'a', 'a', 'a', 'a', '\\', 'u'};
|
||||||
CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
json _;
|
||||||
|
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
||||||
CHECK(!json::accept(std::begin(v), std::end(v)));
|
CHECK(!json::accept(std::begin(v), std::end(v)));
|
||||||
|
|
||||||
json j_error;
|
json j_error;
|
||||||
|
@ -569,7 +571,8 @@ TEST_CASE("deserialization")
|
||||||
SECTION("case 2")
|
SECTION("case 2")
|
||||||
{
|
{
|
||||||
uint8_t v[] = {'\"', 'a', 'a', 'a', 'a', 'a', 'a', '\\', 'u', '1'};
|
uint8_t v[] = {'\"', 'a', 'a', 'a', 'a', 'a', 'a', '\\', 'u', '1'};
|
||||||
CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
json _;
|
||||||
|
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
||||||
CHECK(!json::accept(std::begin(v), std::end(v)));
|
CHECK(!json::accept(std::begin(v), std::end(v)));
|
||||||
|
|
||||||
json j_error;
|
json j_error;
|
||||||
|
@ -585,7 +588,8 @@ TEST_CASE("deserialization")
|
||||||
SECTION("case 3")
|
SECTION("case 3")
|
||||||
{
|
{
|
||||||
uint8_t v[] = {'\"', 'a', 'a', 'a', 'a', 'a', 'a', '\\', 'u', '1', '1', '1', '1', '1', '1', '1', '1'};
|
uint8_t v[] = {'\"', 'a', 'a', 'a', 'a', 'a', 'a', '\\', 'u', '1', '1', '1', '1', '1', '1', '1', '1'};
|
||||||
CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
json _;
|
||||||
|
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
||||||
CHECK(!json::accept(std::begin(v), std::end(v)));
|
CHECK(!json::accept(std::begin(v), std::end(v)));
|
||||||
|
|
||||||
json j_error;
|
json j_error;
|
||||||
|
@ -601,7 +605,8 @@ TEST_CASE("deserialization")
|
||||||
SECTION("case 4")
|
SECTION("case 4")
|
||||||
{
|
{
|
||||||
uint8_t v[] = {'\"', 'a', 'a', 'a', 'a', 'a', 'a', 'u', '1', '1', '1', '1', '1', '1', '1', '1', '\\'};
|
uint8_t v[] = {'\"', 'a', 'a', 'a', 'a', 'a', 'a', 'u', '1', '1', '1', '1', '1', '1', '1', '1', '\\'};
|
||||||
CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
json _;
|
||||||
|
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
||||||
CHECK(!json::accept(std::begin(v), std::end(v)));
|
CHECK(!json::accept(std::begin(v), std::end(v)));
|
||||||
|
|
||||||
json j_error;
|
json j_error;
|
||||||
|
@ -617,7 +622,8 @@ TEST_CASE("deserialization")
|
||||||
SECTION("case 5")
|
SECTION("case 5")
|
||||||
{
|
{
|
||||||
uint8_t v[] = {'\"', 0x7F, 0xC1};
|
uint8_t v[] = {'\"', 0x7F, 0xC1};
|
||||||
CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
json _;
|
||||||
|
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
||||||
CHECK(!json::accept(std::begin(v), std::end(v)));
|
CHECK(!json::accept(std::begin(v), std::end(v)));
|
||||||
|
|
||||||
json j_error;
|
json j_error;
|
||||||
|
@ -652,7 +658,8 @@ TEST_CASE("deserialization")
|
||||||
SECTION("case 7")
|
SECTION("case 7")
|
||||||
{
|
{
|
||||||
uint8_t v[] = {'\"', 0x7F, 0xDF, 0xC0};
|
uint8_t v[] = {'\"', 0x7F, 0xDF, 0xC0};
|
||||||
CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
json _;
|
||||||
|
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
||||||
CHECK(!json::accept(std::begin(v), std::end(v)));
|
CHECK(!json::accept(std::begin(v), std::end(v)));
|
||||||
|
|
||||||
json j_error;
|
json j_error;
|
||||||
|
@ -668,7 +675,8 @@ TEST_CASE("deserialization")
|
||||||
SECTION("case 8")
|
SECTION("case 8")
|
||||||
{
|
{
|
||||||
uint8_t v[] = {'\"', 0x7F, 0xE0, 0x9F};
|
uint8_t v[] = {'\"', 0x7F, 0xE0, 0x9F};
|
||||||
CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
json _;
|
||||||
|
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
||||||
CHECK(!json::accept(std::begin(v), std::end(v)));
|
CHECK(!json::accept(std::begin(v), std::end(v)));
|
||||||
|
|
||||||
json j_error;
|
json j_error;
|
||||||
|
@ -684,7 +692,8 @@ TEST_CASE("deserialization")
|
||||||
SECTION("case 9")
|
SECTION("case 9")
|
||||||
{
|
{
|
||||||
uint8_t v[] = {'\"', 0x7F, 0xEF, 0xC0};
|
uint8_t v[] = {'\"', 0x7F, 0xEF, 0xC0};
|
||||||
CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
json _;
|
||||||
|
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
||||||
CHECK(!json::accept(std::begin(v), std::end(v)));
|
CHECK(!json::accept(std::begin(v), std::end(v)));
|
||||||
|
|
||||||
json j_error;
|
json j_error;
|
||||||
|
@ -700,7 +709,8 @@ TEST_CASE("deserialization")
|
||||||
SECTION("case 10")
|
SECTION("case 10")
|
||||||
{
|
{
|
||||||
uint8_t v[] = {'\"', 0x7F, 0xED, 0x7F};
|
uint8_t v[] = {'\"', 0x7F, 0xED, 0x7F};
|
||||||
CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
json _;
|
||||||
|
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
||||||
CHECK(!json::accept(std::begin(v), std::end(v)));
|
CHECK(!json::accept(std::begin(v), std::end(v)));
|
||||||
|
|
||||||
json j_error;
|
json j_error;
|
||||||
|
@ -716,7 +726,8 @@ TEST_CASE("deserialization")
|
||||||
SECTION("case 11")
|
SECTION("case 11")
|
||||||
{
|
{
|
||||||
uint8_t v[] = {'\"', 0x7F, 0xF0, 0x8F};
|
uint8_t v[] = {'\"', 0x7F, 0xF0, 0x8F};
|
||||||
CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
json _;
|
||||||
|
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
||||||
CHECK(!json::accept(std::begin(v), std::end(v)));
|
CHECK(!json::accept(std::begin(v), std::end(v)));
|
||||||
|
|
||||||
json j_error;
|
json j_error;
|
||||||
|
@ -732,7 +743,8 @@ TEST_CASE("deserialization")
|
||||||
SECTION("case 12")
|
SECTION("case 12")
|
||||||
{
|
{
|
||||||
uint8_t v[] = {'\"', 0x7F, 0xF0, 0xC0};
|
uint8_t v[] = {'\"', 0x7F, 0xF0, 0xC0};
|
||||||
CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
json _;
|
||||||
|
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
||||||
CHECK(!json::accept(std::begin(v), std::end(v)));
|
CHECK(!json::accept(std::begin(v), std::end(v)));
|
||||||
|
|
||||||
json j_error;
|
json j_error;
|
||||||
|
@ -748,7 +760,8 @@ TEST_CASE("deserialization")
|
||||||
SECTION("case 13")
|
SECTION("case 13")
|
||||||
{
|
{
|
||||||
uint8_t v[] = {'\"', 0x7F, 0xF3, 0x7F};
|
uint8_t v[] = {'\"', 0x7F, 0xF3, 0x7F};
|
||||||
CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
json _;
|
||||||
|
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
||||||
CHECK(!json::accept(std::begin(v), std::end(v)));
|
CHECK(!json::accept(std::begin(v), std::end(v)));
|
||||||
|
|
||||||
json j_error;
|
json j_error;
|
||||||
|
@ -764,7 +777,8 @@ TEST_CASE("deserialization")
|
||||||
SECTION("case 14")
|
SECTION("case 14")
|
||||||
{
|
{
|
||||||
uint8_t v[] = {'\"', 0x7F, 0xF3, 0xC0};
|
uint8_t v[] = {'\"', 0x7F, 0xF3, 0xC0};
|
||||||
CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
json _;
|
||||||
|
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
||||||
CHECK(!json::accept(std::begin(v), std::end(v)));
|
CHECK(!json::accept(std::begin(v), std::end(v)));
|
||||||
|
|
||||||
json j_error;
|
json j_error;
|
||||||
|
@ -780,7 +794,8 @@ TEST_CASE("deserialization")
|
||||||
SECTION("case 15")
|
SECTION("case 15")
|
||||||
{
|
{
|
||||||
uint8_t v[] = {'\"', 0x7F, 0xF4, 0x7F};
|
uint8_t v[] = {'\"', 0x7F, 0xF4, 0x7F};
|
||||||
CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
json _;
|
||||||
|
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
||||||
CHECK(!json::accept(std::begin(v), std::end(v)));
|
CHECK(!json::accept(std::begin(v), std::end(v)));
|
||||||
|
|
||||||
json j_error;
|
json j_error;
|
||||||
|
@ -796,7 +811,8 @@ TEST_CASE("deserialization")
|
||||||
SECTION("case 16")
|
SECTION("case 16")
|
||||||
{
|
{
|
||||||
uint8_t v[] = {'{', '\"', '\"', ':', '1', '1'};
|
uint8_t v[] = {'{', '\"', '\"', ':', '1', '1'};
|
||||||
CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
json _;
|
||||||
|
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
|
||||||
CHECK(!json::accept(std::begin(v), std::end(v)));
|
CHECK(!json::accept(std::begin(v), std::end(v)));
|
||||||
|
|
||||||
json j_error;
|
json j_error;
|
||||||
|
|
|
@ -805,12 +805,13 @@ TEST_CASE("UBJSON")
|
||||||
std::vector<uint8_t> vec1 = {'H', 'i', '1'};
|
std::vector<uint8_t> vec1 = {'H', 'i', '1'};
|
||||||
CHECK(json::from_ubjson(vec1, true, false).is_discarded());
|
CHECK(json::from_ubjson(vec1, true, false).is_discarded());
|
||||||
|
|
||||||
|
json _;
|
||||||
std::vector<uint8_t> vec2 = {'H', 'i', 2, '1', 'A', '3'};
|
std::vector<uint8_t> vec2 = {'H', 'i', 2, '1', 'A', '3'};
|
||||||
CHECK_THROWS_WITH_AS(json::from_ubjson(vec2), "[json.exception.parse_error.115] parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1A", json::parse_error);
|
CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vec2), "[json.exception.parse_error.115] parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1A", json::parse_error);
|
||||||
std::vector<uint8_t> vec3 = {'H', 'i', 2, '1', '.'};
|
std::vector<uint8_t> vec3 = {'H', 'i', 2, '1', '.'};
|
||||||
CHECK_THROWS_WITH_AS(json::from_ubjson(vec3), "[json.exception.parse_error.115] parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1.", json::parse_error);
|
CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vec3), "[json.exception.parse_error.115] parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1.", json::parse_error);
|
||||||
std::vector<uint8_t> vec4 = {'H', 2, '1', '0'};
|
std::vector<uint8_t> vec4 = {'H', 2, '1', '0'};
|
||||||
CHECK_THROWS_WITH_AS(json::from_ubjson(vec4), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing UBJSON size: expected length type specification (U, i, I, l, L) after '#'; last byte: 0x02", json::parse_error);
|
CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vec4), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing UBJSON size: expected length type specification (U, i, I, l, L) after '#'; last byte: 0x02", json::parse_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("serialization")
|
SECTION("serialization")
|
||||||
|
|
|
@ -1201,7 +1201,8 @@ TEST_CASE("Unicode" * doctest::skip())
|
||||||
SECTION("with an iterator")
|
SECTION("with an iterator")
|
||||||
{
|
{
|
||||||
std::string i = "\xef\xbb\xbf{\n \"foo\": true\n}";
|
std::string i = "\xef\xbb\xbf{\n \"foo\": true\n}";
|
||||||
CHECK_NOTHROW(json::parse(i.begin(), i.end()));
|
json _;
|
||||||
|
CHECK_NOTHROW(_ = json::parse(i.begin(), i.end()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue