mirror of
https://github.com/nlohmann/json.git
synced 2026-02-22 03:16:25 +00:00
🚨 fix warnings
This commit is contained in:
@@ -1591,14 +1591,16 @@ TEST_CASE("CBOR")
|
||||
{
|
||||
// array with three empty byte strings
|
||||
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")
|
||||
{
|
||||
// object mapping "foo" to empty byte string
|
||||
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")
|
||||
@@ -2551,8 +2553,9 @@ TEST_CASE("Tagged values")
|
||||
v_tagged.insert(v_tagged.begin(), b);
|
||||
|
||||
// check that parsing fails in error mode
|
||||
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);
|
||||
json _;
|
||||
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
|
||||
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
|
||||
|
||||
// check that parsing fails in error mode
|
||||
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);
|
||||
json _;
|
||||
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
|
||||
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
|
||||
|
||||
// check that parsing fails in all modes
|
||||
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_THROWS_AS(json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore), json::parse_error);
|
||||
json _;
|
||||
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_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
|
||||
|
||||
// check that parsing fails in error mode
|
||||
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);
|
||||
json _;
|
||||
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
|
||||
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
|
||||
|
||||
// check that parsing fails in all modes
|
||||
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_THROWS_AS(json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore), json::parse_error);
|
||||
json _;
|
||||
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_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
|
||||
|
||||
// check that parsing fails in error mode
|
||||
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);
|
||||
json _;
|
||||
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
|
||||
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
|
||||
|
||||
// check that parsing fails in all modes
|
||||
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_THROWS_AS(json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore), json::parse_error);
|
||||
json _;
|
||||
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_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
|
||||
|
||||
// check that parsing fails in error mode
|
||||
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);
|
||||
json _;
|
||||
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
|
||||
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
|
||||
|
||||
// check that parsing fails in all modes
|
||||
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_THROWS_AS(json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore), json::parse_error);
|
||||
json _;
|
||||
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_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});
|
||||
|
||||
// parse error when parsing tagged value
|
||||
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");
|
||||
json _;
|
||||
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
|
||||
json jb = json::from_cbor(vec, true, true, json::cbor_tag_handler_t::ignore);
|
||||
|
||||
Reference in New Issue
Block a user