🎨 replace alternative operators (and, not, or)

This commit is contained in:
Niels Lohmann 2020-06-03 21:22:07 +02:00
parent 0498202a03
commit 65c4b07451
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
23 changed files with 352 additions and 352 deletions

View file

@ -55,7 +55,7 @@ TEST_CASE("algorithms")
{ {
CHECK(std::any_of(j_array.begin(), j_array.end(), [](const json & value) CHECK(std::any_of(j_array.begin(), j_array.end(), [](const json & value)
{ {
return value.is_string() and value.get<std::string>() == "foo"; return value.is_string() && value.get<std::string>() == "foo";
})); }));
CHECK(std::any_of(j_object.begin(), j_object.end(), [](const json & value) CHECK(std::any_of(j_object.begin(), j_object.end(), [](const json & value)
{ {
@ -139,14 +139,14 @@ TEST_CASE("algorithms")
{ {
CHECK(std::equal(j_array.begin(), j_array.end(), j_array.begin())); CHECK(std::equal(j_array.begin(), j_array.end(), j_array.begin()));
CHECK(std::equal(j_object.begin(), j_object.end(), j_object.begin())); CHECK(std::equal(j_object.begin(), j_object.end(), j_object.begin()));
CHECK(not std::equal(j_array.begin(), j_array.end(), j_object.begin())); CHECK(!std::equal(j_array.begin(), j_array.end(), j_object.begin()));
} }
SECTION("using user-defined comparison") SECTION("using user-defined comparison")
{ {
// compare objects only by size of its elements // compare objects only by size of its elements
json j_array2 = {13, 29, 3, {"Hello", "World"}, true, false, {{"one", 1}, {"two", 2}, {"three", 3}}, "foo", "baz"}; json j_array2 = {13, 29, 3, {"Hello", "World"}, true, false, {{"one", 1}, {"two", 2}, {"three", 3}}, "foo", "baz"};
CHECK(not std::equal(j_array.begin(), j_array.end(), j_array2.begin())); CHECK(!std::equal(j_array.begin(), j_array.end(), j_array2.begin()));
CHECK(std::equal(j_array.begin(), j_array.end(), j_array2.begin(), CHECK(std::equal(j_array.begin(), j_array.end(), j_array2.begin(),
[](const json & a, const json & b) [](const json & a, const json & b)
{ {
@ -213,7 +213,7 @@ TEST_CASE("algorithms")
return v.is_string(); return v.is_string();
}); });
CHECK(std::distance(j_array.begin(), it) == 2); CHECK(std::distance(j_array.begin(), it) == 2);
CHECK(not it[2].is_string()); CHECK(!it[2].is_string());
} }
} }

View file

@ -766,7 +766,7 @@ TEST_CASE("Incomplete BSON Input")
CHECK(json::from_bson(incomplete_bson, true, false).is_discarded()); CHECK(json::from_bson(incomplete_bson, true, false).is_discarded());
SaxCountdown scp(0); SaxCountdown scp(0);
CHECK(not json::sax_parse(incomplete_bson, &scp, json::input_format_t::bson)); CHECK(!json::sax_parse(incomplete_bson, &scp, json::input_format_t::bson));
} }
SECTION("Incomplete BSON Input 2") SECTION("Incomplete BSON Input 2")
@ -784,7 +784,7 @@ TEST_CASE("Incomplete BSON Input")
CHECK(json::from_bson(incomplete_bson, true, false).is_discarded()); CHECK(json::from_bson(incomplete_bson, true, false).is_discarded());
SaxCountdown scp(0); SaxCountdown scp(0);
CHECK(not json::sax_parse(incomplete_bson, &scp, json::input_format_t::bson)); CHECK(!json::sax_parse(incomplete_bson, &scp, json::input_format_t::bson));
} }
SECTION("Incomplete BSON Input 3") SECTION("Incomplete BSON Input 3")
@ -808,7 +808,7 @@ TEST_CASE("Incomplete BSON Input")
CHECK(json::from_bson(incomplete_bson, true, false).is_discarded()); CHECK(json::from_bson(incomplete_bson, true, false).is_discarded());
SaxCountdown scp(1); SaxCountdown scp(1);
CHECK(not json::sax_parse(incomplete_bson, &scp, json::input_format_t::bson)); CHECK(!json::sax_parse(incomplete_bson, &scp, json::input_format_t::bson));
} }
SECTION("Incomplete BSON Input 4") SECTION("Incomplete BSON Input 4")
@ -825,7 +825,7 @@ TEST_CASE("Incomplete BSON Input")
CHECK(json::from_bson(incomplete_bson, true, false).is_discarded()); CHECK(json::from_bson(incomplete_bson, true, false).is_discarded());
SaxCountdown scp(0); SaxCountdown scp(0);
CHECK(not json::sax_parse(incomplete_bson, &scp, json::input_format_t::bson)); CHECK(!json::sax_parse(incomplete_bson, &scp, json::input_format_t::bson));
} }
SECTION("Improve coverage") SECTION("Improve coverage")
@ -835,7 +835,7 @@ TEST_CASE("Incomplete BSON Input")
json j = {{"key", "value"}}; json j = {{"key", "value"}};
auto bson_vec = json::to_bson(j); auto bson_vec = json::to_bson(j);
SaxCountdown scp(2); SaxCountdown scp(2);
CHECK(not json::sax_parse(bson_vec, &scp, json::input_format_t::bson)); CHECK(!json::sax_parse(bson_vec, &scp, json::input_format_t::bson));
} }
SECTION("array") SECTION("array")
@ -846,7 +846,7 @@ TEST_CASE("Incomplete BSON Input")
}; };
auto bson_vec = json::to_bson(j); auto bson_vec = json::to_bson(j);
SaxCountdown scp(2); SaxCountdown scp(2);
CHECK(not json::sax_parse(bson_vec, &scp, json::input_format_t::bson)); CHECK(!json::sax_parse(bson_vec, &scp, json::input_format_t::bson));
} }
} }
} }
@ -887,7 +887,7 @@ TEST_CASE("Unsupported BSON input")
CHECK(json::from_bson(bson, true, false).is_discarded()); CHECK(json::from_bson(bson, true, false).is_discarded());
SaxCountdown scp(0); SaxCountdown scp(0);
CHECK(not json::sax_parse(bson, &scp, json::input_format_t::bson)); CHECK(!json::sax_parse(bson, &scp, json::input_format_t::bson));
} }
TEST_CASE("BSON numerical data") TEST_CASE("BSON numerical data")

View file

@ -1077,7 +1077,7 @@ TEST_CASE("CBOR")
{ {
json j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x7c, 0x00})); json j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x7c, 0x00}));
json::number_float_t d = j; json::number_float_t d = j;
CHECK(not std::isfinite(d)); CHECK(!std::isfinite(d));
CHECK(j.dump() == "null"); CHECK(j.dump() == "null");
} }
@ -1869,7 +1869,7 @@ TEST_CASE("CBOR")
{ {
const auto result = json::from_cbor(vec, false); const auto result = json::from_cbor(vec, false);
CHECK(result == json()); CHECK(result == json());
CHECK(not json::from_cbor(vec, false, false).is_discarded()); CHECK(!json::from_cbor(vec, false, false).is_discarded());
} }
SECTION("strict mode") SECTION("strict mode")
@ -1889,21 +1889,21 @@ TEST_CASE("CBOR")
{ {
std::vector<uint8_t> v = {0x83, 0x01, 0x02, 0x03}; std::vector<uint8_t> v = {0x83, 0x01, 0x02, 0x03};
SaxCountdown scp(0); SaxCountdown scp(0);
CHECK(not json::sax_parse(v, &scp, json::input_format_t::cbor)); CHECK(!json::sax_parse(v, &scp, json::input_format_t::cbor));
} }
SECTION("start_object(len)") SECTION("start_object(len)")
{ {
std::vector<uint8_t> v = {0xA1, 0x63, 0x66, 0x6F, 0x6F, 0xF4}; std::vector<uint8_t> v = {0xA1, 0x63, 0x66, 0x6F, 0x6F, 0xF4};
SaxCountdown scp(0); SaxCountdown scp(0);
CHECK(not json::sax_parse(v, &scp, json::input_format_t::cbor)); CHECK(!json::sax_parse(v, &scp, json::input_format_t::cbor));
} }
SECTION("key()") SECTION("key()")
{ {
std::vector<uint8_t> v = {0xA1, 0x63, 0x66, 0x6F, 0x6F, 0xF4}; std::vector<uint8_t> v = {0xA1, 0x63, 0x66, 0x6F, 0x6F, 0xF4};
SaxCountdown scp(1); SaxCountdown scp(1);
CHECK(not json::sax_parse(v, &scp, json::input_format_t::cbor)); CHECK(!json::sax_parse(v, &scp, json::input_format_t::cbor));
} }
} }
} }
@ -1954,7 +1954,7 @@ TEST_CASE("single CBOR roundtrip")
} }
} }
#if not defined(JSON_NOEXCEPTION) #if !defined(JSON_NOEXCEPTION)
TEST_CASE("CBOR regressions") TEST_CASE("CBOR regressions")
{ {
SECTION("fuzz test results") SECTION("fuzz test results")
@ -2274,7 +2274,7 @@ TEST_CASE("CBOR roundtrips" * doctest::skip())
} }
} }
#if not defined(JSON_NOEXCEPTION) #if !defined(JSON_NOEXCEPTION)
TEST_CASE("all CBOR first bytes") TEST_CASE("all CBOR first bytes")
{ {
// these bytes will fail immediately with exception parse_error.112 // these bytes will fail immediately with exception parse_error.112

View file

@ -224,7 +224,7 @@ TEST_CASE("const_iterator class")
json::const_iterator it = j.cbegin(); json::const_iterator it = j.cbegin();
CHECK((it.m_it.primitive_iterator.m_it == 1)); CHECK((it.m_it.primitive_iterator.m_it == 1));
it++; it++;
CHECK((it.m_it.primitive_iterator.m_it != 0 and it.m_it.primitive_iterator.m_it != 1)); CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterator.m_it != 1));
} }
SECTION("number") SECTION("number")
@ -235,7 +235,7 @@ TEST_CASE("const_iterator class")
it++; it++;
CHECK((it.m_it.primitive_iterator.m_it == 1)); CHECK((it.m_it.primitive_iterator.m_it == 1));
it++; it++;
CHECK((it.m_it.primitive_iterator.m_it != 0 and it.m_it.primitive_iterator.m_it != 1)); CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterator.m_it != 1));
} }
SECTION("object") SECTION("object")
@ -275,7 +275,7 @@ TEST_CASE("const_iterator class")
json::const_iterator it = j.cbegin(); json::const_iterator it = j.cbegin();
CHECK((it.m_it.primitive_iterator.m_it == 1)); CHECK((it.m_it.primitive_iterator.m_it == 1));
++it; ++it;
CHECK((it.m_it.primitive_iterator.m_it != 0 and it.m_it.primitive_iterator.m_it != 1)); CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterator.m_it != 1));
} }
SECTION("number") SECTION("number")
@ -286,7 +286,7 @@ TEST_CASE("const_iterator class")
++it; ++it;
CHECK((it.m_it.primitive_iterator.m_it == 1)); CHECK((it.m_it.primitive_iterator.m_it == 1));
++it; ++it;
CHECK((it.m_it.primitive_iterator.m_it != 0 and it.m_it.primitive_iterator.m_it != 1)); CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterator.m_it != 1));
} }
SECTION("object") SECTION("object")
@ -335,7 +335,7 @@ TEST_CASE("const_iterator class")
it--; it--;
CHECK((it.m_it.primitive_iterator.m_it == 0)); CHECK((it.m_it.primitive_iterator.m_it == 0));
it--; it--;
CHECK((it.m_it.primitive_iterator.m_it != 0 and it.m_it.primitive_iterator.m_it != 1)); CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterator.m_it != 1));
} }
SECTION("object") SECTION("object")
@ -384,7 +384,7 @@ TEST_CASE("const_iterator class")
--it; --it;
CHECK((it.m_it.primitive_iterator.m_it == 0)); CHECK((it.m_it.primitive_iterator.m_it == 0));
--it; --it;
CHECK((it.m_it.primitive_iterator.m_it != 0 and it.m_it.primitive_iterator.m_it != 1)); CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterator.m_it != 1));
} }
SECTION("object") SECTION("object")

View file

@ -208,7 +208,7 @@ TEST_CASE("iterator class")
json::iterator it = j.begin(); json::iterator it = j.begin();
CHECK((it.m_it.primitive_iterator.m_it == 1)); CHECK((it.m_it.primitive_iterator.m_it == 1));
it++; it++;
CHECK((it.m_it.primitive_iterator.m_it != 0 and it.m_it.primitive_iterator.m_it != 1)); CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterator.m_it != 1));
} }
SECTION("number") SECTION("number")
@ -219,7 +219,7 @@ TEST_CASE("iterator class")
it++; it++;
CHECK((it.m_it.primitive_iterator.m_it == 1)); CHECK((it.m_it.primitive_iterator.m_it == 1));
it++; it++;
CHECK((it.m_it.primitive_iterator.m_it != 0 and it.m_it.primitive_iterator.m_it != 1)); CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterator.m_it != 1));
} }
SECTION("object") SECTION("object")
@ -259,7 +259,7 @@ TEST_CASE("iterator class")
json::iterator it = j.begin(); json::iterator it = j.begin();
CHECK((it.m_it.primitive_iterator.m_it == 1)); CHECK((it.m_it.primitive_iterator.m_it == 1));
++it; ++it;
CHECK((it.m_it.primitive_iterator.m_it != 0 and it.m_it.primitive_iterator.m_it != 1)); CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterator.m_it != 1));
} }
SECTION("number") SECTION("number")
@ -270,7 +270,7 @@ TEST_CASE("iterator class")
++it; ++it;
CHECK((it.m_it.primitive_iterator.m_it == 1)); CHECK((it.m_it.primitive_iterator.m_it == 1));
++it; ++it;
CHECK((it.m_it.primitive_iterator.m_it != 0 and it.m_it.primitive_iterator.m_it != 1)); CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterator.m_it != 1));
} }
SECTION("object") SECTION("object")
@ -319,7 +319,7 @@ TEST_CASE("iterator class")
it--; it--;
CHECK((it.m_it.primitive_iterator.m_it == 0)); CHECK((it.m_it.primitive_iterator.m_it == 0));
it--; it--;
CHECK((it.m_it.primitive_iterator.m_it != 0 and it.m_it.primitive_iterator.m_it != 1)); CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterator.m_it != 1));
} }
SECTION("object") SECTION("object")
@ -368,7 +368,7 @@ TEST_CASE("iterator class")
--it; --it;
CHECK((it.m_it.primitive_iterator.m_it == 0)); CHECK((it.m_it.primitive_iterator.m_it == 0));
--it; --it;
CHECK((it.m_it.primitive_iterator.m_it != 0 and it.m_it.primitive_iterator.m_it != 1)); CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterator.m_it != 1));
} }
SECTION("object") SECTION("object")

View file

@ -251,7 +251,7 @@ bool accept_helper(const std::string& s)
// 1. parse s without exceptions // 1. parse s without exceptions
json j; json j;
CHECK_NOTHROW(json::parser(nlohmann::detail::input_adapter(s), nullptr, false).parse(true, j)); CHECK_NOTHROW(json::parser(nlohmann::detail::input_adapter(s), nullptr, false).parse(true, j));
const bool ok_noexcept = not j.is_discarded(); const bool ok_noexcept = !j.is_discarded();
// 2. accept s // 2. accept s
const bool ok_accept = json::parser(nlohmann::detail::input_adapter(s)).accept(true); const bool ok_accept = json::parser(nlohmann::detail::input_adapter(s)).accept(true);
@ -262,7 +262,7 @@ bool accept_helper(const std::string& s)
// 4. parse with SAX (compare with relaxed accept result) // 4. parse with SAX (compare with relaxed accept result)
SaxEventLogger el; SaxEventLogger el;
CHECK_NOTHROW(json::sax_parse(s, &el, json::input_format_t::json, false)); CHECK_NOTHROW(json::sax_parse(s, &el, json::input_format_t::json, false));
CHECK(json::parser(nlohmann::detail::input_adapter(s)).accept(false) == not el.errored); CHECK(json::parser(nlohmann::detail::input_adapter(s)).accept(false) == !el.errored);
// 5. parse with simple callback // 5. parse with simple callback
json::parser_callback_t cb = [](int, json::parse_event_t, json&) json::parser_callback_t cb = [](int, json::parse_event_t, json&)
@ -270,7 +270,7 @@ bool accept_helper(const std::string& s)
return true; return true;
}; };
json j_cb = json::parse(s, cb, false); json j_cb = json::parse(s, cb, false);
const bool ok_noexcept_cb = not j_cb.is_discarded(); const bool ok_noexcept_cb = !j_cb.is_discarded();
// 6. check if this approach came to the same result // 6. check if this approach came to the same result
CHECK(ok_noexcept == ok_noexcept_cb); CHECK(ok_noexcept == ok_noexcept_cb);
@ -898,7 +898,7 @@ TEST_CASE("parser class")
SECTION("overflow") SECTION("overflow")
{ {
// overflows during parsing // overflows during parsing
CHECK(not accept_helper("1.18973e+4932")); CHECK(!accept_helper("1.18973e+4932"));
} }
SECTION("invalid numbers") SECTION("invalid numbers")
@ -1573,7 +1573,7 @@ TEST_CASE("parser class")
{ {
json j_filtered1 = json::parse(structured_array, [](int, json::parse_event_t e, const json & parsed) json j_filtered1 = json::parse(structured_array, [](int, json::parse_event_t e, const json & parsed)
{ {
if (e == json::parse_event_t::object_end and parsed.contains("foo")) if (e == json::parse_event_t::object_end && parsed.contains("foo"))
{ {
return false; return false;
} }
@ -1612,7 +1612,7 @@ TEST_CASE("parser class")
json j_object = json::parse(s_object, [](int, json::parse_event_t e, const json&) json j_object = json::parse(s_object, [](int, json::parse_event_t e, const json&)
{ {
static bool first = true; static bool first = true;
if (e == json::parse_event_t::object_end and first) if (e == json::parse_event_t::object_end && first)
{ {
first = false; first = false;
return false; return false;
@ -1631,7 +1631,7 @@ TEST_CASE("parser class")
json j_array = json::parse(s_array, [](int, json::parse_event_t e, const json&) json j_array = json::parse(s_array, [](int, json::parse_event_t e, const json&)
{ {
static bool first = true; static bool first = true;
if (e == json::parse_event_t::array_end and first) if (e == json::parse_event_t::array_end && first)
{ {
first = false; first = false;
return false; return false;

View file

@ -165,7 +165,7 @@ TEST_CASE("lexicographical comparison operators")
CAPTURE(i) CAPTURE(i)
CAPTURE(j) CAPTURE(j)
// check definition // check definition
CHECK( (j_values[i] != j_values[j]) == not(j_values[i] == j_values[j]) ); CHECK( (j_values[i] != j_values[j]) == !(j_values[i] == j_values[j]) );
} }
} }
@ -173,8 +173,8 @@ TEST_CASE("lexicographical comparison operators")
json j_null; json j_null;
CHECK( (j_null != nullptr) == false); CHECK( (j_null != nullptr) == false);
CHECK( (nullptr != j_null) == false); CHECK( (nullptr != j_null) == false);
CHECK( (j_null != nullptr) == not(j_null == nullptr)); CHECK( (j_null != nullptr) == !(j_null == nullptr));
CHECK( (nullptr != j_null) == not(nullptr == j_null)); CHECK( (nullptr != j_null) == !(nullptr == j_null));
} }
SECTION("comparison: less") SECTION("comparison: less")
@ -234,7 +234,7 @@ TEST_CASE("lexicographical comparison operators")
CAPTURE(i) CAPTURE(i)
CAPTURE(j) CAPTURE(j)
// check definition // check definition
CHECK( (j_values[i] <= j_values[j]) == not(j_values[j] < j_values[i]) ); CHECK( (j_values[i] <= j_values[j]) == !(j_values[j] < j_values[i]) );
} }
} }
} }
@ -262,7 +262,7 @@ TEST_CASE("lexicographical comparison operators")
CAPTURE(i) CAPTURE(i)
CAPTURE(j) CAPTURE(j)
// check definition // check definition
CHECK( (j_values[i] >= j_values[j]) == not(j_values[i] < j_values[j]) ); CHECK( (j_values[i] >= j_values[j]) == !(j_values[i] < j_values[j]) );
} }
} }
} }

View file

@ -847,7 +847,7 @@ TEST_CASE("constructors")
// check round trip of NaN // check round trip of NaN
json::number_float_t d = j; json::number_float_t d = j;
CHECK((std::isnan(d) and std::isnan(n)) == true); CHECK((std::isnan(d) && std::isnan(n)) == true);
// check that NaN is serialized to null // check that NaN is serialized to null
CHECK(j.dump() == "null"); CHECK(j.dump() == "null");

View file

@ -272,7 +272,7 @@ TEST_CASE("value conversion")
json(json::value_t::null).get<std::vector<json>>(), json(json::value_t::null).get<std::vector<json>>(),
"[json.exception.type_error.302] type must be array, but is null"); "[json.exception.type_error.302] type must be array, but is null");
#if not defined(JSON_NOEXCEPTION) #if !defined(JSON_NOEXCEPTION)
SECTION("reserve is called on containers that supports it") SECTION("reserve is called on containers that supports it")
{ {
// make sure all values are properly copied // make sure all values are properly copied

View file

@ -289,14 +289,14 @@ TEST_CASE("deserialization")
CHECK_THROWS_AS(_ = json::parse(ss1), json::parse_error&); CHECK_THROWS_AS(_ = json::parse(ss1), json::parse_error&);
CHECK_THROWS_WITH(_ = json::parse(ss2), CHECK_THROWS_WITH(_ = json::parse(ss2),
"[json.exception.parse_error.101] parse error at line 1, column 29: syntax error while parsing array - unexpected end of input; expected ']'"); "[json.exception.parse_error.101] parse error at line 1, column 29: syntax error while parsing array - unexpected end of input; expected ']'");
CHECK(not json::accept(ss3)); CHECK(!json::accept(ss3));
json j_error; json j_error;
CHECK_NOTHROW(j_error = json::parse(ss4, nullptr, false)); CHECK_NOTHROW(j_error = json::parse(ss4, nullptr, false));
CHECK(j_error.is_discarded()); CHECK(j_error.is_discarded());
SaxEventLogger l; SaxEventLogger l;
CHECK(not json::sax_parse(ss5, &l)); CHECK(!json::sax_parse(ss5, &l));
CHECK(l.events.size() == 11); CHECK(l.events.size() == 11);
CHECK(l.events == std::vector<std::string>( CHECK(l.events == std::vector<std::string>(
{ {
@ -314,14 +314,14 @@ TEST_CASE("deserialization")
CHECK_THROWS_AS(_ = json::parse(s), json::parse_error&); CHECK_THROWS_AS(_ = json::parse(s), json::parse_error&);
CHECK_THROWS_WITH(_ = json::parse(s), CHECK_THROWS_WITH(_ = json::parse(s),
"[json.exception.parse_error.101] parse error at line 1, column 29: syntax error while parsing array - unexpected end of input; expected ']'"); "[json.exception.parse_error.101] parse error at line 1, column 29: syntax error while parsing array - unexpected end of input; expected ']'");
CHECK(not json::accept(s)); CHECK(!json::accept(s));
json j_error; json j_error;
CHECK_NOTHROW(j_error = json::parse(s, nullptr, false)); CHECK_NOTHROW(j_error = json::parse(s, nullptr, false));
CHECK(j_error.is_discarded()); CHECK(j_error.is_discarded());
SaxEventLogger l; SaxEventLogger l;
CHECK(not json::sax_parse(s, &l)); CHECK(!json::sax_parse(s, &l));
CHECK(l.events.size() == 11); CHECK(l.events.size() == 11);
CHECK(l.events == std::vector<std::string>( CHECK(l.events == std::vector<std::string>(
{ {
@ -450,10 +450,10 @@ TEST_CASE("deserialization")
std::vector<uint8_t> v; std::vector<uint8_t> v;
json _; json _;
CHECK_THROWS_AS(_ = json::parse(v), json::parse_error&); CHECK_THROWS_AS(_ = json::parse(v), json::parse_error&);
CHECK(not json::accept(v)); CHECK(!json::accept(v));
SaxEventLogger l; SaxEventLogger l;
CHECK(not json::sax_parse(v, &l)); CHECK(!json::sax_parse(v, &l));
CHECK(l.events.size() == 1); CHECK(l.events.size() == 1);
CHECK(l.events == std::vector<std::string>({"parse_error(1)"})); CHECK(l.events == std::vector<std::string>({"parse_error(1)"}));
} }
@ -538,10 +538,10 @@ TEST_CASE("deserialization")
{ {
std::vector<uint8_t> v; std::vector<uint8_t> v;
CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&); CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(not json::accept(std::begin(v), std::end(v))); CHECK(!json::accept(std::begin(v), std::end(v)));
SaxEventLogger l; SaxEventLogger l;
CHECK(not json::sax_parse(std::begin(v), std::end(v), &l)); CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1); CHECK(l.events.size() == 1);
CHECK(l.events == std::vector<std::string>({"parse_error(1)"})); CHECK(l.events == std::vector<std::string>({"parse_error(1)"}));
} }
@ -554,14 +554,14 @@ TEST_CASE("deserialization")
{ {
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&); CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(not json::accept(std::begin(v), std::end(v))); CHECK(!json::accept(std::begin(v), std::end(v)));
json j_error; json j_error;
CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false)); CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false));
CHECK(j_error.is_discarded()); CHECK(j_error.is_discarded());
SaxEventLogger l; SaxEventLogger l;
CHECK(not json::sax_parse(std::begin(v), std::end(v), &l)); CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1); CHECK(l.events.size() == 1);
CHECK(l.events == std::vector<std::string>({"parse_error(10)"})); CHECK(l.events == std::vector<std::string>({"parse_error(10)"}));
} }
@ -570,14 +570,14 @@ TEST_CASE("deserialization")
{ {
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&); CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(not json::accept(std::begin(v), std::end(v))); CHECK(!json::accept(std::begin(v), std::end(v)));
json j_error; json j_error;
CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false)); CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false));
CHECK(j_error.is_discarded()); CHECK(j_error.is_discarded());
SaxEventLogger l; SaxEventLogger l;
CHECK(not json::sax_parse(std::begin(v), std::end(v), &l)); CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1); CHECK(l.events.size() == 1);
CHECK(l.events == std::vector<std::string>({"parse_error(11)"})); CHECK(l.events == std::vector<std::string>({"parse_error(11)"}));
} }
@ -586,14 +586,14 @@ TEST_CASE("deserialization")
{ {
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&); CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(not json::accept(std::begin(v), std::end(v))); CHECK(!json::accept(std::begin(v), std::end(v)));
json j_error; json j_error;
CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false)); CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false));
CHECK(j_error.is_discarded()); CHECK(j_error.is_discarded());
SaxEventLogger l; SaxEventLogger l;
CHECK(not json::sax_parse(std::begin(v), std::end(v), &l)); CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1); CHECK(l.events.size() == 1);
CHECK(l.events == std::vector<std::string>({"parse_error(18)"})); CHECK(l.events == std::vector<std::string>({"parse_error(18)"}));
} }
@ -602,14 +602,14 @@ TEST_CASE("deserialization")
{ {
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&); CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(not json::accept(std::begin(v), std::end(v))); CHECK(!json::accept(std::begin(v), std::end(v)));
json j_error; json j_error;
CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false)); CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false));
CHECK(j_error.is_discarded()); CHECK(j_error.is_discarded());
SaxEventLogger l; SaxEventLogger l;
CHECK(not json::sax_parse(std::begin(v), std::end(v), &l)); CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1); CHECK(l.events.size() == 1);
CHECK(l.events == std::vector<std::string>({"parse_error(18)"})); CHECK(l.events == std::vector<std::string>({"parse_error(18)"}));
} }
@ -618,14 +618,14 @@ TEST_CASE("deserialization")
{ {
uint8_t v[] = {'\"', 0x7F, 0xC1}; uint8_t v[] = {'\"', 0x7F, 0xC1};
CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&); CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(not json::accept(std::begin(v), std::end(v))); CHECK(!json::accept(std::begin(v), std::end(v)));
json j_error; json j_error;
CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false)); CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false));
CHECK(j_error.is_discarded()); CHECK(j_error.is_discarded());
SaxEventLogger l; SaxEventLogger l;
CHECK(not json::sax_parse(std::begin(v), std::end(v), &l)); CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1); CHECK(l.events.size() == 1);
CHECK(l.events == std::vector<std::string>({"parse_error(3)"})); CHECK(l.events == std::vector<std::string>({"parse_error(3)"}));
} }
@ -637,14 +637,14 @@ TEST_CASE("deserialization")
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&); CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK_THROWS_WITH(_ = json::parse(std::begin(v), std::end(v)), CHECK_THROWS_WITH(_ = json::parse(std::begin(v), std::end(v)),
"[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid string: ill-formed UTF-8 byte; last read: '\"\x7f\xdf\x7f'"); "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid string: ill-formed UTF-8 byte; last read: '\"\x7f\xdf\x7f'");
CHECK(not json::accept(std::begin(v), std::end(v))); CHECK(!json::accept(std::begin(v), std::end(v)));
json j_error; json j_error;
CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false)); CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false));
CHECK(j_error.is_discarded()); CHECK(j_error.is_discarded());
SaxEventLogger l; SaxEventLogger l;
CHECK(not json::sax_parse(std::begin(v), std::end(v), &l)); CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1); CHECK(l.events.size() == 1);
CHECK(l.events == std::vector<std::string>({"parse_error(4)"})); CHECK(l.events == std::vector<std::string>({"parse_error(4)"}));
} }
@ -653,14 +653,14 @@ TEST_CASE("deserialization")
{ {
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&); CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(not json::accept(std::begin(v), std::end(v))); CHECK(!json::accept(std::begin(v), std::end(v)));
json j_error; json j_error;
CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false)); CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false));
CHECK(j_error.is_discarded()); CHECK(j_error.is_discarded());
SaxEventLogger l; SaxEventLogger l;
CHECK(not json::sax_parse(std::begin(v), std::end(v), &l)); CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1); CHECK(l.events.size() == 1);
CHECK(l.events == std::vector<std::string>({"parse_error(4)"})); CHECK(l.events == std::vector<std::string>({"parse_error(4)"}));
} }
@ -669,14 +669,14 @@ TEST_CASE("deserialization")
{ {
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&); CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(not json::accept(std::begin(v), std::end(v))); CHECK(!json::accept(std::begin(v), std::end(v)));
json j_error; json j_error;
CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false)); CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false));
CHECK(j_error.is_discarded()); CHECK(j_error.is_discarded());
SaxEventLogger l; SaxEventLogger l;
CHECK(not json::sax_parse(std::begin(v), std::end(v), &l)); CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1); CHECK(l.events.size() == 1);
CHECK(l.events == std::vector<std::string>({"parse_error(4)"})); CHECK(l.events == std::vector<std::string>({"parse_error(4)"}));
} }
@ -685,14 +685,14 @@ TEST_CASE("deserialization")
{ {
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&); CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(not json::accept(std::begin(v), std::end(v))); CHECK(!json::accept(std::begin(v), std::end(v)));
json j_error; json j_error;
CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false)); CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false));
CHECK(j_error.is_discarded()); CHECK(j_error.is_discarded());
SaxEventLogger l; SaxEventLogger l;
CHECK(not json::sax_parse(std::begin(v), std::end(v), &l)); CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1); CHECK(l.events.size() == 1);
CHECK(l.events == std::vector<std::string>({"parse_error(4)"})); CHECK(l.events == std::vector<std::string>({"parse_error(4)"}));
} }
@ -701,14 +701,14 @@ TEST_CASE("deserialization")
{ {
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&); CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(not json::accept(std::begin(v), std::end(v))); CHECK(!json::accept(std::begin(v), std::end(v)));
json j_error; json j_error;
CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false)); CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false));
CHECK(j_error.is_discarded()); CHECK(j_error.is_discarded());
SaxEventLogger l; SaxEventLogger l;
CHECK(not json::sax_parse(std::begin(v), std::end(v), &l)); CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1); CHECK(l.events.size() == 1);
CHECK(l.events == std::vector<std::string>({"parse_error(4)"})); CHECK(l.events == std::vector<std::string>({"parse_error(4)"}));
} }
@ -717,14 +717,14 @@ TEST_CASE("deserialization")
{ {
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&); CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(not json::accept(std::begin(v), std::end(v))); CHECK(!json::accept(std::begin(v), std::end(v)));
json j_error; json j_error;
CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false)); CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false));
CHECK(j_error.is_discarded()); CHECK(j_error.is_discarded());
SaxEventLogger l; SaxEventLogger l;
CHECK(not json::sax_parse(std::begin(v), std::end(v), &l)); CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1); CHECK(l.events.size() == 1);
CHECK(l.events == std::vector<std::string>({"parse_error(4)"})); CHECK(l.events == std::vector<std::string>({"parse_error(4)"}));
} }
@ -733,14 +733,14 @@ TEST_CASE("deserialization")
{ {
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&); CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(not json::accept(std::begin(v), std::end(v))); CHECK(!json::accept(std::begin(v), std::end(v)));
json j_error; json j_error;
CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false)); CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false));
CHECK(j_error.is_discarded()); CHECK(j_error.is_discarded());
SaxEventLogger l; SaxEventLogger l;
CHECK(not json::sax_parse(std::begin(v), std::end(v), &l)); CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1); CHECK(l.events.size() == 1);
CHECK(l.events == std::vector<std::string>({"parse_error(4)"})); CHECK(l.events == std::vector<std::string>({"parse_error(4)"}));
} }
@ -749,14 +749,14 @@ TEST_CASE("deserialization")
{ {
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&); CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(not json::accept(std::begin(v), std::end(v))); CHECK(!json::accept(std::begin(v), std::end(v)));
json j_error; json j_error;
CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false)); CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false));
CHECK(j_error.is_discarded()); CHECK(j_error.is_discarded());
SaxEventLogger l; SaxEventLogger l;
CHECK(not json::sax_parse(std::begin(v), std::end(v), &l)); CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1); CHECK(l.events.size() == 1);
CHECK(l.events == std::vector<std::string>({"parse_error(4)"})); CHECK(l.events == std::vector<std::string>({"parse_error(4)"}));
} }
@ -765,14 +765,14 @@ TEST_CASE("deserialization")
{ {
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&); CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(not json::accept(std::begin(v), std::end(v))); CHECK(!json::accept(std::begin(v), std::end(v)));
json j_error; json j_error;
CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false)); CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false));
CHECK(j_error.is_discarded()); CHECK(j_error.is_discarded());
SaxEventLogger l; SaxEventLogger l;
CHECK(not json::sax_parse(std::begin(v), std::end(v), &l)); CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1); CHECK(l.events.size() == 1);
CHECK(l.events == std::vector<std::string>({"parse_error(4)"})); CHECK(l.events == std::vector<std::string>({"parse_error(4)"}));
} }
@ -781,14 +781,14 @@ TEST_CASE("deserialization")
{ {
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&); CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(not json::accept(std::begin(v), std::end(v))); CHECK(!json::accept(std::begin(v), std::end(v)));
json j_error; json j_error;
CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false)); CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false));
CHECK(j_error.is_discarded()); CHECK(j_error.is_discarded());
SaxEventLogger l; SaxEventLogger l;
CHECK(not json::sax_parse(std::begin(v), std::end(v), &l)); CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1); CHECK(l.events.size() == 1);
CHECK(l.events == std::vector<std::string>({"parse_error(4)"})); CHECK(l.events == std::vector<std::string>({"parse_error(4)"}));
} }
@ -797,14 +797,14 @@ TEST_CASE("deserialization")
{ {
uint8_t v[] = {'{', '\"', '\"', ':', '1', '1'}; uint8_t v[] = {'{', '\"', '\"', ':', '1', '1'};
CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&); CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(not json::accept(std::begin(v), std::end(v))); CHECK(!json::accept(std::begin(v), std::end(v)));
json j_error; json j_error;
CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false)); CHECK_NOTHROW(j_error = json::parse(std::begin(v), std::end(v), nullptr, false));
CHECK(j_error.is_discarded()); CHECK(j_error.is_discarded());
SaxEventLogger l; SaxEventLogger l;
CHECK(not json::sax_parse(std::begin(v), std::end(v), &l)); CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 4); CHECK(l.events.size() == 4);
CHECK(l.events == std::vector<std::string>( CHECK(l.events == std::vector<std::string>(
{ {
@ -831,7 +831,7 @@ TEST_CASE("deserialization")
"[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal"); "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal");
SaxEventLogger l; SaxEventLogger l;
CHECK(not json::sax_parse(bom, &l)); CHECK(!json::sax_parse(bom, &l));
CHECK(l.events.size() == 1); CHECK(l.events.size() == 1);
CHECK(l.events == std::vector<std::string>( CHECK(l.events == std::vector<std::string>(
{ {
@ -871,8 +871,8 @@ TEST_CASE("deserialization")
"[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid BOM; must be 0xEF 0xBB 0xBF if given; last read: '\xEF\xBB'"); "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid BOM; must be 0xEF 0xBB 0xBF if given; last read: '\xEF\xBB'");
SaxEventLogger l1, l2; SaxEventLogger l1, l2;
CHECK(not json::sax_parse(std::istringstream(bom.substr(0, 2)), &l1)); CHECK(!json::sax_parse(std::istringstream(bom.substr(0, 2)), &l1));
CHECK(not json::sax_parse(bom.substr(0, 2), &l2)); CHECK(!json::sax_parse(bom.substr(0, 2), &l2));
CHECK(l1.events.size() == 1); CHECK(l1.events.size() == 1);
CHECK(l1.events == std::vector<std::string>( CHECK(l1.events == std::vector<std::string>(
{ {
@ -897,8 +897,8 @@ TEST_CASE("deserialization")
"[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid BOM; must be 0xEF 0xBB 0xBF if given; last read: '\xEF'"); "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid BOM; must be 0xEF 0xBB 0xBF if given; last read: '\xEF'");
SaxEventLogger l1, l2; SaxEventLogger l1, l2;
CHECK(not json::sax_parse(std::istringstream(bom.substr(0, 1)), &l1)); CHECK(!json::sax_parse(std::istringstream(bom.substr(0, 1)), &l1));
CHECK(not json::sax_parse(bom.substr(0, 1), &l2)); CHECK(!json::sax_parse(bom.substr(0, 1), &l2));
CHECK(l1.events.size() == 1); CHECK(l1.events.size() == 1);
CHECK(l1.events == std::vector<std::string>( CHECK(l1.events == std::vector<std::string>(
{ {
@ -931,7 +931,7 @@ TEST_CASE("deserialization")
s.push_back(static_cast<char>(bom[1] + i1)); s.push_back(static_cast<char>(bom[1] + i1));
s.push_back(static_cast<char>(bom[2] + i2)); s.push_back(static_cast<char>(bom[2] + i2));
if (i0 == 0 and i1 == 0 and i2 == 0) if (i0 == 0 && i1 == 0 && i2 == 0)
{ {
// without any variation, we skip the BOM // without any variation, we skip the BOM
CHECK(json::parse(s + "null") == json()); CHECK(json::parse(s + "null") == json());
@ -953,7 +953,7 @@ TEST_CASE("deserialization")
CHECK_THROWS_AS(_ = json::parse(std::istringstream(s + "null")), json::parse_error&); CHECK_THROWS_AS(_ = json::parse(std::istringstream(s + "null")), json::parse_error&);
SaxEventLogger l; SaxEventLogger l;
CHECK(not json::sax_parse(s + "null", &l)); CHECK(!json::sax_parse(s + "null", &l));
CHECK(l.events.size() == 1); CHECK(l.events.size() == 1);
if (i0 != 0) if (i0 != 0)

View file

@ -1072,7 +1072,7 @@ TEST_CASE("element access 2")
} }
} }
#if not defined(JSON_NOEXCEPTION) #if !defined(JSON_NOEXCEPTION)
TEST_CASE("element access 2 (throwing tests)") TEST_CASE("element access 2 (throwing tests)")
{ {
SECTION("object") SECTION("object")

View file

@ -43,36 +43,36 @@ TEST_CASE("object inspection")
SECTION("object") SECTION("object")
{ {
json j {{"foo", 1}, {"bar", false}}; json j {{"foo", 1}, {"bar", false}};
CHECK(not j.is_null()); CHECK(!j.is_null());
CHECK(not j.is_boolean()); CHECK(!j.is_boolean());
CHECK(not j.is_number()); CHECK(!j.is_number());
CHECK(not j.is_number_integer()); CHECK(!j.is_number_integer());
CHECK(not j.is_number_unsigned()); CHECK(!j.is_number_unsigned());
CHECK(not j.is_number_float()); CHECK(!j.is_number_float());
CHECK(not j.is_binary()); CHECK(!j.is_binary());
CHECK(j.is_object()); CHECK(j.is_object());
CHECK(not j.is_array()); CHECK(!j.is_array());
CHECK(not j.is_string()); CHECK(!j.is_string());
CHECK(not j.is_discarded()); CHECK(!j.is_discarded());
CHECK(not j.is_primitive()); CHECK(!j.is_primitive());
CHECK(j.is_structured()); CHECK(j.is_structured());
} }
SECTION("array") SECTION("array")
{ {
json j {"foo", 1, 1u, 42.23, false}; json j {"foo", 1, 1u, 42.23, false};
CHECK(not j.is_null()); CHECK(!j.is_null());
CHECK(not j.is_boolean()); CHECK(!j.is_boolean());
CHECK(not j.is_number()); CHECK(!j.is_number());
CHECK(not j.is_number_integer()); CHECK(!j.is_number_integer());
CHECK(not j.is_number_unsigned()); CHECK(!j.is_number_unsigned());
CHECK(not j.is_number_float()); CHECK(!j.is_number_float());
CHECK(not j.is_binary()); CHECK(!j.is_binary());
CHECK(not j.is_object()); CHECK(!j.is_object());
CHECK(j.is_array()); CHECK(j.is_array());
CHECK(not j.is_string()); CHECK(!j.is_string());
CHECK(not j.is_discarded()); CHECK(!j.is_discarded());
CHECK(not j.is_primitive()); CHECK(!j.is_primitive());
CHECK(j.is_structured()); CHECK(j.is_structured());
} }
@ -80,144 +80,144 @@ TEST_CASE("object inspection")
{ {
json j(nullptr); json j(nullptr);
CHECK(j.is_null()); CHECK(j.is_null());
CHECK(not j.is_boolean()); CHECK(!j.is_boolean());
CHECK(not j.is_number()); CHECK(!j.is_number());
CHECK(not j.is_number_integer()); CHECK(!j.is_number_integer());
CHECK(not j.is_number_unsigned()); CHECK(!j.is_number_unsigned());
CHECK(not j.is_number_float()); CHECK(!j.is_number_float());
CHECK(not j.is_binary()); CHECK(!j.is_binary());
CHECK(not j.is_object()); CHECK(!j.is_object());
CHECK(not j.is_array()); CHECK(!j.is_array());
CHECK(not j.is_string()); CHECK(!j.is_string());
CHECK(not j.is_discarded()); CHECK(!j.is_discarded());
CHECK(j.is_primitive()); CHECK(j.is_primitive());
CHECK(not j.is_structured()); CHECK(!j.is_structured());
} }
SECTION("boolean") SECTION("boolean")
{ {
json j(true); json j(true);
CHECK(not j.is_null()); CHECK(!j.is_null());
CHECK(j.is_boolean()); CHECK(j.is_boolean());
CHECK(not j.is_number()); CHECK(!j.is_number());
CHECK(not j.is_number_integer()); CHECK(!j.is_number_integer());
CHECK(not j.is_number_unsigned()); CHECK(!j.is_number_unsigned());
CHECK(not j.is_number_float()); CHECK(!j.is_number_float());
CHECK(not j.is_binary()); CHECK(!j.is_binary());
CHECK(not j.is_object()); CHECK(!j.is_object());
CHECK(not j.is_array()); CHECK(!j.is_array());
CHECK(not j.is_string()); CHECK(!j.is_string());
CHECK(not j.is_discarded()); CHECK(!j.is_discarded());
CHECK(j.is_primitive()); CHECK(j.is_primitive());
CHECK(not j.is_structured()); CHECK(!j.is_structured());
} }
SECTION("string") SECTION("string")
{ {
json j("Hello world"); json j("Hello world");
CHECK(not j.is_null()); CHECK(!j.is_null());
CHECK(not j.is_boolean()); CHECK(!j.is_boolean());
CHECK(not j.is_number()); CHECK(!j.is_number());
CHECK(not j.is_number_integer()); CHECK(!j.is_number_integer());
CHECK(not j.is_number_unsigned()); CHECK(!j.is_number_unsigned());
CHECK(not j.is_number_float()); CHECK(!j.is_number_float());
CHECK(not j.is_binary()); CHECK(!j.is_binary());
CHECK(not j.is_object()); CHECK(!j.is_object());
CHECK(not j.is_array()); CHECK(!j.is_array());
CHECK(j.is_string()); CHECK(j.is_string());
CHECK(not j.is_discarded()); CHECK(!j.is_discarded());
CHECK(j.is_primitive()); CHECK(j.is_primitive());
CHECK(not j.is_structured()); CHECK(!j.is_structured());
} }
SECTION("number (integer)") SECTION("number (integer)")
{ {
json j(42); json j(42);
CHECK(not j.is_null()); CHECK(!j.is_null());
CHECK(not j.is_boolean()); CHECK(!j.is_boolean());
CHECK(j.is_number()); CHECK(j.is_number());
CHECK(j.is_number_integer()); CHECK(j.is_number_integer());
CHECK(not j.is_number_unsigned()); CHECK(!j.is_number_unsigned());
CHECK(not j.is_number_float()); CHECK(!j.is_number_float());
CHECK(not j.is_binary()); CHECK(!j.is_binary());
CHECK(not j.is_object()); CHECK(!j.is_object());
CHECK(not j.is_array()); CHECK(!j.is_array());
CHECK(not j.is_string()); CHECK(!j.is_string());
CHECK(not j.is_discarded()); CHECK(!j.is_discarded());
CHECK(j.is_primitive()); CHECK(j.is_primitive());
CHECK(not j.is_structured()); CHECK(!j.is_structured());
} }
SECTION("number (unsigned)") SECTION("number (unsigned)")
{ {
json j(42u); json j(42u);
CHECK(not j.is_null()); CHECK(!j.is_null());
CHECK(not j.is_boolean()); CHECK(!j.is_boolean());
CHECK(j.is_number()); CHECK(j.is_number());
CHECK(j.is_number_integer()); CHECK(j.is_number_integer());
CHECK(j.is_number_unsigned()); CHECK(j.is_number_unsigned());
CHECK(not j.is_number_float()); CHECK(!j.is_number_float());
CHECK(not j.is_binary()); CHECK(!j.is_binary());
CHECK(not j.is_object()); CHECK(!j.is_object());
CHECK(not j.is_array()); CHECK(!j.is_array());
CHECK(not j.is_string()); CHECK(!j.is_string());
CHECK(not j.is_discarded()); CHECK(!j.is_discarded());
CHECK(j.is_primitive()); CHECK(j.is_primitive());
CHECK(not j.is_structured()); CHECK(!j.is_structured());
} }
SECTION("number (floating-point)") SECTION("number (floating-point)")
{ {
json j(42.23); json j(42.23);
CHECK(not j.is_null()); CHECK(!j.is_null());
CHECK(not j.is_boolean()); CHECK(!j.is_boolean());
CHECK(j.is_number()); CHECK(j.is_number());
CHECK(not j.is_number_integer()); CHECK(!j.is_number_integer());
CHECK(not j.is_number_unsigned()); CHECK(!j.is_number_unsigned());
CHECK(j.is_number_float()); CHECK(j.is_number_float());
CHECK(not j.is_binary()); CHECK(!j.is_binary());
CHECK(not j.is_object()); CHECK(!j.is_object());
CHECK(not j.is_array()); CHECK(!j.is_array());
CHECK(not j.is_string()); CHECK(!j.is_string());
CHECK(not j.is_discarded()); CHECK(!j.is_discarded());
CHECK(j.is_primitive()); CHECK(j.is_primitive());
CHECK(not j.is_structured()); CHECK(!j.is_structured());
} }
SECTION("binary") SECTION("binary")
{ {
json j(json::value_t::binary); json j(json::value_t::binary);
CHECK(not j.is_null()); CHECK(!j.is_null());
CHECK(not j.is_boolean()); CHECK(!j.is_boolean());
CHECK(not j.is_number()); CHECK(!j.is_number());
CHECK(not j.is_number_integer()); CHECK(!j.is_number_integer());
CHECK(not j.is_number_unsigned()); CHECK(!j.is_number_unsigned());
CHECK(not j.is_number_float()); CHECK(!j.is_number_float());
CHECK(j.is_binary()); CHECK(j.is_binary());
CHECK(not j.is_object()); CHECK(!j.is_object());
CHECK(not j.is_array()); CHECK(!j.is_array());
CHECK(not j.is_string()); CHECK(!j.is_string());
CHECK(not j.is_discarded()); CHECK(!j.is_discarded());
CHECK(j.is_primitive()); CHECK(j.is_primitive());
CHECK(not j.is_structured()); CHECK(!j.is_structured());
} }
SECTION("discarded") SECTION("discarded")
{ {
json j(json::value_t::discarded); json j(json::value_t::discarded);
CHECK(not j.is_null()); CHECK(!j.is_null());
CHECK(not j.is_boolean()); CHECK(!j.is_boolean());
CHECK(not j.is_number()); CHECK(!j.is_number());
CHECK(not j.is_number_integer()); CHECK(!j.is_number_integer());
CHECK(not j.is_number_unsigned()); CHECK(!j.is_number_unsigned());
CHECK(not j.is_number_float()); CHECK(!j.is_number_float());
CHECK(not j.is_binary()); CHECK(!j.is_binary());
CHECK(not j.is_object()); CHECK(!j.is_object());
CHECK(not j.is_array()); CHECK(!j.is_array());
CHECK(not j.is_string()); CHECK(!j.is_string());
CHECK(j.is_discarded()); CHECK(j.is_discarded());
CHECK(not j.is_primitive()); CHECK(!j.is_primitive());
CHECK(not j.is_structured()); CHECK(!j.is_structured());
} }
} }

View file

@ -231,12 +231,12 @@ TEST_CASE("iterators 1")
{ {
SECTION("!(begin != begin)") SECTION("!(begin != begin)")
{ {
CHECK(not(j.begin() != j.begin())); CHECK(!(j.begin() != j.begin()));
} }
SECTION("!(end != end)") SECTION("!(end != end)")
{ {
CHECK(not(j.end() != j.end())); CHECK(!(j.end() != j.end()));
} }
SECTION("begin < end") SECTION("begin < end")
@ -286,7 +286,7 @@ TEST_CASE("iterators 1")
SECTION("!(begin == end)") SECTION("!(begin == end)")
{ {
CHECK(not(j.begin() == j.end())); CHECK(!(j.begin() == j.end()));
} }
SECTION("begin != end") SECTION("begin != end")

View file

@ -56,26 +56,26 @@ TEST_CASE("iterators 2")
// comparison: equal // comparison: equal
{ {
CHECK(it1 == it1); CHECK(it1 == it1);
CHECK(not (it1 == it2)); CHECK(!(it1 == it2));
CHECK(not (it1 == it3)); CHECK(!(it1 == it3));
CHECK(not (it2 == it3)); CHECK(!(it2 == it3));
CHECK(it1_c == it1_c); CHECK(it1_c == it1_c);
CHECK(not (it1_c == it2_c)); CHECK(!(it1_c == it2_c));
CHECK(not (it1_c == it3_c)); CHECK(!(it1_c == it3_c));
CHECK(not (it2_c == it3_c)); CHECK(!(it2_c == it3_c));
} }
// comparison: not equal // comparison: not equal
{ {
// check definition // check definition
CHECK( (it1 != it1) == not(it1 == it1) ); CHECK( (it1 != it1) == !(it1 == it1) );
CHECK( (it1 != it2) == not(it1 == it2) ); CHECK( (it1 != it2) == !(it1 == it2) );
CHECK( (it1 != it3) == not(it1 == it3) ); CHECK( (it1 != it3) == !(it1 == it3) );
CHECK( (it2 != it3) == not(it2 == it3) ); CHECK( (it2 != it3) == !(it2 == it3) );
CHECK( (it1_c != it1_c) == not(it1_c == it1_c) ); CHECK( (it1_c != it1_c) == !(it1_c == it1_c) );
CHECK( (it1_c != it2_c) == not(it1_c == it2_c) ); CHECK( (it1_c != it2_c) == !(it1_c == it2_c) );
CHECK( (it1_c != it3_c) == not(it1_c == it3_c) ); CHECK( (it1_c != it3_c) == !(it1_c == it3_c) );
CHECK( (it2_c != it3_c) == not(it2_c == it3_c) ); CHECK( (it2_c != it3_c) == !(it2_c == it3_c) );
} }
// comparison: smaller // comparison: smaller
@ -101,11 +101,11 @@ TEST_CASE("iterators 2")
} }
else else
{ {
CHECK(not (it1 < it1)); CHECK(!(it1 < it1));
CHECK(it1 < it2); CHECK(it1 < it2);
CHECK(it1 < it3); CHECK(it1 < it3);
CHECK(it2 < it3); CHECK(it2 < it3);
CHECK(not (it1_c < it1_c)); CHECK(!(it1_c < it1_c));
CHECK(it1_c < it2_c); CHECK(it1_c < it2_c);
CHECK(it1_c < it3_c); CHECK(it1_c < it3_c);
CHECK(it2_c < it3_c); CHECK(it2_c < it3_c);
@ -136,14 +136,14 @@ TEST_CASE("iterators 2")
else else
{ {
// check definition // check definition
CHECK( (it1 <= it1) == not(it1 < it1) ); CHECK( (it1 <= it1) == !(it1 < it1) );
CHECK( (it1 <= it2) == not(it2 < it1) ); CHECK( (it1 <= it2) == !(it2 < it1) );
CHECK( (it1 <= it3) == not(it3 < it1) ); CHECK( (it1 <= it3) == !(it3 < it1) );
CHECK( (it2 <= it3) == not(it3 < it2) ); CHECK( (it2 <= it3) == !(it3 < it2) );
CHECK( (it1_c <= it1_c) == not(it1_c < it1_c) ); CHECK( (it1_c <= it1_c) == !(it1_c < it1_c) );
CHECK( (it1_c <= it2_c) == not(it2_c < it1_c) ); CHECK( (it1_c <= it2_c) == !(it2_c < it1_c) );
CHECK( (it1_c <= it3_c) == not(it3_c < it1_c) ); CHECK( (it1_c <= it3_c) == !(it3_c < it1_c) );
CHECK( (it2_c <= it3_c) == not(it3_c < it2_c) ); CHECK( (it2_c <= it3_c) == !(it3_c < it2_c) );
} }
} }
@ -206,14 +206,14 @@ TEST_CASE("iterators 2")
else else
{ {
// check definition // check definition
CHECK( (it1 >= it1) == not(it1 < it1) ); CHECK( (it1 >= it1) == !(it1 < it1) );
CHECK( (it1 >= it2) == not(it1 < it2) ); CHECK( (it1 >= it2) == !(it1 < it2) );
CHECK( (it1 >= it3) == not(it1 < it3) ); CHECK( (it1 >= it3) == !(it1 < it3) );
CHECK( (it2 >= it3) == not(it2 < it3) ); CHECK( (it2 >= it3) == !(it2 < it3) );
CHECK( (it1_c >= it1_c) == not(it1_c < it1_c) ); CHECK( (it1_c >= it1_c) == !(it1_c < it1_c) );
CHECK( (it1_c >= it2_c) == not(it1_c < it2_c) ); CHECK( (it1_c >= it2_c) == !(it1_c < it2_c) );
CHECK( (it1_c >= it3_c) == not(it1_c < it3_c) ); CHECK( (it1_c >= it3_c) == !(it1_c < it3_c) );
CHECK( (it2_c >= it3_c) == not(it2_c < it3_c) ); CHECK( (it2_c >= it3_c) == !(it2_c < it3_c) );
} }
} }
} }
@ -491,26 +491,26 @@ TEST_CASE("iterators 2")
// comparison: equal // comparison: equal
{ {
CHECK(it1 == it1); CHECK(it1 == it1);
CHECK(not (it1 == it2)); CHECK(!(it1 == it2));
CHECK(not (it1 == it3)); CHECK(!(it1 == it3));
CHECK(not (it2 == it3)); CHECK(!(it2 == it3));
CHECK(it1_c == it1_c); CHECK(it1_c == it1_c);
CHECK(not (it1_c == it2_c)); CHECK(!(it1_c == it2_c));
CHECK(not (it1_c == it3_c)); CHECK(!(it1_c == it3_c));
CHECK(not (it2_c == it3_c)); CHECK(!(it2_c == it3_c));
} }
// comparison: not equal // comparison: not equal
{ {
// check definition // check definition
CHECK( (it1 != it1) == not(it1 == it1) ); CHECK( (it1 != it1) == !(it1 == it1) );
CHECK( (it1 != it2) == not(it1 == it2) ); CHECK( (it1 != it2) == !(it1 == it2) );
CHECK( (it1 != it3) == not(it1 == it3) ); CHECK( (it1 != it3) == !(it1 == it3) );
CHECK( (it2 != it3) == not(it2 == it3) ); CHECK( (it2 != it3) == !(it2 == it3) );
CHECK( (it1_c != it1_c) == not(it1_c == it1_c) ); CHECK( (it1_c != it1_c) == !(it1_c == it1_c) );
CHECK( (it1_c != it2_c) == not(it1_c == it2_c) ); CHECK( (it1_c != it2_c) == !(it1_c == it2_c) );
CHECK( (it1_c != it3_c) == not(it1_c == it3_c) ); CHECK( (it1_c != it3_c) == !(it1_c == it3_c) );
CHECK( (it2_c != it3_c) == not(it2_c == it3_c) ); CHECK( (it2_c != it3_c) == !(it2_c == it3_c) );
} }
// comparison: smaller // comparison: smaller
@ -536,11 +536,11 @@ TEST_CASE("iterators 2")
} }
else else
{ {
CHECK(not (it1 < it1)); CHECK(!(it1 < it1));
CHECK(it1 < it2); CHECK(it1 < it2);
CHECK(it1 < it3); CHECK(it1 < it3);
CHECK(it2 < it3); CHECK(it2 < it3);
CHECK(not (it1_c < it1_c)); CHECK(!(it1_c < it1_c));
CHECK(it1_c < it2_c); CHECK(it1_c < it2_c);
CHECK(it1_c < it3_c); CHECK(it1_c < it3_c);
CHECK(it2_c < it3_c); CHECK(it2_c < it3_c);
@ -571,14 +571,14 @@ TEST_CASE("iterators 2")
else else
{ {
// check definition // check definition
CHECK( (it1 <= it1) == not(it1 < it1) ); CHECK( (it1 <= it1) == !(it1 < it1) );
CHECK( (it1 <= it2) == not(it2 < it1) ); CHECK( (it1 <= it2) == !(it2 < it1) );
CHECK( (it1 <= it3) == not(it3 < it1) ); CHECK( (it1 <= it3) == !(it3 < it1) );
CHECK( (it2 <= it3) == not(it3 < it2) ); CHECK( (it2 <= it3) == !(it3 < it2) );
CHECK( (it1_c <= it1_c) == not(it1_c < it1_c) ); CHECK( (it1_c <= it1_c) == !(it1_c < it1_c) );
CHECK( (it1_c <= it2_c) == not(it2_c < it1_c) ); CHECK( (it1_c <= it2_c) == !(it2_c < it1_c) );
CHECK( (it1_c <= it3_c) == not(it3_c < it1_c) ); CHECK( (it1_c <= it3_c) == !(it3_c < it1_c) );
CHECK( (it2_c <= it3_c) == not(it3_c < it2_c) ); CHECK( (it2_c <= it3_c) == !(it3_c < it2_c) );
} }
} }
@ -641,14 +641,14 @@ TEST_CASE("iterators 2")
else else
{ {
// check definition // check definition
CHECK( (it1 >= it1) == not(it1 < it1) ); CHECK( (it1 >= it1) == !(it1 < it1) );
CHECK( (it1 >= it2) == not(it1 < it2) ); CHECK( (it1 >= it2) == !(it1 < it2) );
CHECK( (it1 >= it3) == not(it1 < it3) ); CHECK( (it1 >= it3) == !(it1 < it3) );
CHECK( (it2 >= it3) == not(it2 < it3) ); CHECK( (it2 >= it3) == !(it2 < it3) );
CHECK( (it1_c >= it1_c) == not(it1_c < it1_c) ); CHECK( (it1_c >= it1_c) == !(it1_c < it1_c) );
CHECK( (it1_c >= it2_c) == not(it1_c < it2_c) ); CHECK( (it1_c >= it2_c) == !(it1_c < it2_c) );
CHECK( (it1_c >= it3_c) == not(it1_c < it3_c) ); CHECK( (it1_c >= it3_c) == !(it1_c < it3_c) );
CHECK( (it2_c >= it3_c) == not(it2_c < it3_c) ); CHECK( (it2_c >= it3_c) == !(it2_c < it3_c) );
} }
} }
} }

View file

@ -101,10 +101,10 @@ TEST_CASE("JSON pointers")
CHECK(j["/foo/1"_json_pointer] == j["foo"][1]); CHECK(j["/foo/1"_json_pointer] == j["foo"][1]);
CHECK(j.contains(json::json_pointer("/foo/0"))); CHECK(j.contains(json::json_pointer("/foo/0")));
CHECK(j.contains(json::json_pointer("/foo/1"))); CHECK(j.contains(json::json_pointer("/foo/1")));
CHECK(not j.contains(json::json_pointer("/foo/3"))); CHECK(!j.contains(json::json_pointer("/foo/3")));
CHECK(not j.contains(json::json_pointer("/foo/+"))); CHECK(!j.contains(json::json_pointer("/foo/+")));
CHECK(not j.contains(json::json_pointer("/foo/1+2"))); CHECK(!j.contains(json::json_pointer("/foo/1+2")));
CHECK(not j.contains(json::json_pointer("/foo/-"))); CHECK(!j.contains(json::json_pointer("/foo/-")));
// checked array access // checked array access
CHECK(j.at(json::json_pointer("/foo/0")) == j["foo"][0]); CHECK(j.at(json::json_pointer("/foo/0")) == j["foo"][0]);
@ -147,19 +147,19 @@ TEST_CASE("JSON pointers")
// unescaped access // unescaped access
// access to nonexisting values yield object creation // access to nonexisting values yield object creation
CHECK(not j.contains(json::json_pointer("/a/b"))); CHECK(!j.contains(json::json_pointer("/a/b")));
CHECK_NOTHROW(j[json::json_pointer("/a/b")] = 42); CHECK_NOTHROW(j[json::json_pointer("/a/b")] = 42);
CHECK(j.contains(json::json_pointer("/a/b"))); CHECK(j.contains(json::json_pointer("/a/b")));
CHECK(j["a"]["b"] == json(42)); CHECK(j["a"]["b"] == json(42));
CHECK(not j.contains(json::json_pointer("/a/c/1"))); CHECK(!j.contains(json::json_pointer("/a/c/1")));
CHECK_NOTHROW(j[json::json_pointer("/a/c/1")] = 42); CHECK_NOTHROW(j[json::json_pointer("/a/c/1")] = 42);
CHECK(j["a"]["c"] == json({nullptr, 42})); CHECK(j["a"]["c"] == json({nullptr, 42}));
CHECK(j.contains(json::json_pointer("/a/c/1"))); CHECK(j.contains(json::json_pointer("/a/c/1")));
CHECK(not j.contains(json::json_pointer("/a/d/-"))); CHECK(!j.contains(json::json_pointer("/a/d/-")));
CHECK_NOTHROW(j[json::json_pointer("/a/d/-")] = 42); CHECK_NOTHROW(j[json::json_pointer("/a/d/-")] = 42);
CHECK(not j.contains(json::json_pointer("/a/d/-"))); CHECK(!j.contains(json::json_pointer("/a/d/-")));
CHECK(j["a"]["d"] == json::array({42})); CHECK(j["a"]["d"] == json::array({42}));
// "/a/b" works for JSON {"a": {"b": 42}} // "/a/b" works for JSON {"a": {"b": 42}}
CHECK(json({{"a", {{"b", 42}}}})[json::json_pointer("/a/b")] == json(42)); CHECK(json({{"a", {{"b", 42}}}})[json::json_pointer("/a/b")] == json(42));
@ -172,7 +172,7 @@ TEST_CASE("JSON pointers")
CHECK_THROWS_AS(j_primitive.at("/foo"_json_pointer), json::out_of_range&); CHECK_THROWS_AS(j_primitive.at("/foo"_json_pointer), json::out_of_range&);
CHECK_THROWS_WITH(j_primitive.at("/foo"_json_pointer), CHECK_THROWS_WITH(j_primitive.at("/foo"_json_pointer),
"[json.exception.out_of_range.404] unresolved reference token 'foo'"); "[json.exception.out_of_range.404] unresolved reference token 'foo'");
CHECK(not j_primitive.contains(json::json_pointer("/foo"))); CHECK(!j_primitive.contains(json::json_pointer("/foo")));
} }
SECTION("const access") SECTION("const access")
@ -272,7 +272,7 @@ TEST_CASE("JSON pointers")
CHECK(j.contains("/foo"_json_pointer)); CHECK(j.contains("/foo"_json_pointer));
CHECK(j.contains("/foo/0"_json_pointer)); CHECK(j.contains("/foo/0"_json_pointer));
CHECK(j.contains("/foo/1"_json_pointer)); CHECK(j.contains("/foo/1"_json_pointer));
CHECK(not j.contains("/foo/-"_json_pointer)); CHECK(!j.contains("/foo/-"_json_pointer));
} }
} }
@ -314,10 +314,10 @@ TEST_CASE("JSON pointers")
CHECK_THROWS_WITH(j_const.at("/01"_json_pointer), CHECK_THROWS_WITH(j_const.at("/01"_json_pointer),
"[json.exception.parse_error.106] parse error: array index '01' must not begin with '0'"); "[json.exception.parse_error.106] parse error: array index '01' must not begin with '0'");
CHECK(not j.contains("/01"_json_pointer)); CHECK(!j.contains("/01"_json_pointer));
CHECK(not j.contains("/01"_json_pointer)); CHECK(!j.contains("/01"_json_pointer));
CHECK(not j_const.contains("/01"_json_pointer)); CHECK(!j_const.contains("/01"_json_pointer));
CHECK(not j_const.contains("/01"_json_pointer)); CHECK(!j_const.contains("/01"_json_pointer));
// error with incorrect numbers // error with incorrect numbers
CHECK_THROWS_AS(j["/one"_json_pointer] = 1, json::parse_error&); CHECK_THROWS_AS(j["/one"_json_pointer] = 1, json::parse_error&);
@ -362,10 +362,10 @@ TEST_CASE("JSON pointers")
CHECK_THROWS_WITH(j_const.at("/one"_json_pointer) == 1, CHECK_THROWS_WITH(j_const.at("/one"_json_pointer) == 1,
"[json.exception.parse_error.109] parse error: array index 'one' is not a number"); "[json.exception.parse_error.109] parse error: array index 'one' is not a number");
CHECK(not j.contains("/one"_json_pointer)); CHECK(!j.contains("/one"_json_pointer));
CHECK(not j.contains("/one"_json_pointer)); CHECK(!j.contains("/one"_json_pointer));
CHECK(not j_const.contains("/one"_json_pointer)); CHECK(!j_const.contains("/one"_json_pointer));
CHECK(not j_const.contains("/one"_json_pointer)); CHECK(!j_const.contains("/one"_json_pointer));
CHECK_THROWS_AS(json({{"/list/0", 1}, {"/list/1", 2}, {"/list/three", 3}}).unflatten(), json::parse_error&); CHECK_THROWS_AS(json({{"/list/0", 1}, {"/list/1", 2}, {"/list/three", 3}}).unflatten(), json::parse_error&);
CHECK_THROWS_WITH(json({{"/list/0", 1}, {"/list/1", 2}, {"/list/three", 3}}).unflatten(), CHECK_THROWS_WITH(json({{"/list/0", 1}, {"/list/1", 2}, {"/list/three", 3}}).unflatten(),
@ -379,7 +379,7 @@ TEST_CASE("JSON pointers")
CHECK_THROWS_AS(j_const["/-"_json_pointer], json::out_of_range&); CHECK_THROWS_AS(j_const["/-"_json_pointer], json::out_of_range&);
CHECK_THROWS_WITH(j_const["/-"_json_pointer], CHECK_THROWS_WITH(j_const["/-"_json_pointer],
"[json.exception.out_of_range.402] array index '-' (3) is out of range"); "[json.exception.out_of_range.402] array index '-' (3) is out of range");
CHECK(not j_const.contains("/-"_json_pointer)); CHECK(!j_const.contains("/-"_json_pointer));
// error when using "-" with at // error when using "-" with at
CHECK_THROWS_AS(j.at("/-"_json_pointer), json::out_of_range&); CHECK_THROWS_AS(j.at("/-"_json_pointer), json::out_of_range&);
@ -388,7 +388,7 @@ TEST_CASE("JSON pointers")
CHECK_THROWS_AS(j_const.at("/-"_json_pointer), json::out_of_range&); CHECK_THROWS_AS(j_const.at("/-"_json_pointer), json::out_of_range&);
CHECK_THROWS_WITH(j_const.at("/-"_json_pointer), CHECK_THROWS_WITH(j_const.at("/-"_json_pointer),
"[json.exception.out_of_range.402] array index '-' (3) is out of range"); "[json.exception.out_of_range.402] array index '-' (3) is out of range");
CHECK(not j_const.contains("/-"_json_pointer)); CHECK(!j_const.contains("/-"_json_pointer));
} }
SECTION("const access") SECTION("const access")
@ -404,13 +404,13 @@ TEST_CASE("JSON pointers")
CHECK_THROWS_AS(j.at("/3"_json_pointer), json::out_of_range&); CHECK_THROWS_AS(j.at("/3"_json_pointer), json::out_of_range&);
CHECK_THROWS_WITH(j.at("/3"_json_pointer), CHECK_THROWS_WITH(j.at("/3"_json_pointer),
"[json.exception.out_of_range.401] array index 3 is out of range"); "[json.exception.out_of_range.401] array index 3 is out of range");
CHECK(not j.contains("/3"_json_pointer)); CHECK(!j.contains("/3"_json_pointer));
// assign to nonexisting index (with gap) // assign to nonexisting index (with gap)
CHECK_THROWS_AS(j.at("/5"_json_pointer), json::out_of_range&); CHECK_THROWS_AS(j.at("/5"_json_pointer), json::out_of_range&);
CHECK_THROWS_WITH(j.at("/5"_json_pointer), CHECK_THROWS_WITH(j.at("/5"_json_pointer),
"[json.exception.out_of_range.401] array index 5 is out of range"); "[json.exception.out_of_range.401] array index 5 is out of range");
CHECK(not j.contains("/5"_json_pointer)); CHECK(!j.contains("/5"_json_pointer));
// assign to "-" // assign to "-"
CHECK_THROWS_AS(j["/-"_json_pointer], json::out_of_range&); CHECK_THROWS_AS(j["/-"_json_pointer], json::out_of_range&);
@ -419,7 +419,7 @@ TEST_CASE("JSON pointers")
CHECK_THROWS_AS(j.at("/-"_json_pointer), json::out_of_range&); CHECK_THROWS_AS(j.at("/-"_json_pointer), json::out_of_range&);
CHECK_THROWS_WITH(j.at("/-"_json_pointer), CHECK_THROWS_WITH(j.at("/-"_json_pointer),
"[json.exception.out_of_range.402] array index '-' (3) is out of range"); "[json.exception.out_of_range.402] array index '-' (3) is out of range");
CHECK(not j.contains("/-"_json_pointer)); CHECK(!j.contains("/-"_json_pointer));
} }
} }

View file

@ -114,7 +114,7 @@ TEST_CASE("modifiers")
json k = j; json k = j;
j.clear(); j.clear();
CHECK(not j.empty()); CHECK(!j.empty());
CHECK(j == json(json::value_t::binary)); CHECK(j == json(json::value_t::binary));
CHECK(j == json(k.type())); CHECK(j == json(k.type()));
} }
@ -125,7 +125,7 @@ TEST_CASE("modifiers")
json k = j; json k = j;
j.clear(); j.clear();
CHECK(not j.empty()); CHECK(!j.empty());
CHECK(j == json(json::value_t::binary)); CHECK(j == json(json::value_t::binary));
CHECK(j == json(k.type())); CHECK(j == json(k.type()));
} }

View file

@ -1544,21 +1544,21 @@ TEST_CASE("MessagePack")
{ {
std::vector<uint8_t> v = {0x93, 0x01, 0x02, 0x03}; std::vector<uint8_t> v = {0x93, 0x01, 0x02, 0x03};
SaxCountdown scp(0); SaxCountdown scp(0);
CHECK(not json::sax_parse(v, &scp, json::input_format_t::msgpack)); CHECK(!json::sax_parse(v, &scp, json::input_format_t::msgpack));
} }
SECTION("start_object(len)") SECTION("start_object(len)")
{ {
std::vector<uint8_t> v = {0x81, 0xa3, 0x66, 0x6F, 0x6F, 0xc2}; std::vector<uint8_t> v = {0x81, 0xa3, 0x66, 0x6F, 0x6F, 0xc2};
SaxCountdown scp(0); SaxCountdown scp(0);
CHECK(not json::sax_parse(v, &scp, json::input_format_t::msgpack)); CHECK(!json::sax_parse(v, &scp, json::input_format_t::msgpack));
} }
SECTION("key()") SECTION("key()")
{ {
std::vector<uint8_t> v = {0x81, 0xa3, 0x66, 0x6F, 0x6F, 0xc2}; std::vector<uint8_t> v = {0x81, 0xa3, 0x66, 0x6F, 0x6F, 0xc2};
SaxCountdown scp(1); SaxCountdown scp(1);
CHECK(not json::sax_parse(v, &scp, json::input_format_t::msgpack)); CHECK(!json::sax_parse(v, &scp, json::input_format_t::msgpack));
} }
} }
} }

View file

@ -59,12 +59,12 @@ static_assert(noexcept(nlohmann::to_json(*j, 2.5)), "");
static_assert(noexcept(nlohmann::to_json(*j, true)), ""); static_assert(noexcept(nlohmann::to_json(*j, true)), "");
static_assert(noexcept(nlohmann::to_json(*j, test{})), ""); static_assert(noexcept(nlohmann::to_json(*j, test{})), "");
static_assert(noexcept(nlohmann::to_json(*j, pod{})), ""); static_assert(noexcept(nlohmann::to_json(*j, pod{})), "");
static_assert(not noexcept(nlohmann::to_json(*j, pod_bis{})), ""); static_assert(!noexcept(nlohmann::to_json(*j, pod_bis{})), "");
static_assert(noexcept(json(2)), ""); static_assert(noexcept(json(2)), "");
static_assert(noexcept(json(test{})), ""); static_assert(noexcept(json(test{})), "");
static_assert(noexcept(json(pod{})), ""); static_assert(noexcept(json(pod{})), "");
static_assert(noexcept(j->get<pod>()), ""); static_assert(noexcept(j->get<pod>()), "");
static_assert(not noexcept(j->get<pod_bis>()), ""); static_assert(!noexcept(j->get<pod_bis>()), "");
static_assert(noexcept(json(pod{})), ""); static_assert(noexcept(json(pod{})), "");
} }

View file

@ -254,12 +254,12 @@ TEST_CASE("regression tests")
json j1 = INFINITY; json j1 = INFINITY;
CHECK(j1.is_number_float()); CHECK(j1.is_number_float());
json::number_float_t f1 = j1; json::number_float_t f1 = j1;
CHECK(not std::isfinite(f1)); CHECK(!std::isfinite(f1));
json j2 = json::number_float_t(INFINITY); json j2 = json::number_float_t(INFINITY);
CHECK(j2.is_number_float()); CHECK(j2.is_number_float());
json::number_float_t f2 = j2; json::number_float_t f2 = j2;
CHECK(not std::isfinite(f2)); CHECK(!std::isfinite(f2));
} }
} }
@ -1350,10 +1350,10 @@ TEST_CASE("regression tests")
CHECK(j["a"] > 3); CHECK(j["a"] > 3);
CHECK(not(j["a"] <= 4)); CHECK(!(j["a"] <= 4));
CHECK(not(j["a"] < 4)); CHECK(!(j["a"] < 4));
CHECK(not(j["a"] >= 6)); CHECK(!(j["a"] >= 6));
CHECK(not(j["a"] > 6)); CHECK(!(j["a"] > 6));
// scalar op json // scalar op json
CHECK(5 == j["a"]); CHECK(5 == j["a"]);
@ -1364,10 +1364,10 @@ TEST_CASE("regression tests")
CHECK(3 <= j["a"]); CHECK(3 <= j["a"]);
CHECK(3 < j["a"]); CHECK(3 < j["a"]);
CHECK(not(4 >= j["a"])); CHECK(!(4 >= j["a"]));
CHECK(not(4 > j["a"])); CHECK(!(4 > j["a"]));
CHECK(not(6 <= j["a"])); CHECK(!(6 <= j["a"]));
CHECK(not(6 < j["a"])); CHECK(!(6 < j["a"]));
} }
SECTION("issue #575 - heap-buffer-overflow (OSS-Fuzz 1400)") SECTION("issue #575 - heap-buffer-overflow (OSS-Fuzz 1400)")
@ -1608,7 +1608,7 @@ TEST_CASE("regression tests")
json::parser_callback_t cb = [](int /*depth*/, json::parse_event_t event, json & parsed) json::parser_callback_t cb = [](int /*depth*/, json::parse_event_t event, json & parsed)
{ {
// skip object elements with key "Thumbnail" // skip object elements with key "Thumbnail"
if (event == json::parse_event_t::key and parsed == json("Thumbnail")) if (event == json::parse_event_t::key && parsed == json("Thumbnail"))
{ {
return false; return false;
} }
@ -1680,7 +1680,7 @@ TEST_CASE("regression tests")
json::parser_callback_t cb = [&](int, json::parse_event_t event, json & parsed) json::parser_callback_t cb = [&](int, json::parse_event_t event, json & parsed)
{ {
// skip uninteresting events // skip uninteresting events
if (event == json::parse_event_t::value and !parsed.is_primitive()) if (event == json::parse_event_t::value && !parsed.is_primitive())
{ {
return false; return false;
} }
@ -1760,7 +1760,7 @@ TEST_CASE("regression tests")
SECTION("issue #1292 - Serializing std::variant causes stack overflow") SECTION("issue #1292 - Serializing std::variant causes stack overflow")
{ {
static_assert( static_assert(
not std::is_constructible<json, std::variant<int, float>>::value, ""); !std::is_constructible<json, std::variant<int, float>>::value, "");
} }
#endif #endif
@ -1947,7 +1947,7 @@ TEST_CASE("regression tests")
} }
} }
#if not defined(JSON_NOEXCEPTION) #if !defined(JSON_NOEXCEPTION)
TEST_CASE("regression tests, exceptions dependent") TEST_CASE("regression tests, exceptions dependent")
{ {
SECTION("issue #1340 - eof not set on exhausted input stream") SECTION("issue #1340 - eof not set on exhausted input stream")

View file

@ -1235,7 +1235,7 @@ TEST_CASE("nst's JSONTestSuite (2)")
json _; json _;
CHECK_THROWS_AS(_ = json::parse(f), json::parse_error&); CHECK_THROWS_AS(_ = json::parse(f), json::parse_error&);
std::ifstream f2(filename); std::ifstream f2(filename);
CHECK(not json::accept(f2)); CHECK(!json::accept(f2));
} }
} }
@ -1250,7 +1250,7 @@ TEST_CASE("nst's JSONTestSuite (2)")
{ {
CAPTURE(filename) CAPTURE(filename)
std::ifstream f(filename); std::ifstream f(filename);
CHECK(not json::accept(f)); CHECK(!json::accept(f));
} }
} }
@ -1352,7 +1352,7 @@ TEST_CASE("nst's JSONTestSuite (2)")
json _; json _;
CHECK_THROWS_AS(_ = json::parse(f), json::exception&); // could be parse_error or out_of_range CHECK_THROWS_AS(_ = json::parse(f), json::exception&); // could be parse_error or out_of_range
std::ifstream f2(filename); std::ifstream f2(filename);
CHECK(not json::accept(f2)); CHECK(!json::accept(f2));
} }
} }
} }

View file

@ -1586,42 +1586,42 @@ TEST_CASE("UBJSON")
{ {
std::vector<uint8_t> v = {'[', 'T', 'F', ']'}; std::vector<uint8_t> v = {'[', 'T', 'F', ']'};
SaxCountdown scp(0); SaxCountdown scp(0);
CHECK(not json::sax_parse(v, &scp, json::input_format_t::ubjson)); CHECK(!json::sax_parse(v, &scp, json::input_format_t::ubjson));
} }
SECTION("start_object()") SECTION("start_object()")
{ {
std::vector<uint8_t> v = {'{', 'i', 3, 'f', 'o', 'o', 'F', '}'}; std::vector<uint8_t> v = {'{', 'i', 3, 'f', 'o', 'o', 'F', '}'};
SaxCountdown scp(0); SaxCountdown scp(0);
CHECK(not json::sax_parse(v, &scp, json::input_format_t::ubjson)); CHECK(!json::sax_parse(v, &scp, json::input_format_t::ubjson));
} }
SECTION("key() in object") SECTION("key() in object")
{ {
std::vector<uint8_t> v = {'{', 'i', 3, 'f', 'o', 'o', 'F', '}'}; std::vector<uint8_t> v = {'{', 'i', 3, 'f', 'o', 'o', 'F', '}'};
SaxCountdown scp(1); SaxCountdown scp(1);
CHECK(not json::sax_parse(v, &scp, json::input_format_t::ubjson)); CHECK(!json::sax_parse(v, &scp, json::input_format_t::ubjson));
} }
SECTION("start_array(len)") SECTION("start_array(len)")
{ {
std::vector<uint8_t> v = {'[', '#', 'i', '2', 'T', 'F'}; std::vector<uint8_t> v = {'[', '#', 'i', '2', 'T', 'F'};
SaxCountdown scp(0); SaxCountdown scp(0);
CHECK(not json::sax_parse(v, &scp, json::input_format_t::ubjson)); CHECK(!json::sax_parse(v, &scp, json::input_format_t::ubjson));
} }
SECTION("start_object(len)") SECTION("start_object(len)")
{ {
std::vector<uint8_t> v = {'{', '#', 'i', '1', 3, 'f', 'o', 'o', 'F'}; std::vector<uint8_t> v = {'{', '#', 'i', '1', 3, 'f', 'o', 'o', 'F'};
SaxCountdown scp(0); SaxCountdown scp(0);
CHECK(not json::sax_parse(v, &scp, json::input_format_t::ubjson)); CHECK(!json::sax_parse(v, &scp, json::input_format_t::ubjson));
} }
SECTION("key() in object with length") SECTION("key() in object with length")
{ {
std::vector<uint8_t> v = {'{', 'i', 3, 'f', 'o', 'o', 'F', '}'}; std::vector<uint8_t> v = {'{', 'i', 3, 'f', 'o', 'o', 'F', '}'};
SaxCountdown scp(1); SaxCountdown scp(1);
CHECK(not json::sax_parse(v, &scp, json::input_format_t::ubjson)); CHECK(!json::sax_parse(v, &scp, json::input_format_t::ubjson));
} }
} }
@ -2363,7 +2363,7 @@ TEST_CASE("Universal Binary JSON Specification Examples 1")
} }
} }
#if not defined(JSON_NOEXCEPTION) #if !defined(JSON_NOEXCEPTION)
TEST_CASE("all UBJSON first bytes") TEST_CASE("all UBJSON first bytes")
{ {
// these bytes will fail immediately with exception parse_error.112 // these bytes will fail immediately with exception parse_error.112

View file

@ -551,7 +551,7 @@ struct pod_serializer
template < template <
typename BasicJsonType, typename U = T, typename BasicJsonType, typename U = T,
typename std::enable_if < typename std::enable_if <
not(std::is_pod<U>::value and std::is_class<U>::value), int >::type = 0 > !(std::is_pod<U>::value && std::is_class<U>::value), int >::type = 0 >
static void from_json(const BasicJsonType& j, U& t) static void from_json(const BasicJsonType& j, U& t)
{ {
using nlohmann::from_json; using nlohmann::from_json;
@ -561,7 +561,7 @@ struct pod_serializer
// special behaviour for pods // special behaviour for pods
template < typename BasicJsonType, typename U = T, template < typename BasicJsonType, typename U = T,
typename std::enable_if < typename std::enable_if <
std::is_pod<U>::value and std::is_class<U>::value, int>::type = 0> std::is_pod<U>::value && std::is_class<U>::value, int >::type = 0 >
static void from_json(const BasicJsonType& j, U& t) static void from_json(const BasicJsonType& j, U& t)
{ {
std::uint64_t value; std::uint64_t value;
@ -587,7 +587,7 @@ struct pod_serializer
template < template <
typename BasicJsonType, typename U = T, typename BasicJsonType, typename U = T,
typename std::enable_if < typename std::enable_if <
not(std::is_pod<U>::value and std::is_class<U>::value), int >::type = 0 > !(std::is_pod<U>::value && std::is_class<U>::value), int >::type = 0 >
static void to_json(BasicJsonType& j, const T& t) static void to_json(BasicJsonType& j, const T& t)
{ {
using nlohmann::to_json; using nlohmann::to_json;
@ -596,7 +596,7 @@ struct pod_serializer
template < typename BasicJsonType, typename U = T, template < typename BasicJsonType, typename U = T,
typename std::enable_if < typename std::enable_if <
std::is_pod<U>::value and std::is_class<U>::value, int>::type = 0> std::is_pod<U>::value && std::is_class<U>::value, int >::type = 0 >
static void to_json(BasicJsonType& j, const T& t) noexcept static void to_json(BasicJsonType& j, const T& t) noexcept
{ {
auto bytes = static_cast< const unsigned char*>(static_cast<const void*>(&t)); auto bytes = static_cast< const unsigned char*>(static_cast<const void*>(&t));
@ -805,7 +805,7 @@ struct is_constructible_patched<T, decltype(void(json(std::declval<T>())))> : st
TEST_CASE("an incomplete type does not trigger a compiler error in non-evaluated context" * doctest::test_suite("udt")) TEST_CASE("an incomplete type does not trigger a compiler error in non-evaluated context" * doctest::test_suite("udt"))
{ {
static_assert(not is_constructible_patched<json, incomplete>::value, ""); static_assert(!is_constructible_patched<json, incomplete>::value, "");
} }
namespace namespace
@ -839,5 +839,5 @@ TEST_CASE("Issue #924")
TEST_CASE("Issue #1237") TEST_CASE("Issue #1237")
{ {
struct non_convertible_type {}; struct non_convertible_type {};
static_assert(not std::is_convertible<json, non_convertible_type>::value, ""); static_assert(!std::is_convertible<json, non_convertible_type>::value, "");
} }

View file

@ -217,7 +217,7 @@ TEST_CASE("Unicode" * doctest::skip())
for (int byte1 = 0x00; byte1 <= 0x7F; ++byte1) for (int byte1 = 0x00; byte1 <= 0x7F; ++byte1)
{ {
// unescaped control characters are parse errors in JSON // unescaped control characters are parse errors in JSON
if (0x00 <= byte1 and byte1 <= 0x1F) if (0x00 <= byte1 && byte1 <= 0x1F)
{ {
check_utf8string(false, byte1); check_utf8string(false, byte1);
continue; continue;
@ -274,7 +274,7 @@ TEST_CASE("Unicode" * doctest::skip())
for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2) for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2)
{ {
// skip correct second byte // skip correct second byte
if (0x80 <= byte2 and byte2 <= 0xBF) if (0x80 <= byte2 && byte2 <= 0xBF)
{ {
continue; continue;
} }
@ -331,7 +331,7 @@ TEST_CASE("Unicode" * doctest::skip())
for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2) for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2)
{ {
// skip correct second byte // skip correct second byte
if (0xA0 <= byte2 and byte2 <= 0xBF) if (0xA0 <= byte2 && byte2 <= 0xBF)
{ {
continue; continue;
} }
@ -354,7 +354,7 @@ TEST_CASE("Unicode" * doctest::skip())
for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3) for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3)
{ {
// skip correct third byte // skip correct third byte
if (0x80 <= byte3 and byte3 <= 0xBF) if (0x80 <= byte3 && byte3 <= 0xBF)
{ {
continue; continue;
} }
@ -412,7 +412,7 @@ TEST_CASE("Unicode" * doctest::skip())
for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2) for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2)
{ {
// skip correct second byte // skip correct second byte
if (0x80 <= byte2 and byte2 <= 0xBF) if (0x80 <= byte2 && byte2 <= 0xBF)
{ {
continue; continue;
} }
@ -435,7 +435,7 @@ TEST_CASE("Unicode" * doctest::skip())
for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3) for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3)
{ {
// skip correct third byte // skip correct third byte
if (0x80 <= byte3 and byte3 <= 0xBF) if (0x80 <= byte3 && byte3 <= 0xBF)
{ {
continue; continue;
} }
@ -493,7 +493,7 @@ TEST_CASE("Unicode" * doctest::skip())
for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2) for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2)
{ {
// skip correct second byte // skip correct second byte
if (0x80 <= byte2 and byte2 <= 0x9F) if (0x80 <= byte2 && byte2 <= 0x9F)
{ {
continue; continue;
} }
@ -516,7 +516,7 @@ TEST_CASE("Unicode" * doctest::skip())
for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3) for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3)
{ {
// skip correct third byte // skip correct third byte
if (0x80 <= byte3 and byte3 <= 0xBF) if (0x80 <= byte3 && byte3 <= 0xBF)
{ {
continue; continue;
} }
@ -574,7 +574,7 @@ TEST_CASE("Unicode" * doctest::skip())
for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2) for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2)
{ {
// skip correct second byte // skip correct second byte
if (0x80 <= byte2 and byte2 <= 0xBF) if (0x80 <= byte2 && byte2 <= 0xBF)
{ {
continue; continue;
} }
@ -597,7 +597,7 @@ TEST_CASE("Unicode" * doctest::skip())
for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3) for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3)
{ {
// skip correct third byte // skip correct third byte
if (0x80 <= byte3 and byte3 <= 0xBF) if (0x80 <= byte3 && byte3 <= 0xBF)
{ {
continue; continue;
} }
@ -673,7 +673,7 @@ TEST_CASE("Unicode" * doctest::skip())
for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2) for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2)
{ {
// skip correct second byte // skip correct second byte
if (0x90 <= byte2 and byte2 <= 0xBF) if (0x90 <= byte2 && byte2 <= 0xBF)
{ {
continue; continue;
} }
@ -699,7 +699,7 @@ TEST_CASE("Unicode" * doctest::skip())
for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3) for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3)
{ {
// skip correct third byte // skip correct third byte
if (0x80 <= byte3 and byte3 <= 0xBF) if (0x80 <= byte3 && byte3 <= 0xBF)
{ {
continue; continue;
} }
@ -725,7 +725,7 @@ TEST_CASE("Unicode" * doctest::skip())
for (int byte4 = 0x00; byte4 <= 0xFF; ++byte4) for (int byte4 = 0x00; byte4 <= 0xFF; ++byte4)
{ {
// skip fourth second byte // skip fourth second byte
if (0x80 <= byte3 and byte3 <= 0xBF) if (0x80 <= byte3 && byte3 <= 0xBF)
{ {
continue; continue;
} }
@ -802,7 +802,7 @@ TEST_CASE("Unicode" * doctest::skip())
for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2) for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2)
{ {
// skip correct second byte // skip correct second byte
if (0x80 <= byte2 and byte2 <= 0xBF) if (0x80 <= byte2 && byte2 <= 0xBF)
{ {
continue; continue;
} }
@ -828,7 +828,7 @@ TEST_CASE("Unicode" * doctest::skip())
for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3) for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3)
{ {
// skip correct third byte // skip correct third byte
if (0x80 <= byte3 and byte3 <= 0xBF) if (0x80 <= byte3 && byte3 <= 0xBF)
{ {
continue; continue;
} }
@ -854,7 +854,7 @@ TEST_CASE("Unicode" * doctest::skip())
for (int byte4 = 0x00; byte4 <= 0xFF; ++byte4) for (int byte4 = 0x00; byte4 <= 0xFF; ++byte4)
{ {
// skip correct fourth byte // skip correct fourth byte
if (0x80 <= byte3 and byte3 <= 0xBF) if (0x80 <= byte3 && byte3 <= 0xBF)
{ {
continue; continue;
} }
@ -931,7 +931,7 @@ TEST_CASE("Unicode" * doctest::skip())
for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2) for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2)
{ {
// skip correct second byte // skip correct second byte
if (0x80 <= byte2 and byte2 <= 0x8F) if (0x80 <= byte2 && byte2 <= 0x8F)
{ {
continue; continue;
} }
@ -957,7 +957,7 @@ TEST_CASE("Unicode" * doctest::skip())
for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3) for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3)
{ {
// skip correct third byte // skip correct third byte
if (0x80 <= byte3 and byte3 <= 0xBF) if (0x80 <= byte3 && byte3 <= 0xBF)
{ {
continue; continue;
} }
@ -983,7 +983,7 @@ TEST_CASE("Unicode" * doctest::skip())
for (int byte4 = 0x00; byte4 <= 0xFF; ++byte4) for (int byte4 = 0x00; byte4 <= 0xFF; ++byte4)
{ {
// skip correct fourth byte // skip correct fourth byte
if (0x80 <= byte3 and byte3 <= 0xBF) if (0x80 <= byte3 && byte3 <= 0xBF)
{ {
continue; continue;
} }
@ -1030,7 +1030,7 @@ TEST_CASE("Unicode" * doctest::skip())
// they will never be assigned a character, so there should be no // they will never be assigned a character, so there should be no
// reason to encode them. The official Unicode standard says that // reason to encode them. The official Unicode standard says that
// no UTF forms, including UTF-16, can encode these code points. // no UTF forms, including UTF-16, can encode these code points.
if (cp >= 0xD800u and cp <= 0xDFFFu) if (cp >= 0xD800u && cp <= 0xDFFFu)
{ {
// if we would not skip these code points, we would get a // if we would not skip these code points, we would get a
// "missing low surrogate" exception // "missing low surrogate" exception
@ -1117,7 +1117,7 @@ TEST_CASE("Unicode" * doctest::skip())
{ {
for (std::size_t cp2 = 0x0000u; cp2 <= 0xFFFFu; ++cp2) for (std::size_t cp2 = 0x0000u; cp2 <= 0xFFFFu; ++cp2)
{ {
if (0xDC00u <= cp2 and cp2 <= 0xDFFFu) if (0xDC00u <= cp2 && cp2 <= 0xDFFFu)
{ {
continue; continue;
} }
@ -1163,7 +1163,7 @@ TEST_CASE("Unicode" * doctest::skip())
for (auto s : j) for (auto s : j)
{ {
// skip non-string JSON values // skip non-string JSON values
if (not s.is_string()) if (!s.is_string())
{ {
continue; continue;
} }