Update to Doctest 2.4.12 (#4771)

* ⬆️ Doctest 2.4.12

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🚨 fix warnings

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🚨 fix warnings

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🚨 fix warnings

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🚨 fix warnings

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🚨 fix warnings

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🚨 fix warnings

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🚨 fix warnings

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🚨 fix warnings

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🚨 fix warnings

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🚨 fix warnings

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🚨 fix warnings

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🚨 fix warnings

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🚨 fix warnings

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🚨 fix warnings

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🚨 fix warnings

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann authored and GitHub committed 2025-05-15 19:25:27 +02:00
1 parent 410c96228c
commit e02de2f971
28 files changed
+255 -225

No files matched your search

+8 -8
View File
@@ -207,49 +207,49 @@ TEST_CASE("alternative string type")
{ {
alt_json doc; alt_json doc;
doc["pi"] = 3.141; doc["pi"] = 3.141;
alt_string dump = doc.dump(); const alt_string dump = doc.dump();
CHECK(dump == R"({"pi":3.141})"); CHECK(dump == R"({"pi":3.141})");
} }
{ {
alt_json doc; alt_json doc;
doc["happy"] = true; doc["happy"] = true;
alt_string dump = doc.dump(); const alt_string dump = doc.dump();
CHECK(dump == R"({"happy":true})"); CHECK(dump == R"({"happy":true})");
} }
{ {
alt_json doc; alt_json doc;
doc["name"] = "I'm Batman"; doc["name"] = "I'm Batman";
alt_string dump = doc.dump(); const alt_string dump = doc.dump();
CHECK(dump == R"({"name":"I'm Batman"})"); CHECK(dump == R"({"name":"I'm Batman"})");
} }
{ {
alt_json doc; alt_json doc;
doc["nothing"] = nullptr; doc["nothing"] = nullptr;
alt_string dump = doc.dump(); const alt_string dump = doc.dump();
CHECK(dump == R"({"nothing":null})"); CHECK(dump == R"({"nothing":null})");
} }
{ {
alt_json doc; alt_json doc;
doc["answer"]["everything"] = 42; doc["answer"]["everything"] = 42;
alt_string dump = doc.dump(); const alt_string dump = doc.dump();
CHECK(dump == R"({"answer":{"everything":42}})"); CHECK(dump == R"({"answer":{"everything":42}})");
} }
{ {
alt_json doc; alt_json doc;
doc["list"] = { 1, 0, 2 }; doc["list"] = { 1, 0, 2 };
alt_string dump = doc.dump(); const alt_string dump = doc.dump();
CHECK(dump == R"({"list":[1,0,2]})"); CHECK(dump == R"({"list":[1,0,2]})");
} }
{ {
alt_json doc; alt_json doc;
doc["object"] = { {"currency", "USD"}, {"value", 42.99} }; doc["object"] = { {"currency", "USD"}, {"value", 42.99} };
alt_string dump = doc.dump(); const alt_string dump = doc.dump();
CHECK(dump == R"({"object":{"currency":"USD","value":42.99}})"); CHECK(dump == R"({"object":{"currency":"USD","value":42.99}})");
} }
} }
@@ -257,7 +257,7 @@ TEST_CASE("alternative string type")
SECTION("parse") SECTION("parse")
{ {
auto doc = alt_json::parse(R"({"foo": "bar"})"); auto doc = alt_json::parse(R"({"foo": "bar"})");
alt_string dump = doc.dump(); const alt_string dump = doc.dump();
CHECK(dump == R"({"foo":"bar"})"); CHECK(dump == R"({"foo":"bar"})");
} }
+10 -10
View File
@@ -1226,21 +1226,21 @@ TEST_CASE("BJData")
SECTION("0 (0 00000 0000000000)") SECTION("0 (0 00000 0000000000)")
{ {
json const j = json::from_bjdata(std::vector<uint8_t>({'h', 0x00, 0x00})); json const j = json::from_bjdata(std::vector<uint8_t>({'h', 0x00, 0x00}));
json::number_float_t d{j}; const json::number_float_t d{j};
CHECK(d == 0.0); CHECK(d == 0.0);
} }
SECTION("-0 (1 00000 0000000000)") SECTION("-0 (1 00000 0000000000)")
{ {
json const j = json::from_bjdata(std::vector<uint8_t>({'h', 0x00, 0x80})); json const j = json::from_bjdata(std::vector<uint8_t>({'h', 0x00, 0x80}));
json::number_float_t d{j}; const json::number_float_t d{j};
CHECK(d == -0.0); CHECK(d == -0.0);
} }
SECTION("2**-24 (0 00000 0000000001)") SECTION("2**-24 (0 00000 0000000001)")
{ {
json const j = json::from_bjdata(std::vector<uint8_t>({'h', 0x01, 0x00})); json const j = json::from_bjdata(std::vector<uint8_t>({'h', 0x01, 0x00}));
json::number_float_t d{j}; const json::number_float_t d{j};
CHECK(d == std::pow(2.0, -24.0)); CHECK(d == std::pow(2.0, -24.0));
} }
} }
@@ -1250,7 +1250,7 @@ TEST_CASE("BJData")
SECTION("infinity (0 11111 0000000000)") SECTION("infinity (0 11111 0000000000)")
{ {
json const j = json::from_bjdata(std::vector<uint8_t>({'h', 0x00, 0x7c})); json const j = json::from_bjdata(std::vector<uint8_t>({'h', 0x00, 0x7c}));
json::number_float_t d{j}; const json::number_float_t d{j};
CHECK(d == std::numeric_limits<json::number_float_t>::infinity()); CHECK(d == std::numeric_limits<json::number_float_t>::infinity());
CHECK(j.dump() == "null"); CHECK(j.dump() == "null");
} }
@@ -1258,7 +1258,7 @@ TEST_CASE("BJData")
SECTION("-infinity (1 11111 0000000000)") SECTION("-infinity (1 11111 0000000000)")
{ {
json const j = json::from_bjdata(std::vector<uint8_t>({'h', 0x00, 0xfc})); json const j = json::from_bjdata(std::vector<uint8_t>({'h', 0x00, 0xfc}));
json::number_float_t d{j}; const json::number_float_t d{j};
CHECK(d == -std::numeric_limits<json::number_float_t>::infinity()); CHECK(d == -std::numeric_limits<json::number_float_t>::infinity());
CHECK(j.dump() == "null"); CHECK(j.dump() == "null");
} }
@@ -1269,21 +1269,21 @@ TEST_CASE("BJData")
SECTION("1 (0 01111 0000000000)") SECTION("1 (0 01111 0000000000)")
{ {
json const j = json::from_bjdata(std::vector<uint8_t>({'h', 0x00, 0x3c})); json const j = json::from_bjdata(std::vector<uint8_t>({'h', 0x00, 0x3c}));
json::number_float_t d{j}; const json::number_float_t d{j};
CHECK(d == 1); CHECK(d == 1);
} }
SECTION("-2 (1 10000 0000000000)") SECTION("-2 (1 10000 0000000000)")
{ {
json const j = json::from_bjdata(std::vector<uint8_t>({'h', 0x00, 0xc0})); json const j = json::from_bjdata(std::vector<uint8_t>({'h', 0x00, 0xc0}));
json::number_float_t d{j}; const json::number_float_t d{j};
CHECK(d == -2); CHECK(d == -2);
} }
SECTION("65504 (0 11110 1111111111)") SECTION("65504 (0 11110 1111111111)")
{ {
json const j = json::from_bjdata(std::vector<uint8_t>({'h', 0xff, 0x7b})); json const j = json::from_bjdata(std::vector<uint8_t>({'h', 0xff, 0x7b}));
json::number_float_t d{j}; const json::number_float_t d{j};
CHECK(d == 65504); CHECK(d == 65504);
} }
} }
@@ -3789,7 +3789,7 @@ TEST_CASE("BJData roundtrips" * doctest::skip())
INFO_WITH_TEMP(filename + ": std::vector<uint8_t>"); INFO_WITH_TEMP(filename + ": std::vector<uint8_t>");
// parse JSON file // parse JSON file
std::ifstream f_json(filename); std::ifstream f_json(filename);
json j1 = json::parse(f_json); const json j1 = json::parse(f_json);
// parse BJData file // parse BJData file
auto packed = utils::read_binary_file(filename + ".bjdata"); auto packed = utils::read_binary_file(filename + ".bjdata");
@@ -3804,7 +3804,7 @@ TEST_CASE("BJData roundtrips" * doctest::skip())
INFO_WITH_TEMP(filename + ": std::ifstream"); INFO_WITH_TEMP(filename + ": std::ifstream");
// parse JSON file // parse JSON file
std::ifstream f_json(filename); std::ifstream f_json(filename);
json j1 = json::parse(f_json); const json j1 = json::parse(f_json);
// parse BJData file // parse BJData file
std::ifstream f_bjdata(filename + ".bjdata", std::ios::binary); std::ifstream f_bjdata(filename + ".bjdata", std::ios::binary);
+14 -14
View File
@@ -565,10 +565,10 @@ TEST_CASE("BSON")
SECTION("Example 1") SECTION("Example 1")
{ {
std::vector<std::uint8_t> input = {0x16, 0x00, 0x00, 0x00, 0x02, 'h', 'e', 'l', 'l', 'o', 0x00, 0x06, 0x00, 0x00, 0x00, 'w', 'o', 'r', 'l', 'd', 0x00, 0x00}; std::vector<std::uint8_t> input = {0x16, 0x00, 0x00, 0x00, 0x02, 'h', 'e', 'l', 'l', 'o', 0x00, 0x06, 0x00, 0x00, 0x00, 'w', 'o', 'r', 'l', 'd', 0x00, 0x00};
json parsed = json::from_bson(input); const json parsed = json::from_bson(input);
json expected = {{"hello", "world"}}; const json expected = {{"hello", "world"}};
CHECK(parsed == expected); CHECK(parsed == expected);
auto dumped = json::to_bson(parsed); const auto dumped = json::to_bson(parsed);
CHECK(dumped == input); CHECK(dumped == input);
CHECK(json::from_bson(dumped) == expected); CHECK(json::from_bson(dumped) == expected);
} }
@@ -576,10 +576,10 @@ TEST_CASE("BSON")
SECTION("Example 2") SECTION("Example 2")
{ {
std::vector<std::uint8_t> input = {0x31, 0x00, 0x00, 0x00, 0x04, 'B', 'S', 'O', 'N', 0x00, 0x26, 0x00, 0x00, 0x00, 0x02, 0x30, 0x00, 0x08, 0x00, 0x00, 0x00, 'a', 'w', 'e', 's', 'o', 'm', 'e', 0x00, 0x01, 0x31, 0x00, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x14, 0x40, 0x10, 0x32, 0x00, 0xc2, 0x07, 0x00, 0x00, 0x00, 0x00}; std::vector<std::uint8_t> input = {0x31, 0x00, 0x00, 0x00, 0x04, 'B', 'S', 'O', 'N', 0x00, 0x26, 0x00, 0x00, 0x00, 0x02, 0x30, 0x00, 0x08, 0x00, 0x00, 0x00, 'a', 'w', 'e', 's', 'o', 'm', 'e', 0x00, 0x01, 0x31, 0x00, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x14, 0x40, 0x10, 0x32, 0x00, 0xc2, 0x07, 0x00, 0x00, 0x00, 0x00};
json parsed = json::from_bson(input); const json parsed = json::from_bson(input);
json expected = {{"BSON", {"awesome", 5.05, 1986}}}; const json expected = {{"BSON", {"awesome", 5.05, 1986}}};
CHECK(parsed == expected); CHECK(parsed == expected);
auto dumped = json::to_bson(parsed); const auto dumped = json::to_bson(parsed);
CHECK(dumped == input); CHECK(dumped == input);
CHECK(json::from_bson(dumped) == expected); CHECK(json::from_bson(dumped) == expected);
} }
@@ -588,7 +588,7 @@ TEST_CASE("BSON")
TEST_CASE("BSON input/output_adapters") TEST_CASE("BSON input/output_adapters")
{ {
json json_representation = const json json_representation =
{ {
{"double", 42.5}, {"double", 42.5},
{"entry", 4.2}, {"entry", 4.2},
@@ -596,7 +596,7 @@ TEST_CASE("BSON input/output_adapters")
{"object", {{ "string", "value" }}} {"object", {{ "string", "value" }}}
}; };
std::vector<std::uint8_t> const bson_representation = const std::vector<std::uint8_t> bson_representation =
{ {
/*size */ 0x4f, 0x00, 0x00, 0x00, /*size */ 0x4f, 0x00, 0x00, 0x00,
/*entry*/ 0x01, 'd', 'o', 'u', 'b', 'l', 'e', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x45, 0x40, /*entry*/ 0x01, 'd', 'o', 'u', 'b', 'l', 'e', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x45, 0x40,
@@ -621,7 +621,7 @@ TEST_CASE("BSON input/output_adapters")
{ {
std::basic_ostringstream<char> ss; std::basic_ostringstream<char> ss;
json::to_bson(json_representation, ss); json::to_bson(json_representation, ss);
json j3 = json::from_bson(ss.str()); const json j3 = json::from_bson(ss.str());
CHECK(json_representation == j3); CHECK(json_representation == j3);
} }
@@ -629,7 +629,7 @@ TEST_CASE("BSON input/output_adapters")
{ {
std::string s; std::string s;
json::to_bson(json_representation, s); json::to_bson(json_representation, s);
json j3 = json::from_bson(s); const json j3 = json::from_bson(s);
CHECK(json_representation == j3); CHECK(json_representation == j3);
} }
@@ -637,7 +637,7 @@ TEST_CASE("BSON input/output_adapters")
{ {
std::vector<std::uint8_t> v; std::vector<std::uint8_t> v;
json::to_bson(json_representation, v); json::to_bson(json_representation, v);
json j3 = json::from_bson(v); const json j3 = json::from_bson(v);
CHECK(json_representation == j3); CHECK(json_representation == j3);
} }
} }
@@ -1227,7 +1227,7 @@ TEST_CASE("BSON roundtrips" * doctest::skip())
INFO_WITH_TEMP(filename + ": std::vector<std::uint8_t>"); INFO_WITH_TEMP(filename + ": std::vector<std::uint8_t>");
// parse JSON file // parse JSON file
std::ifstream f_json(filename); std::ifstream f_json(filename);
json j1 = json::parse(f_json); const json j1 = json::parse(f_json);
// parse BSON file // parse BSON file
auto packed = utils::read_binary_file(filename + ".bson"); auto packed = utils::read_binary_file(filename + ".bson");
@@ -1242,7 +1242,7 @@ TEST_CASE("BSON roundtrips" * doctest::skip())
INFO_WITH_TEMP(filename + ": std::ifstream"); INFO_WITH_TEMP(filename + ": std::ifstream");
// parse JSON file // parse JSON file
std::ifstream f_json(filename); std::ifstream f_json(filename);
json j1 = json::parse(f_json); const json j1 = json::parse(f_json);
// parse BSON file // parse BSON file
std::ifstream f_bson(filename + ".bson", std::ios::binary); std::ifstream f_bson(filename + ".bson", std::ios::binary);
@@ -1257,7 +1257,7 @@ TEST_CASE("BSON roundtrips" * doctest::skip())
INFO_WITH_TEMP(filename + ": uint8_t* and size"); INFO_WITH_TEMP(filename + ": uint8_t* and size");
// parse JSON file // parse JSON file
std::ifstream f_json(filename); std::ifstream f_json(filename);
json j1 = json::parse(f_json); const json j1 = json::parse(f_json);
// parse BSON file // parse BSON file
auto packed = utils::read_binary_file(filename + ".bson"); auto packed = utils::read_binary_file(filename + ".bson");
+12 -12
View File
@@ -1022,21 +1022,21 @@ TEST_CASE("CBOR")
SECTION("0 (0 00000 0000000000)") SECTION("0 (0 00000 0000000000)")
{ {
json const j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x00, 0x00})); json const j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x00, 0x00}));
json::number_float_t d{j}; const json::number_float_t d{j};
CHECK(d == 0.0); CHECK(d == 0.0);
} }
SECTION("-0 (1 00000 0000000000)") SECTION("-0 (1 00000 0000000000)")
{ {
json const j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x80, 0x00})); json const j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x80, 0x00}));
json::number_float_t d{j}; const json::number_float_t d{j};
CHECK(d == -0.0); CHECK(d == -0.0);
} }
SECTION("2**-24 (0 00000 0000000001)") SECTION("2**-24 (0 00000 0000000001)")
{ {
json const j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x00, 0x01})); json const j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x00, 0x01}));
json::number_float_t d{j}; const json::number_float_t d{j};
CHECK(d == std::pow(2.0, -24.0)); CHECK(d == std::pow(2.0, -24.0));
} }
} }
@@ -1046,7 +1046,7 @@ TEST_CASE("CBOR")
SECTION("infinity (0 11111 0000000000)") SECTION("infinity (0 11111 0000000000)")
{ {
json const j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x7c, 0x00})); json const j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x7c, 0x00}));
json::number_float_t d{j}; const json::number_float_t d{j};
CHECK(d == std::numeric_limits<json::number_float_t>::infinity()); CHECK(d == std::numeric_limits<json::number_float_t>::infinity());
CHECK(j.dump() == "null"); CHECK(j.dump() == "null");
} }
@@ -1054,7 +1054,7 @@ TEST_CASE("CBOR")
SECTION("-infinity (1 11111 0000000000)") SECTION("-infinity (1 11111 0000000000)")
{ {
json const j = json::from_cbor(std::vector<uint8_t>({0xf9, 0xfc, 0x00})); json const j = json::from_cbor(std::vector<uint8_t>({0xf9, 0xfc, 0x00}));
json::number_float_t d{j}; const json::number_float_t d{j};
CHECK(d == -std::numeric_limits<json::number_float_t>::infinity()); CHECK(d == -std::numeric_limits<json::number_float_t>::infinity());
CHECK(j.dump() == "null"); CHECK(j.dump() == "null");
} }
@@ -1065,21 +1065,21 @@ TEST_CASE("CBOR")
SECTION("1 (0 01111 0000000000)") SECTION("1 (0 01111 0000000000)")
{ {
json const j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x3c, 0x00})); json const j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x3c, 0x00}));
json::number_float_t d{j}; const json::number_float_t d{j};
CHECK(d == 1); CHECK(d == 1);
} }
SECTION("-2 (1 10000 0000000000)") SECTION("-2 (1 10000 0000000000)")
{ {
json const j = json::from_cbor(std::vector<uint8_t>({0xf9, 0xc0, 0x00})); json const j = json::from_cbor(std::vector<uint8_t>({0xf9, 0xc0, 0x00}));
json::number_float_t d{j}; const json::number_float_t d{j};
CHECK(d == -2); CHECK(d == -2);
} }
SECTION("65504 (0 11110 1111111111)") SECTION("65504 (0 11110 1111111111)")
{ {
json const j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x7b, 0xff})); json const j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x7b, 0xff}));
json::number_float_t d{j}; const json::number_float_t d{j};
CHECK(d == 65504); CHECK(d == 65504);
} }
} }
@@ -1942,7 +1942,7 @@ TEST_CASE("CBOR regressions")
{ {
// parse CBOR file // parse CBOR file
auto vec1 = utils::read_binary_file(filename); auto vec1 = utils::read_binary_file(filename);
json j1 = json::from_cbor(vec1); const json j1 = json::from_cbor(vec1);
try try
{ {
@@ -2143,7 +2143,7 @@ TEST_CASE("CBOR roundtrips" * doctest::skip())
INFO_WITH_TEMP(filename + ": std::vector<uint8_t>"); INFO_WITH_TEMP(filename + ": std::vector<uint8_t>");
// parse JSON file // parse JSON file
std::ifstream f_json(filename); std::ifstream f_json(filename);
json j1 = json::parse(f_json); const json j1 = json::parse(f_json);
// parse CBOR file // parse CBOR file
const auto packed = utils::read_binary_file(filename + ".cbor"); const auto packed = utils::read_binary_file(filename + ".cbor");
@@ -2158,7 +2158,7 @@ TEST_CASE("CBOR roundtrips" * doctest::skip())
INFO_WITH_TEMP(filename + ": std::ifstream"); INFO_WITH_TEMP(filename + ": std::ifstream");
// parse JSON file // parse JSON file
std::ifstream f_json(filename); std::ifstream f_json(filename);
json j1 = json::parse(f_json); const json j1 = json::parse(f_json);
// parse CBOR file // parse CBOR file
std::ifstream f_cbor(filename + ".cbor", std::ios::binary); std::ifstream f_cbor(filename + ".cbor", std::ios::binary);
@@ -2173,7 +2173,7 @@ TEST_CASE("CBOR roundtrips" * doctest::skip())
INFO_WITH_TEMP(filename + ": uint8_t* and size"); INFO_WITH_TEMP(filename + ": uint8_t* and size");
// parse JSON file // parse JSON file
std::ifstream f_json(filename); std::ifstream f_json(filename);
json j1 = json::parse(f_json); const json j1 = json::parse(f_json);
// parse CBOR file // parse CBOR file
const auto packed = utils::read_binary_file(filename + ".cbor"); const auto packed = utils::read_binary_file(filename + ".cbor");
+11 -11
View File
@@ -1366,7 +1366,7 @@ TEST_CASE("parser class")
return event != json::parse_event_t::key; return event != json::parse_event_t::key;
}; };
json x = json::parse("{\"key\": false}", cb); const json x = json::parse("{\"key\": false}", cb);
CHECK(x == json::object()); CHECK(x == json::object());
} }
} }
@@ -1400,14 +1400,14 @@ TEST_CASE("parser class")
SECTION("filter nothing") SECTION("filter nothing")
{ {
json j_object = json::parse(s_object, [](int /*unused*/, json::parse_event_t /*unused*/, const json& /*unused*/) noexcept const json j_object = json::parse(s_object, [](int /*unused*/, json::parse_event_t /*unused*/, const json& /*unused*/) noexcept
{ {
return true; return true;
}); });
CHECK (j_object == json({{"foo", 2}, {"bar", {{"baz", 1}}}})); CHECK (j_object == json({{"foo", 2}, {"bar", {{"baz", 1}}}}));
json j_array = json::parse(s_array, [](int /*unused*/, json::parse_event_t /*unused*/, const json& /*unused*/) noexcept const json j_array = json::parse(s_array, [](int /*unused*/, json::parse_event_t /*unused*/, const json& /*unused*/) noexcept
{ {
return true; return true;
}); });
@@ -1436,7 +1436,7 @@ TEST_CASE("parser class")
SECTION("filter specific element") SECTION("filter specific element")
{ {
json j_object = json::parse(s_object, [](int /*unused*/, json::parse_event_t event, const json & j) noexcept const json j_object = json::parse(s_object, [](int /*unused*/, json::parse_event_t event, const json & j) noexcept
{ {
// filter all number(2) elements // filter all number(2) elements
return event != json::parse_event_t::value || j != json(2); return event != json::parse_event_t::value || j != json(2);
@@ -1444,7 +1444,7 @@ TEST_CASE("parser class")
CHECK (j_object == json({{"bar", {{"baz", 1}}}})); CHECK (j_object == json({{"bar", {{"baz", 1}}}}));
json j_array = json::parse(s_array, [](int /*unused*/, json::parse_event_t event, const json & j) noexcept const json j_array = json::parse(s_array, [](int /*unused*/, json::parse_event_t event, const json & j) noexcept
{ {
return event != json::parse_event_t::value || j != json(2); return event != json::parse_event_t::value || j != json(2);
}); });
@@ -1454,7 +1454,7 @@ TEST_CASE("parser class")
SECTION("filter object in array") SECTION("filter object in array")
{ {
json j_filtered1 = json::parse(structured_array, [](int /*unused*/, json::parse_event_t e, const json & parsed) const json j_filtered1 = json::parse(structured_array, [](int /*unused*/, json::parse_event_t e, const json & parsed)
{ {
return !(e == json::parse_event_t::object_end && parsed.contains("foo")); return !(e == json::parse_event_t::object_end && parsed.contains("foo"));
}); });
@@ -1463,7 +1463,7 @@ TEST_CASE("parser class")
CHECK (j_filtered1.size() == 2); CHECK (j_filtered1.size() == 2);
CHECK (j_filtered1 == json({1, {{"qux", "baz"}}})); CHECK (j_filtered1 == json({1, {{"qux", "baz"}}}));
json j_filtered2 = json::parse(structured_array, [](int /*unused*/, json::parse_event_t e, const json& /*parsed*/) noexcept const json j_filtered2 = json::parse(structured_array, [](int /*unused*/, json::parse_event_t e, const json& /*parsed*/) noexcept
{ {
return e != json::parse_event_t::object_end; return e != json::parse_event_t::object_end;
}); });
@@ -1478,7 +1478,7 @@ TEST_CASE("parser class")
SECTION("first closing event") SECTION("first closing event")
{ {
{ {
json j_object = json::parse(s_object, [](int /*unused*/, json::parse_event_t e, const json& /*unused*/) noexcept const json j_object = json::parse(s_object, [](int /*unused*/, json::parse_event_t e, const json& /*unused*/) noexcept
{ {
static bool first = true; static bool first = true;
if (e == json::parse_event_t::object_end && first) if (e == json::parse_event_t::object_end && first)
@@ -1495,7 +1495,7 @@ TEST_CASE("parser class")
} }
{ {
json j_array = json::parse(s_array, [](int /*unused*/, json::parse_event_t e, const json& /*unused*/) noexcept const json j_array = json::parse(s_array, [](int /*unused*/, json::parse_event_t e, const json& /*unused*/) noexcept
{ {
static bool first = true; static bool first = true;
if (e == json::parse_event_t::array_end && first) if (e == json::parse_event_t::array_end && first)
@@ -1519,13 +1519,13 @@ TEST_CASE("parser class")
// object and array is discarded only after the closing character // object and array is discarded only after the closing character
// has been read // has been read
json j_empty_object = json::parse("{}", [](int /*unused*/, json::parse_event_t e, const json& /*unused*/) noexcept const json j_empty_object = json::parse("{}", [](int /*unused*/, json::parse_event_t e, const json& /*unused*/) noexcept
{ {
return e != json::parse_event_t::object_end; return e != json::parse_event_t::object_end;
}); });
CHECK(j_empty_object == json()); CHECK(j_empty_object == json());
json j_empty_array = json::parse("[]", [](int /*unused*/, json::parse_event_t e, const json& /*unused*/) noexcept const json j_empty_array = json::parse("[]", [](int /*unused*/, json::parse_event_t e, const json& /*unused*/) noexcept
{ {
return e != json::parse_event_t::array_end; return e != json::parse_event_t::array_end;
}); });
@@ -1413,7 +1413,7 @@ TEST_CASE("parser class")
return event != json::parse_event_t::key; return event != json::parse_event_t::key;
}; };
json x = json::parse("{\"key\": false}", cb); const json x = json::parse("{\"key\": false}", cb);
CHECK(x == json::object()); CHECK(x == json::object());
} }
} }
@@ -1447,14 +1447,14 @@ TEST_CASE("parser class")
SECTION("filter nothing") SECTION("filter nothing")
{ {
json j_object = json::parse(s_object, [](int /*unused*/, json::parse_event_t /*unused*/, const json& /*unused*/) noexcept const json j_object = json::parse(s_object, [](int /*unused*/, json::parse_event_t /*unused*/, const json& /*unused*/) noexcept
{ {
return true; return true;
}); });
CHECK (j_object == json({{"foo", 2}, {"bar", {{"baz", 1}}}})); CHECK (j_object == json({{"foo", 2}, {"bar", {{"baz", 1}}}}));
json j_array = json::parse(s_array, [](int /*unused*/, json::parse_event_t /*unused*/, const json& /*unused*/) noexcept const json j_array = json::parse(s_array, [](int /*unused*/, json::parse_event_t /*unused*/, const json& /*unused*/) noexcept
{ {
return true; return true;
}); });
@@ -1483,7 +1483,7 @@ TEST_CASE("parser class")
SECTION("filter specific element") SECTION("filter specific element")
{ {
json j_object = json::parse(s_object, [](int /*unused*/, json::parse_event_t event, const json & j) noexcept const json j_object = json::parse(s_object, [](int /*unused*/, json::parse_event_t event, const json & j) noexcept
{ {
// filter all number(2) elements // filter all number(2) elements
return event != json::parse_event_t::value || j != json(2); return event != json::parse_event_t::value || j != json(2);
@@ -1491,7 +1491,7 @@ TEST_CASE("parser class")
CHECK (j_object == json({{"bar", {{"baz", 1}}}})); CHECK (j_object == json({{"bar", {{"baz", 1}}}}));
json j_array = json::parse(s_array, [](int /*unused*/, json::parse_event_t event, const json & j) noexcept const json j_array = json::parse(s_array, [](int /*unused*/, json::parse_event_t event, const json & j) noexcept
{ {
return event != json::parse_event_t::value || j != json(2); return event != json::parse_event_t::value || j != json(2);
}); });
@@ -1501,7 +1501,7 @@ TEST_CASE("parser class")
SECTION("filter object in array") SECTION("filter object in array")
{ {
json j_filtered1 = json::parse(structured_array, [](int /*unused*/, json::parse_event_t e, const json & parsed) const json j_filtered1 = json::parse(structured_array, [](int /*unused*/, json::parse_event_t e, const json & parsed)
{ {
return !(e == json::parse_event_t::object_end && parsed.contains("foo")); return !(e == json::parse_event_t::object_end && parsed.contains("foo"));
}); });
@@ -1510,7 +1510,7 @@ TEST_CASE("parser class")
CHECK (j_filtered1.size() == 2); CHECK (j_filtered1.size() == 2);
CHECK (j_filtered1 == json({1, {{"qux", "baz"}}})); CHECK (j_filtered1 == json({1, {{"qux", "baz"}}}));
json j_filtered2 = json::parse(structured_array, [](int /*unused*/, json::parse_event_t e, const json& /*parsed*/) noexcept const json j_filtered2 = json::parse(structured_array, [](int /*unused*/, json::parse_event_t e, const json& /*parsed*/) noexcept
{ {
return e != json::parse_event_t::object_end; return e != json::parse_event_t::object_end;
}); });
@@ -1525,7 +1525,7 @@ TEST_CASE("parser class")
SECTION("first closing event") SECTION("first closing event")
{ {
{ {
json j_object = json::parse(s_object, [](int /*unused*/, json::parse_event_t e, const json& /*unused*/) noexcept const json j_object = json::parse(s_object, [](int /*unused*/, json::parse_event_t e, const json& /*unused*/) noexcept
{ {
static bool first = true; static bool first = true;
if (e == json::parse_event_t::object_end && first) if (e == json::parse_event_t::object_end && first)
@@ -1542,7 +1542,7 @@ TEST_CASE("parser class")
} }
{ {
json j_array = json::parse(s_array, [](int /*unused*/, json::parse_event_t e, const json& /*unused*/) noexcept const json j_array = json::parse(s_array, [](int /*unused*/, json::parse_event_t e, const json& /*unused*/) noexcept
{ {
static bool first = true; static bool first = true;
if (e == json::parse_event_t::array_end && first) if (e == json::parse_event_t::array_end && first)
@@ -1566,13 +1566,13 @@ TEST_CASE("parser class")
// object and array is discarded only after the closing character // object and array is discarded only after the closing character
// has been read // has been read
json j_empty_object = json::parse("{}", [](int /*unused*/, json::parse_event_t e, const json& /*unused*/) noexcept const json j_empty_object = json::parse("{}", [](int /*unused*/, json::parse_event_t e, const json& /*unused*/) noexcept
{ {
return e != json::parse_event_t::object_end; return e != json::parse_event_t::object_end;
}); });
CHECK(j_empty_object == json()); CHECK(j_empty_object == json());
json j_empty_array = json::parse("[]", [](int /*unused*/, json::parse_event_t e, const json& /*unused*/) noexcept const json j_empty_array = json::parse("[]", [](int /*unused*/, json::parse_event_t e, const json& /*unused*/) noexcept
{ {
return e != json::parse_event_t::array_end; return e != json::parse_event_t::array_end;
}); });
+2 -2
View File
@@ -576,7 +576,7 @@ TEST_CASE("lexicographical comparison operators")
[1,2,[3,4,5],4,5] [1,2,[3,4,5],4,5]
)"; )";
json j_object = json::parse(s_object, [](int /*unused*/, json::parse_event_t /*unused*/, const json & j) noexcept const json j_object = json::parse(s_object, [](int /*unused*/, json::parse_event_t /*unused*/, const json & j) noexcept
{ {
// filter all number(2) elements // filter all number(2) elements
return j != json(2); return j != json(2);
@@ -584,7 +584,7 @@ TEST_CASE("lexicographical comparison operators")
CHECK (j_object == json({{"bar", {{"baz", 1}}}})); CHECK (j_object == json({{"bar", {{"baz", 1}}}}));
json j_array = json::parse(s_array, [](int /*unused*/, json::parse_event_t /*unused*/, const json & j) noexcept const json j_array = json::parse(s_array, [](int /*unused*/, json::parse_event_t /*unused*/, const json & j) noexcept
{ {
return j != json(2); return j != json(2);
}); });
+4 -4
View File
@@ -779,7 +779,7 @@ TEST_CASE("constructors")
SECTION("integer literal with u suffix") SECTION("integer literal with u suffix")
{ {
json j(42u); const json j(42u);
CHECK(j.type() == json::value_t::number_unsigned); CHECK(j.type() == json::value_t::number_unsigned);
CHECK(j == j_unsigned_reference); CHECK(j == j_unsigned_reference);
} }
@@ -793,7 +793,7 @@ TEST_CASE("constructors")
SECTION("integer literal with ul suffix") SECTION("integer literal with ul suffix")
{ {
json j(42ul); const json j(42ul);
CHECK(j.type() == json::value_t::number_unsigned); CHECK(j.type() == json::value_t::number_unsigned);
CHECK(j == j_unsigned_reference); CHECK(j == j_unsigned_reference);
} }
@@ -807,7 +807,7 @@ TEST_CASE("constructors")
SECTION("integer literal with ull suffix") SECTION("integer literal with ull suffix")
{ {
json j(42ull); const json j(42ull);
CHECK(j.type() == json::value_t::number_unsigned); CHECK(j.type() == json::value_t::number_unsigned);
CHECK(j == j_unsigned_reference); CHECK(j == j_unsigned_reference);
} }
@@ -1362,7 +1362,7 @@ TEST_CASE("constructors")
{ {
{ {
json jarray = {1, 2, 3, 4, 5}; json jarray = {1, 2, 3, 4, 5};
json j_new(jarray.begin(), jarray.begin()); const json j_new(jarray.begin(), jarray.begin());
CHECK(j_new == json::array()); CHECK(j_new == json::array());
} }
{ {
+18 -18
View File
@@ -17,63 +17,63 @@ TEST_CASE("other constructors and destructor")
{ {
SECTION("object") SECTION("object")
{ {
json j {{"foo", 1}, {"bar", false}}; const json j {{"foo", 1}, {"bar", false}};
json k(j); // NOLINT(performance-unnecessary-copy-initialization) json k(j); // NOLINT(performance-unnecessary-copy-initialization)
CHECK(j == k); CHECK(j == k);
} }
SECTION("array") SECTION("array")
{ {
json j {"foo", 1, 42.23, false}; const json j {"foo", 1, 42.23, false};
json k(j); // NOLINT(performance-unnecessary-copy-initialization) json k(j); // NOLINT(performance-unnecessary-copy-initialization)
CHECK(j == k); CHECK(j == k);
} }
SECTION("null") SECTION("null")
{ {
json j(nullptr); const json j(nullptr);
json k(j); // NOLINT(performance-unnecessary-copy-initialization) json k(j); // NOLINT(performance-unnecessary-copy-initialization)
CHECK(j == k); CHECK(j == k);
} }
SECTION("boolean") SECTION("boolean")
{ {
json j(true); const json j(true);
json k(j); // NOLINT(performance-unnecessary-copy-initialization) json k(j); // NOLINT(performance-unnecessary-copy-initialization)
CHECK(j == k); CHECK(j == k);
} }
SECTION("string") SECTION("string")
{ {
json j("Hello world"); const json j("Hello world");
json k(j); // NOLINT(performance-unnecessary-copy-initialization) json k(j); // NOLINT(performance-unnecessary-copy-initialization)
CHECK(j == k); CHECK(j == k);
} }
SECTION("number (integer)") SECTION("number (integer)")
{ {
json j(42); const json j(42);
json k(j); // NOLINT(performance-unnecessary-copy-initialization) json k(j); // NOLINT(performance-unnecessary-copy-initialization)
CHECK(j == k); CHECK(j == k);
} }
SECTION("number (unsigned)") SECTION("number (unsigned)")
{ {
json j(42u); const json j(42u);
json k(j); // NOLINT(performance-unnecessary-copy-initialization) json k(j); // NOLINT(performance-unnecessary-copy-initialization)
CHECK(j == k); CHECK(j == k);
} }
SECTION("number (floating-point)") SECTION("number (floating-point)")
{ {
json j(42.23); const json j(42.23);
json k(j); // NOLINT(performance-unnecessary-copy-initialization) json k(j); // NOLINT(performance-unnecessary-copy-initialization)
CHECK(j == k); CHECK(j == k);
} }
SECTION("binary") SECTION("binary")
{ {
json j = json::binary({1, 2, 3}); const json j = json::binary({1, 2, 3});
json k(j); // NOLINT(performance-unnecessary-copy-initialization) json k(j); // NOLINT(performance-unnecessary-copy-initialization)
CHECK(j == k); CHECK(j == k);
} }
@@ -92,7 +92,7 @@ TEST_CASE("other constructors and destructor")
{ {
SECTION("object") SECTION("object")
{ {
json j {{"foo", 1}, {"bar", false}}; const json j {{"foo", 1}, {"bar", false}};
json k; json k;
k = j; k = j;
CHECK(j == k); CHECK(j == k);
@@ -100,7 +100,7 @@ TEST_CASE("other constructors and destructor")
SECTION("array") SECTION("array")
{ {
json j {"foo", 1, 42.23, false}; const json j {"foo", 1, 42.23, false};
json k; json k;
k = j; k = j;
CHECK(j == k); CHECK(j == k);
@@ -108,7 +108,7 @@ TEST_CASE("other constructors and destructor")
SECTION("null") SECTION("null")
{ {
json j(nullptr); const json j(nullptr);
json k; json k;
k = j; k = j;
CHECK(j == k); CHECK(j == k);
@@ -116,7 +116,7 @@ TEST_CASE("other constructors and destructor")
SECTION("boolean") SECTION("boolean")
{ {
json j(true); const json j(true);
json k; json k;
k = j; k = j;
CHECK(j == k); CHECK(j == k);
@@ -124,7 +124,7 @@ TEST_CASE("other constructors and destructor")
SECTION("string") SECTION("string")
{ {
json j("Hello world"); const json j("Hello world");
json k; json k;
k = j; k = j;
CHECK(j == k); CHECK(j == k);
@@ -132,7 +132,7 @@ TEST_CASE("other constructors and destructor")
SECTION("number (integer)") SECTION("number (integer)")
{ {
json j(42); const json j(42);
json k; json k;
k = j; k = j;
CHECK(j == k); CHECK(j == k);
@@ -140,7 +140,7 @@ TEST_CASE("other constructors and destructor")
SECTION("number (unsigned)") SECTION("number (unsigned)")
{ {
json j(42u); const json j(42u);
json k; json k;
k = j; k = j;
CHECK(j == k); CHECK(j == k);
@@ -148,7 +148,7 @@ TEST_CASE("other constructors and destructor")
SECTION("number (floating-point)") SECTION("number (floating-point)")
{ {
json j(42.23); const json j(42.23);
json k; json k;
k = j; k = j;
CHECK(j == k); CHECK(j == k);
@@ -156,7 +156,7 @@ TEST_CASE("other constructors and destructor")
SECTION("binary") SECTION("binary")
{ {
json j = json::binary({1, 2, 3}); const json j = json::binary({1, 2, 3});
json k; json k;
k = j; k = j;
CHECK(j == k); CHECK(j == k);
+5 -5
View File
@@ -179,9 +179,9 @@ TEST_CASE("convenience functions")
SECTION("std::string") SECTION("std::string")
{ {
std::string str1 = concat(hello_iter, world, '!'); const std::string str1 = concat(hello_iter, world, '!');
std::string str2 = concat(hello_data, world, '!'); const std::string str2 = concat(hello_data, world, '!');
std::string str3 = concat("Hello, ", world, '!'); const std::string str3 = concat("Hello, ", world, '!');
CHECK(str1 == expected); CHECK(str1 == expected);
CHECK(str2 == expected); CHECK(str2 == expected);
@@ -190,14 +190,14 @@ TEST_CASE("convenience functions")
SECTION("alt_string_iter") SECTION("alt_string_iter")
{ {
alt_string_iter str = concat<alt_string_iter>(hello_iter, world, '!'); const alt_string_iter str = concat<alt_string_iter>(hello_iter, world, '!');
CHECK(str.impl == expected); CHECK(str.impl == expected);
} }
SECTION("alt_string_data") SECTION("alt_string_data")
{ {
alt_string_data str = concat<alt_string_data>(hello_data, world, '!'); const alt_string_data str = concat<alt_string_data>(hello_data, world, '!');
CHECK(str.impl == expected); CHECK(str.impl == expected);
} }
+2 -2
View File
@@ -1514,7 +1514,7 @@ TEST_CASE("value conversion")
SECTION("std::map (array of pairs)") SECTION("std::map (array of pairs)")
{ {
std::map<int, int> m{{0, 1}, {1, 2}, {2, 3}}; const std::map<int, int> m{{0, 1}, {1, 2}, {2, 3}};
json const j6 = m; json const j6 = m;
auto m2 = j6.get<std::map<int, int>>(); auto m2 = j6.get<std::map<int, int>>();
@@ -1539,7 +1539,7 @@ TEST_CASE("value conversion")
SECTION("std::unordered_map (array of pairs)") SECTION("std::unordered_map (array of pairs)")
{ {
std::unordered_map<int, int> m{{0, 1}, {1, 2}, {2, 3}}; const std::unordered_map<int, int> m{{0, 1}, {1, 2}, {2, 3}};
json const j6 = m; json const j6 = m;
auto m2 = j6.get<std::unordered_map<int, int>>(); auto m2 = j6.get<std::unordered_map<int, int>>();
+3 -3
View File
@@ -227,7 +227,7 @@ TEST_CASE("deserialization")
ss1 << R"(["foo",1,2,3,false,{"one":1}])"; ss1 << R"(["foo",1,2,3,false,{"one":1}])";
ss2 << R"(["foo",1,2,3,false,{"one":1}])"; ss2 << R"(["foo",1,2,3,false,{"one":1}])";
ss3 << R"(["foo",1,2,3,false,{"one":1}])"; ss3 << R"(["foo",1,2,3,false,{"one":1}])";
json j = json::parse(ss1); const json j = json::parse(ss1);
CHECK(json::accept(ss2)); CHECK(json::accept(ss2));
CHECK(j == json({"foo", 1, 2, 3, false, {{"one", 1}}})); CHECK(j == json({"foo", 1, 2, 3, false, {{"one", 1}}}));
@@ -246,7 +246,7 @@ TEST_CASE("deserialization")
SECTION("string literal") SECTION("string literal")
{ {
const auto* s = R"(["foo",1,2,3,false,{"one":1}])"; const auto* s = R"(["foo",1,2,3,false,{"one":1}])";
json j = json::parse(s); const json j = json::parse(s);
CHECK(json::accept(s)); CHECK(json::accept(s));
CHECK(j == json({"foo", 1, 2, 3, false, {{"one", 1}}})); CHECK(j == json({"foo", 1, 2, 3, false, {{"one", 1}}}));
@@ -265,7 +265,7 @@ TEST_CASE("deserialization")
SECTION("string_t") SECTION("string_t")
{ {
json::string_t const s = R"(["foo",1,2,3,false,{"one":1}])"; json::string_t const s = R"(["foo",1,2,3,false,{"one":1}])";
json j = json::parse(s); const json j = json::parse(s);
CHECK(json::accept(s)); CHECK(json::accept(s));
CHECK(j == json({"foo", 1, 2, 3, false, {{"one", 1}}})); CHECK(j == json({"foo", 1, 2, 3, false, {{"one", 1}}}));
+27 -27
View File
@@ -16,7 +16,7 @@ TEST_CASE("element access 1")
SECTION("array") SECTION("array")
{ {
json j = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}}; json j = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
const json j_const = j; const json j_const = j; // NOLINT(performance-unnecessary-copy-initialization)
SECTION("access specified element with bounds checking") SECTION("access specified element with bounds checking")
{ {
@@ -289,13 +289,13 @@ TEST_CASE("element access 1")
{ {
{ {
json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}}; json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
json::iterator it2 = jarray.erase(jarray.begin(), jarray.end()); const json::iterator it2 = jarray.erase(jarray.begin(), jarray.end());
CHECK(jarray == json::array()); CHECK(jarray == json::array());
CHECK(it2 == jarray.end()); CHECK(it2 == jarray.end());
} }
{ {
json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}}; json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
json::const_iterator it2 = jarray.erase(jarray.cbegin(), jarray.cend()); const json::const_iterator it2 = jarray.erase(jarray.cbegin(), jarray.cend());
CHECK(jarray == json::array()); CHECK(jarray == json::array());
CHECK(it2 == jarray.cend()); CHECK(it2 == jarray.cend());
} }
@@ -537,13 +537,13 @@ TEST_CASE("element access 1")
{ {
{ {
json j = "foo"; json j = "foo";
json::iterator it = j.erase(j.begin()); const json::iterator it = j.erase(j.begin());
CHECK(j.type() == json::value_t::null); CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); CHECK(it == j.end());
} }
{ {
json j = "bar"; json j = "bar";
json::const_iterator it = j.erase(j.cbegin()); const json::const_iterator it = j.erase(j.cbegin());
CHECK(j.type() == json::value_t::null); CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); CHECK(it == j.end());
} }
@@ -553,13 +553,13 @@ TEST_CASE("element access 1")
{ {
{ {
json j = false; json j = false;
json::iterator it = j.erase(j.begin()); const json::iterator it = j.erase(j.begin());
CHECK(j.type() == json::value_t::null); CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); CHECK(it == j.end());
} }
{ {
json j = true; json j = true;
json::const_iterator it = j.erase(j.cbegin()); const json::const_iterator it = j.erase(j.cbegin());
CHECK(j.type() == json::value_t::null); CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); CHECK(it == j.end());
} }
@@ -569,13 +569,13 @@ TEST_CASE("element access 1")
{ {
{ {
json j = 17; json j = 17;
json::iterator it = j.erase(j.begin()); const json::iterator it = j.erase(j.begin());
CHECK(j.type() == json::value_t::null); CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); CHECK(it == j.end());
} }
{ {
json j = 17; json j = 17;
json::const_iterator it = j.erase(j.cbegin()); const json::const_iterator it = j.erase(j.cbegin());
CHECK(j.type() == json::value_t::null); CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); CHECK(it == j.end());
} }
@@ -585,13 +585,13 @@ TEST_CASE("element access 1")
{ {
{ {
json j = 17u; json j = 17u;
json::iterator it = j.erase(j.begin()); const json::iterator it = j.erase(j.begin());
CHECK(j.type() == json::value_t::null); CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); CHECK(it == j.end());
} }
{ {
json j = 17u; json j = 17u;
json::const_iterator it = j.erase(j.cbegin()); const json::const_iterator it = j.erase(j.cbegin());
CHECK(j.type() == json::value_t::null); CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); CHECK(it == j.end());
} }
@@ -601,13 +601,13 @@ TEST_CASE("element access 1")
{ {
{ {
json j = 23.42; json j = 23.42;
json::iterator it = j.erase(j.begin()); const json::iterator it = j.erase(j.begin());
CHECK(j.type() == json::value_t::null); CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); CHECK(it == j.end());
} }
{ {
json j = 23.42; json j = 23.42;
json::const_iterator it = j.erase(j.cbegin()); const json::const_iterator it = j.erase(j.cbegin());
CHECK(j.type() == json::value_t::null); CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); CHECK(it == j.end());
} }
@@ -617,13 +617,13 @@ TEST_CASE("element access 1")
{ {
{ {
json j = json::binary({1, 2, 3}); json j = json::binary({1, 2, 3});
json::iterator it = j.erase(j.begin()); const json::iterator it = j.erase(j.begin());
CHECK(j.type() == json::value_t::null); CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); CHECK(it == j.end());
} }
{ {
json j = json::binary({1, 2, 3}); json j = json::binary({1, 2, 3});
json::const_iterator it = j.erase(j.cbegin()); const json::const_iterator it = j.erase(j.cbegin());
CHECK(j.type() == json::value_t::null); CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); CHECK(it == j.end());
} }
@@ -711,13 +711,13 @@ TEST_CASE("element access 1")
{ {
{ {
json j = "foo"; json j = "foo";
json::iterator it = j.erase(j.begin(), j.end()); const json::iterator it = j.erase(j.begin(), j.end());
CHECK(j.type() == json::value_t::null); CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); CHECK(it == j.end());
} }
{ {
json j = "bar"; json j = "bar";
json::const_iterator it = j.erase(j.cbegin(), j.cend()); const json::const_iterator it = j.erase(j.cbegin(), j.cend());
CHECK(j.type() == json::value_t::null); CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); CHECK(it == j.end());
} }
@@ -727,13 +727,13 @@ TEST_CASE("element access 1")
{ {
{ {
json j = false; json j = false;
json::iterator it = j.erase(j.begin(), j.end()); const json::iterator it = j.erase(j.begin(), j.end());
CHECK(j.type() == json::value_t::null); CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); CHECK(it == j.end());
} }
{ {
json j = true; json j = true;
json::const_iterator it = j.erase(j.cbegin(), j.cend()); const json::const_iterator it = j.erase(j.cbegin(), j.cend());
CHECK(j.type() == json::value_t::null); CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); CHECK(it == j.end());
} }
@@ -743,13 +743,13 @@ TEST_CASE("element access 1")
{ {
{ {
json j = 17; json j = 17;
json::iterator it = j.erase(j.begin(), j.end()); const json::iterator it = j.erase(j.begin(), j.end());
CHECK(j.type() == json::value_t::null); CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); CHECK(it == j.end());
} }
{ {
json j = 17; json j = 17;
json::const_iterator it = j.erase(j.cbegin(), j.cend()); const json::const_iterator it = j.erase(j.cbegin(), j.cend());
CHECK(j.type() == json::value_t::null); CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); CHECK(it == j.end());
} }
@@ -759,13 +759,13 @@ TEST_CASE("element access 1")
{ {
{ {
json j = 17u; json j = 17u;
json::iterator it = j.erase(j.begin(), j.end()); const json::iterator it = j.erase(j.begin(), j.end());
CHECK(j.type() == json::value_t::null); CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); CHECK(it == j.end());
} }
{ {
json j = 17u; json j = 17u;
json::const_iterator it = j.erase(j.cbegin(), j.cend()); const json::const_iterator it = j.erase(j.cbegin(), j.cend());
CHECK(j.type() == json::value_t::null); CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); CHECK(it == j.end());
} }
@@ -775,13 +775,13 @@ TEST_CASE("element access 1")
{ {
{ {
json j = 23.42; json j = 23.42;
json::iterator it = j.erase(j.begin(), j.end()); const json::iterator it = j.erase(j.begin(), j.end());
CHECK(j.type() == json::value_t::null); CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); CHECK(it == j.end());
} }
{ {
json j = 23.42; json j = 23.42;
json::const_iterator it = j.erase(j.cbegin(), j.cend()); const json::const_iterator it = j.erase(j.cbegin(), j.cend());
CHECK(j.type() == json::value_t::null); CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); CHECK(it == j.end());
} }
@@ -791,13 +791,13 @@ TEST_CASE("element access 1")
{ {
{ {
json j = json::binary({1, 2, 3}); json j = json::binary({1, 2, 3});
json::iterator it = j.erase(j.begin(), j.end()); const json::iterator it = j.erase(j.begin(), j.end());
CHECK(j.type() == json::value_t::null); CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); CHECK(it == j.end());
} }
{ {
json j = json::binary({1, 2, 3}); json j = json::binary({1, 2, 3});
json::const_iterator it = j.erase(j.cbegin(), j.cend()); const json::const_iterator it = j.erase(j.cbegin(), j.cend());
CHECK(j.type() == json::value_t::null); CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); CHECK(it == j.end());
} }
+2 -2
View File
@@ -847,13 +847,13 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j
{ {
{ {
Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}}; Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}};
typename Json::iterator it2 = jobject.erase(jobject.begin(), jobject.end()); const typename Json::iterator it2 = jobject.erase(jobject.begin(), jobject.end());
CHECK(jobject == Json::object()); CHECK(jobject == Json::object());
CHECK(it2 == jobject.end()); CHECK(it2 == jobject.end());
} }
{ {
Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}}; Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}};
typename Json::const_iterator it2 = jobject.erase(jobject.cbegin(), jobject.cend()); const typename Json::const_iterator it2 = jobject.erase(jobject.cbegin(), jobject.cend());
CHECK(jobject == Json::object()); CHECK(jobject == Json::object());
CHECK(it2 == jobject.cend()); CHECK(it2 == jobject.cend());
} }
+15 -15
View File
@@ -278,8 +278,8 @@ TEST_CASE("object inspection")
std::ifstream f_escaped(TEST_DATA_DIRECTORY "/json_nlohmann_tests/all_unicode_ascii.json"); std::ifstream f_escaped(TEST_DATA_DIRECTORY "/json_nlohmann_tests/all_unicode_ascii.json");
std::ifstream f_unescaped(TEST_DATA_DIRECTORY "/json_nlohmann_tests/all_unicode.json"); std::ifstream f_unescaped(TEST_DATA_DIRECTORY "/json_nlohmann_tests/all_unicode.json");
json j1 = json::parse(f_escaped); const json j1 = json::parse(f_escaped);
json j2 = json::parse(f_unescaped); const json j2 = json::parse(f_unescaped);
CHECK(j1 == j2); CHECK(j1 == j2);
} }
@@ -289,10 +289,10 @@ TEST_CASE("object inspection")
std::ifstream f_unescaped(TEST_DATA_DIRECTORY "/json_nlohmann_tests/all_unicode.json"); std::ifstream f_unescaped(TEST_DATA_DIRECTORY "/json_nlohmann_tests/all_unicode.json");
json const value = json::parse(f_unescaped); json const value = json::parse(f_unescaped);
std::string text = value.dump(4, ' ', true); const std::string text = value.dump(4, ' ', true);
std::string expected((std::istreambuf_iterator<char>(f_escaped)), const std::string expected((std::istreambuf_iterator<char>(f_escaped)),
std::istreambuf_iterator<char>()); std::istreambuf_iterator<char>());
CHECK(text == expected); CHECK(text == expected);
} }
} }
@@ -333,7 +333,7 @@ TEST_CASE("object inspection")
}) })
{ {
json const j1 = json::parse(s); json const j1 = json::parse(s);
std::string s1 = j1.dump(); const std::string s1 = j1.dump();
json const j2 = json::parse(s1); json const j2 = json::parse(s1);
std::string s2 = j2.dump(); std::string s2 = j2.dump();
CHECK(s1 == s2); CHECK(s1 == s2);
@@ -396,63 +396,63 @@ TEST_CASE("object inspection")
SECTION("null") SECTION("null")
{ {
json const j = nullptr; json const j = nullptr;
json::value_t t = j; const json::value_t t = j;
CHECK(t == j.type()); CHECK(t == j.type());
} }
SECTION("object") SECTION("object")
{ {
json const j = {{"foo", "bar"}}; json const j = {{"foo", "bar"}};
json::value_t t = j; const json::value_t t = j;
CHECK(t == j.type()); CHECK(t == j.type());
} }
SECTION("array") SECTION("array")
{ {
json const j = {1, 2, 3, 4}; json const j = {1, 2, 3, 4};
json::value_t t = j; const json::value_t t = j;
CHECK(t == j.type()); CHECK(t == j.type());
} }
SECTION("boolean") SECTION("boolean")
{ {
json const j = true; json const j = true;
json::value_t t = j; const json::value_t t = j;
CHECK(t == j.type()); CHECK(t == j.type());
} }
SECTION("string") SECTION("string")
{ {
json const j = "Hello world"; json const j = "Hello world";
json::value_t t = j; const json::value_t t = j;
CHECK(t == j.type()); CHECK(t == j.type());
} }
SECTION("number (integer)") SECTION("number (integer)")
{ {
json const j = 23; json const j = 23;
json::value_t t = j; const json::value_t t = j;
CHECK(t == j.type()); CHECK(t == j.type());
} }
SECTION("number (unsigned)") SECTION("number (unsigned)")
{ {
json const j = 23u; json const j = 23u;
json::value_t t = j; const json::value_t t = j;
CHECK(t == j.type()); CHECK(t == j.type());
} }
SECTION("number (floating-point)") SECTION("number (floating-point)")
{ {
json const j = 42.23; json const j = 42.23;
json::value_t t = j; const json::value_t t = j;
CHECK(t == j.type()); CHECK(t == j.type());
} }
SECTION("binary") SECTION("binary")
{ {
json const j = json::binary({}); json const j = json::binary({});
json::value_t t = j; const json::value_t t = j;
CHECK(t == j.type()); CHECK(t == j.type());
} }
} }
+9 -9
View File
@@ -18,10 +18,10 @@ TEST_CASE("iterators 1")
{ {
SECTION("uninitialized") SECTION("uninitialized")
{ {
json::iterator it; json::iterator it; // NOLINT(misc-const-correctness)
CHECK(it.m_object == nullptr); CHECK(it.m_object == nullptr);
json::const_iterator cit; json::const_iterator cit; // NOLINT(misc-const-correctness)
CHECK(cit.m_object == nullptr); CHECK(cit.m_object == nullptr);
} }
@@ -1498,46 +1498,46 @@ TEST_CASE("iterators 1")
SECTION("json + begin/end") SECTION("json + begin/end")
{ {
json::iterator it = j.begin(); const json::iterator it = j.begin();
CHECK(it == j.end()); CHECK(it == j.end());
} }
SECTION("const json + begin/end") SECTION("const json + begin/end")
{ {
json::const_iterator it_begin = j_const.begin(); const json::const_iterator it_begin = j_const.begin();
json::const_iterator it_end = j_const.end(); json::const_iterator it_end = j_const.end();
CHECK(it_begin == it_end); CHECK(it_begin == it_end);
} }
SECTION("json + cbegin/cend") SECTION("json + cbegin/cend")
{ {
json::const_iterator it_begin = j.cbegin(); const json::const_iterator it_begin = j.cbegin();
json::const_iterator it_end = j.cend(); json::const_iterator it_end = j.cend();
CHECK(it_begin == it_end); CHECK(it_begin == it_end);
} }
SECTION("const json + cbegin/cend") SECTION("const json + cbegin/cend")
{ {
json::const_iterator it_begin = j_const.cbegin(); const json::const_iterator it_begin = j_const.cbegin();
json::const_iterator it_end = j_const.cend(); json::const_iterator it_end = j_const.cend();
CHECK(it_begin == it_end); CHECK(it_begin == it_end);
} }
SECTION("json + rbegin/rend") SECTION("json + rbegin/rend")
{ {
json::reverse_iterator it = j.rbegin(); const json::reverse_iterator it = j.rbegin();
CHECK(it == j.rend()); CHECK(it == j.rend());
} }
SECTION("json + crbegin/crend") SECTION("json + crbegin/crend")
{ {
json::const_reverse_iterator it = j.crbegin(); const json::const_reverse_iterator it = j.crbegin();
CHECK(it == j.crend()); CHECK(it == j.crend());
} }
SECTION("const json + crbegin/crend") SECTION("const json + crbegin/crend")
{ {
json::const_reverse_iterator it = j_const.crbegin(); const json::const_reverse_iterator it = j_const.crbegin();
CHECK(it == j_const.crend()); CHECK(it == j_const.crend());
} }
+6 -6
View File
@@ -24,9 +24,9 @@ TEST_CASE("JSON patch")
SECTION("4. Operations") SECTION("4. Operations")
{ {
// the ordering of members in JSON objects is not significant: // the ordering of members in JSON objects is not significant:
json op1 = R"({ "op": "add", "path": "/a/b/c", "value": "foo" })"_json; const json op1 = R"({ "op": "add", "path": "/a/b/c", "value": "foo" })"_json;
json op2 = R"({ "path": "/a/b/c", "op": "add", "value": "foo" })"_json; const json op2 = R"({ "path": "/a/b/c", "op": "add", "value": "foo" })"_json;
json op3 = R"({ "value": "foo", "path": "/a/b/c", "op": "add" })"_json; const json op3 = R"({ "value": "foo", "path": "/a/b/c", "op": "add" })"_json;
// check if the operation objects are equivalent // check if the operation objects are equivalent
CHECK(op1 == op2); CHECK(op1 == op2);
@@ -642,12 +642,12 @@ TEST_CASE("JSON patch")
)"_json; )"_json;
// apply the patch // apply the patch
json target = source.patch(p1); const json target = source.patch(p1);
// target = { "D": "Berlin", "F": "Paris", "GB": "London" } // target = { "D": "Berlin", "F": "Paris", "GB": "London" }
CHECK(target == R"({ "D": "Berlin", "F": "Paris", "GB": "London" })"_json); CHECK(target == R"({ "D": "Berlin", "F": "Paris", "GB": "London" })"_json);
// create a diff from two JSONs // create a diff from two JSONs
json p2 = json::diff(target, source); // NOLINT(readability-suspicious-call-argument) const json p2 = json::diff(target, source); // NOLINT(readability-suspicious-call-argument)
// p2 = [{"op": "delete", "path": "/GB"}] // p2 = [{"op": "delete", "path": "/GB"}]
CHECK(p2 == R"([{"op":"remove","path":"/GB"}])"_json); CHECK(p2 == R"([{"op":"remove","path":"/GB"}])"_json);
} }
@@ -666,7 +666,7 @@ TEST_CASE("JSON patch")
j["/2/en"_json_pointer] = "ugly"; j["/2/en"_json_pointer] = "ugly";
CHECK(j == R"(["good","bad",{"en":"ugly","it":"cattivo"}])"_json); CHECK(j == R"(["good","bad",{"en":"ugly","it":"cattivo"}])"_json);
json flat = j.flatten(); const json flat = j.flatten();
CHECK(flat == R"({"/0":"good","/1":"bad","/2/en":"ugly","/2/it":"cattivo"})"_json); CHECK(flat == R"({"/0":"good","/1":"bad","/2/en":"ugly","/2/it":"cattivo"})"_json);
} }
} }
+11 -9
View File
@@ -1606,7 +1606,7 @@ TEST_CASE("single MessagePack roundtrip")
// parse JSON file // parse JSON file
std::ifstream f_json(filename); std::ifstream f_json(filename);
json j1 = json::parse(f_json); const json j1 = json::parse(f_json);
// parse MessagePack file // parse MessagePack file
auto packed = utils::read_binary_file(filename + ".msgpack"); auto packed = utils::read_binary_file(filename + ".msgpack");
@@ -1817,7 +1817,7 @@ TEST_CASE("MessagePack roundtrips" * doctest::skip())
INFO_WITH_TEMP(filename + ": std::vector<uint8_t>"); INFO_WITH_TEMP(filename + ": std::vector<uint8_t>");
// parse JSON file // parse JSON file
std::ifstream f_json(filename); std::ifstream f_json(filename);
json j1 = json::parse(f_json); const json j1 = json::parse(f_json);
// parse MessagePack file // parse MessagePack file
auto packed = utils::read_binary_file(filename + ".msgpack"); auto packed = utils::read_binary_file(filename + ".msgpack");
@@ -1832,7 +1832,7 @@ TEST_CASE("MessagePack roundtrips" * doctest::skip())
INFO_WITH_TEMP(filename + ": std::ifstream"); INFO_WITH_TEMP(filename + ": std::ifstream");
// parse JSON file // parse JSON file
std::ifstream f_json(filename); std::ifstream f_json(filename);
json j1 = json::parse(f_json); const json j1 = json::parse(f_json);
// parse MessagePack file // parse MessagePack file
std::ifstream f_msgpack(filename + ".msgpack", std::ios::binary); std::ifstream f_msgpack(filename + ".msgpack", std::ios::binary);
@@ -1847,7 +1847,7 @@ TEST_CASE("MessagePack roundtrips" * doctest::skip())
INFO_WITH_TEMP(filename + ": uint8_t* and size"); INFO_WITH_TEMP(filename + ": uint8_t* and size");
// parse JSON file // parse JSON file
std::ifstream f_json(filename); std::ifstream f_json(filename);
json j1 = json::parse(f_json); const json j1 = json::parse(f_json);
// parse MessagePack file // parse MessagePack file
auto packed = utils::read_binary_file(filename + ".msgpack"); auto packed = utils::read_binary_file(filename + ".msgpack");
@@ -1914,10 +1914,12 @@ TEST_CASE("MessagePack with std::byte")
SECTION("empty vector") SECTION("empty vector")
{ {
const std::vector<std::byte> empty_data; const std::vector<std::byte> empty_data;
CHECK_THROWS_WITH_AS([&]() { CHECK_THROWS_WITH_AS([&]()
{
[[maybe_unused]] auto result = json::from_msgpack(empty_data); [[maybe_unused]] auto result = json::from_msgpack(empty_data);
return true; return true;
}(), }
(),
"[json.exception.parse_error.110] parse error at byte 1: syntax error while parsing MessagePack value: unexpected end of input", "[json.exception.parse_error.110] parse error at byte 1: syntax error while parsing MessagePack value: unexpected end of input",
json::parse_error&); json::parse_error&);
} }
@@ -1943,11 +1945,11 @@ TEST_CASE("MessagePack with std::byte")
msgpack_data[i] = std::byte(temp[i]); msgpack_data[i] = std::byte(temp[i]);
} }
// Attempt direct deserialization using std::byte input // Attempt direct deserialization using std::byte input
json direct_result = json::from_msgpack(msgpack_data); const json direct_result = json::from_msgpack(msgpack_data);
// Test the workaround approach: reinterpret as unsigned char* and use iterator range // Test the workaround approach: reinterpret as unsigned char* and use iterator range
const auto *const char_start = reinterpret_cast<unsigned char const*>(msgpack_data.data()); const auto* const char_start = reinterpret_cast<unsigned char const*>(msgpack_data.data());
const auto *const char_end = char_start + msgpack_data.size(); const auto* const char_end = char_start + msgpack_data.size();
json workaround_result = json::from_msgpack(char_start, char_end); json workaround_result = json::from_msgpack(char_start, char_end);
// Verify that the final deserialized JSON matches the original JSON // Verify that the final deserialized JSON matches the original JSON
+2 -2
View File
@@ -36,7 +36,7 @@ TEST_CASE("ordered_map")
{ {
std::map<std::string, std::string> m {{"eins", "one"}, {"zwei", "two"}, {"drei", "three"}}; std::map<std::string, std::string> m {{"eins", "one"}, {"zwei", "two"}, {"drei", "three"}};
ordered_map<std::string, std::string> om(m.begin(), m.end()); ordered_map<std::string, std::string> om(m.begin(), m.end());
const auto com = om; const auto com = om; // NOLINT(performance-unnecessary-copy-initialization)
SECTION("with Key&&") SECTION("with Key&&")
{ {
@@ -69,7 +69,7 @@ TEST_CASE("ordered_map")
{ {
std::map<std::string, std::string> m {{"eins", "one"}, {"zwei", "two"}, {"drei", "three"}}; std::map<std::string, std::string> m {{"eins", "one"}, {"zwei", "two"}, {"drei", "three"}};
ordered_map<std::string, std::string> om(m.begin(), m.end()); ordered_map<std::string, std::string> om(m.begin(), m.end());
const auto com = om; const auto com = om; // NOLINT(performance-unnecessary-copy-initialization)
SECTION("with Key&&") SECTION("with Key&&")
{ {
+7 -7
View File
@@ -19,7 +19,7 @@ TEST_CASE("pointer access")
json value = {{"one", 1}, {"two", 2}}; json value = {{"one", 1}, {"two", 2}};
// check if pointers are returned correctly // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); const test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); CHECK(*p1 == value.get<test_type>());
@@ -77,7 +77,7 @@ TEST_CASE("pointer access")
json value = {1, 2, 3, 4}; json value = {1, 2, 3, 4};
// check if pointers are returned correctly // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); const test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); CHECK(*p1 == value.get<test_type>());
@@ -135,7 +135,7 @@ TEST_CASE("pointer access")
json value = "hello"; json value = "hello";
// check if pointers are returned correctly // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); const test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); CHECK(*p1 == value.get<test_type>());
@@ -193,7 +193,7 @@ TEST_CASE("pointer access")
json value = false; json value = false;
// check if pointers are returned correctly // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); const test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); CHECK(*p1 == value.get<test_type>());
@@ -251,7 +251,7 @@ TEST_CASE("pointer access")
json value = 23; json value = 23;
// check if pointers are returned correctly // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); const test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); CHECK(*p1 == value.get<test_type>());
@@ -309,7 +309,7 @@ TEST_CASE("pointer access")
json value = 23u; json value = 23u;
// check if pointers are returned correctly // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); const test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); CHECK(*p1 == value.get<test_type>());
@@ -367,7 +367,7 @@ TEST_CASE("pointer access")
json value = 42.23; json value = 42.23;
// check if pointers are returned correctly // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); const test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == Approx(value.get<test_type>())); CHECK(*p1 == Approx(value.get<test_type>()));
+6 -6
View File
@@ -136,7 +136,7 @@ TEST_CASE("README" * doctest::skip())
j.push_back(true); j.push_back(true);
// comparison // comparison
bool x = (j == R"(["foo", 1, true])"_json); // true const bool x = (j == R"(["foo", 1, true])"_json); // true
CHECK(x == true); CHECK(x == true);
// iterate the array // iterate the array
@@ -154,7 +154,7 @@ TEST_CASE("README" * doctest::skip())
// getter/setter // getter/setter
const auto tmp = j[0].get<std::string>(); // NOLINT(bugprone-unused-local-non-trivial-variable) const auto tmp = j[0].get<std::string>(); // NOLINT(bugprone-unused-local-non-trivial-variable)
j[1] = 42; j[1] = 42;
bool foo{j.at(2)}; const bool foo{j.at(2)};
CHECK(foo == true); CHECK(foo == true);
// other stuff // other stuff
@@ -242,21 +242,21 @@ TEST_CASE("README" * doctest::skip())
// Booleans // Booleans
bool const b1 = true; bool const b1 = true;
json const jb = b1; json const jb = b1;
bool b2{jb}; const bool b2{jb};
CHECK(b2 == true); CHECK(b2 == true);
// numbers // numbers
int const i = 42; int const i = 42;
json const jn = i; json const jn = i;
double f{jn}; const double f{jn};
CHECK(f == 42); CHECK(f == 42);
// etc. // etc.
std::string const vs = js.get<std::string>(); // NOLINT(bugprone-unused-local-non-trivial-variable) std::string const vs = js.get<std::string>(); // NOLINT(bugprone-unused-local-non-trivial-variable)
bool vb = jb.get<bool>(); const bool vb = jb.get<bool>();
CHECK(vb == true); CHECK(vb == true);
int vi = jn.get<int>(); const int vi = jn.get<int>();
CHECK(vi == 42); CHECK(vi == 42);
// etc. // etc.
+16 -16
View File
@@ -122,7 +122,7 @@ TEST_CASE("regression tests 1")
SECTION("escape_doublequote") SECTION("escape_doublequote")
{ {
const auto* s = R"(["\"foo\""])"; const auto* s = R"(["\"foo\""])";
json j = json::parse(s); const json j = json::parse(s);
auto expected = R"(["\"foo\""])"_json; auto expected = R"(["\"foo\""])"_json;
CHECK(j == expected); CHECK(j == expected);
} }
@@ -182,7 +182,7 @@ TEST_CASE("regression tests 1")
j.push_back(t); j.push_back(t);
// maybe this is not the place to test this? // maybe this is not the place to test this?
json j2 = u; const json j2 = u;
auto anon_enum_value = j2.get<decltype(u)>(); auto anon_enum_value = j2.get<decltype(u)>();
CHECK(u == anon_enum_value); CHECK(u == anon_enum_value);
@@ -247,9 +247,9 @@ TEST_CASE("regression tests 1")
auto test = j["Test"].get<std::string>(); auto test = j["Test"].get<std::string>();
CHECK(test == "Test1"); CHECK(test == "Test1");
int number{j["Number"]}; const int number{j["Number"]};
CHECK(number == 100); CHECK(number == 100);
float foo{j["Foo"]}; const float foo{j["Foo"]};
CHECK(static_cast<double>(foo) == Approx(42.42)); CHECK(static_cast<double>(foo) == Approx(42.42));
} }
@@ -371,7 +371,7 @@ TEST_CASE("regression tests 1")
{ {
json o = {{"name", "value"}}; json o = {{"name", "value"}};
std::string s1 = o["name"]; const std::string s1 = o["name"];
CHECK(s1 == "value"); CHECK(s1 == "value");
std::string s2; std::string s2;
@@ -607,8 +607,8 @@ TEST_CASE("regression tests 1")
{"object", {{"key1", 1}, {"key2", 2}}}, {"object", {{"key1", 1}, {"key2", 2}}},
}; };
int at_integer{j.at("/object/key2"_json_pointer)}; const int at_integer{j.at("/object/key2"_json_pointer)};
int val_integer = j.value("/object/key2"_json_pointer, 0); const int val_integer = j.value("/object/key2"_json_pointer, 0);
CHECK(at_integer == val_integer); CHECK(at_integer == val_integer);
} }
@@ -1099,7 +1099,7 @@ TEST_CASE("regression tests 1")
#if JSON_USE_IMPLICIT_CONVERSIONS #if JSON_USE_IMPLICIT_CONVERSIONS
SECTION("issue #464 - VS2017 implicit to std::string conversion fix") SECTION("issue #464 - VS2017 implicit to std::string conversion fix")
{ {
json v = "test"; const json v = "test";
std::string test; std::string test;
test = v; test = v;
CHECK(v == "test"); CHECK(v == "test");
@@ -1109,9 +1109,9 @@ TEST_CASE("regression tests 1")
SECTION("issue #465 - roundtrip error while parsing 1000000000000000010E5") SECTION("issue #465 - roundtrip error while parsing 1000000000000000010E5")
{ {
json const j1 = json::parse("1000000000000000010E5"); json const j1 = json::parse("1000000000000000010E5");
std::string s1 = j1.dump(); const std::string s1 = j1.dump();
json const j2 = json::parse(s1); json const j2 = json::parse(s1);
std::string s2 = j2.dump(); const std::string s2 = j2.dump();
CHECK(s1 == s2); CHECK(s1 == s2);
} }
@@ -1243,7 +1243,7 @@ TEST_CASE("regression tests 1")
SECTION("example 1") SECTION("example 1")
{ {
// create a map // create a map
std::map<std::string, int> m1 {{"key", 1}}; const std::map<std::string, int> m1 {{"key", 1}};
// create and print a JSON from the map // create and print a JSON from the map
json const j = m1; json const j = m1;
@@ -1258,7 +1258,7 @@ TEST_CASE("regression tests 1")
SECTION("example 2") SECTION("example 2")
{ {
// create a map // create a map
std::map<std::string, std::string> m1 {{"key", "val"}}; const std::map<std::string, std::string> m1 {{"key", "val"}};
// create and print a JSON from the map // create and print a JSON from the map
json const j = m1; json const j = m1;
@@ -1322,7 +1322,7 @@ TEST_CASE("regression tests 1")
auto m1 = j1.get<std::map<std::string, std::string>>(); auto m1 = j1.get<std::map<std::string, std::string>>();
auto m2 = j2.get<std::map<std::string, std::string>>(); auto m2 = j2.get<std::map<std::string, std::string>>();
int i3{j3}; const int i3{j3};
CHECK( m1 == ( std::map<std::string, std::string> {{ "first", "one" }} )); CHECK( m1 == ( std::map<std::string, std::string> {{ "first", "one" }} ));
CHECK( m2 == ( std::map<std::string, std::string> {{ "second", "two" }} )); CHECK( m2 == ( std::map<std::string, std::string> {{ "second", "two" }} ));
@@ -1431,7 +1431,7 @@ TEST_CASE("regression tests 1")
'1', '2', '3', '1', '2', '3',
0xFF 0xFF
}; };
json j = json::from_cbor(v_cbor); const json j = json::from_cbor(v_cbor);
CHECK(j == "abcd123"); CHECK(j == "abcd123");
} }
@@ -1477,7 +1477,7 @@ TEST_CASE("regression tests 1")
}; };
// parse (with callback) and serialize JSON // parse (with callback) and serialize JSON
json j_filtered = json::parse(text, cb); const json j_filtered = json::parse(text, cb);
CHECK(j_filtered == R"({"Image":{"Animated":false,"Height":600,"IDs":[116,943,234,38793], "Title":"View from 15th Floor","Width":800}})"_json); CHECK(j_filtered == R"({"Image":{"Animated":false,"Height":600,"IDs":[116,943,234,38793], "Title":"View from 15th Floor","Width":800}})"_json);
} }
@@ -1490,7 +1490,7 @@ TEST_CASE("regression tests 1")
SECTION("issue #977 - Assigning between different json types") SECTION("issue #977 - Assigning between different json types")
{ {
foo_json lj = ns::foo{3}; foo_json lj = ns::foo{3};
ns::foo ff(lj); const ns::foo ff(lj);
CHECK(lj.is_object()); CHECK(lj.is_object());
CHECK(lj.size() == 1); CHECK(lj.size() == 1);
CHECK(lj["x"] == 3); CHECK(lj["x"] == 3);
+6 -6
View File
@@ -549,7 +549,7 @@ TEST_CASE("regression tests 2")
{"3", {{"a", "testa_3"}, {"b", "testb_3"}}}, {"3", {{"a", "testa_3"}, {"b", "testb_3"}}},
}; };
std::map<std::string, Data> expected const std::map<std::string, Data> expected
{ {
{"1", {"testa_1", "testb_1"}}, {"1", {"testa_1", "testb_1"}},
{"2", {"testa_2", "testb_2"}}, {"2", {"testa_2", "testb_2"}},
@@ -642,7 +642,7 @@ TEST_CASE("regression tests 2")
#if !(defined(__INTEL_COMPILER) && __cplusplus >= 202000) #if !(defined(__INTEL_COMPILER) && __cplusplus >= 202000)
{ {
const json j; const json j;
NonDefaultFromJsonStruct x(j); const NonDefaultFromJsonStruct x(j);
NonDefaultFromJsonStruct y; NonDefaultFromJsonStruct y;
CHECK(x == y); CHECK(x == y);
} }
@@ -920,7 +920,7 @@ TEST_CASE("regression tests 2")
SECTION("issue #2982 - to_{binary format} does not provide a mechanism for specifying a custom allocator for the returned type") SECTION("issue #2982 - to_{binary format} does not provide a mechanism for specifying a custom allocator for the returned type")
{ {
std::vector<std::uint8_t, my_allocator<std::uint8_t>> my_vector; std::vector<std::uint8_t, my_allocator<std::uint8_t>> my_vector;
json j = {1, 2, 3, 4}; const json j = {1, 2, 3, 4};
json::to_cbor(j, my_vector); json::to_cbor(j, my_vector);
json k = json::from_cbor(my_vector); json k = json::from_cbor(my_vector);
CHECK(j == k); CHECK(j == k);
@@ -1019,8 +1019,8 @@ TEST_CASE("regression tests 2")
SECTION("issue #3204 - ambiguous regression") SECTION("issue #3204 - ambiguous regression")
{ {
for_3204_bar bar_from_foo([](for_3204_foo) noexcept {}); // NOLINT(performance-unnecessary-value-param) const for_3204_bar bar_from_foo([](for_3204_foo) noexcept {}); // NOLINT(performance-unnecessary-value-param)
for_3204_bar bar_from_json([](json) noexcept {}); // NOLINT(performance-unnecessary-value-param) const for_3204_bar bar_from_json([](json) noexcept {}); // NOLINT(performance-unnecessary-value-param)
CHECK(bar_from_foo.constructed_from == for_3204_bar::constructed_from_foo); CHECK(bar_from_foo.constructed_from == for_3204_bar::constructed_from_foo);
CHECK(bar_from_json.constructed_from == for_3204_bar::constructed_from_json); CHECK(bar_from_json.constructed_from == for_3204_bar::constructed_from_json);
@@ -1033,7 +1033,7 @@ TEST_CASE("regression tests 2")
{"x", 1}, {"x", 1},
{"y", 2} {"y", 2}
}; };
for_3333 p = j; const for_3333 p = j;
CHECK(p.x == 1); CHECK(p.x == 1);
CHECK(p.y == 2); CHECK(p.y == 2);
+2 -2
View File
@@ -340,7 +340,7 @@ TEST_CASE("formatting")
{ {
std::array<char, 33> buf{}; std::array<char, 33> buf{};
char* end = nlohmann::detail::to_chars(buf.data(), buf.data() + 32, number); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) char* end = nlohmann::detail::to_chars(buf.data(), buf.data() + 32, number); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
std::string actual(buf.data(), end); const std::string actual(buf.data(), end);
CHECK(actual == expected); CHECK(actual == expected);
}; };
@@ -400,7 +400,7 @@ TEST_CASE("formatting")
{ {
std::array<char, 33> buf{}; std::array<char, 33> buf{};
char* end = nlohmann::detail::to_chars(buf.data(), buf.data() + 32, number); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) char* end = nlohmann::detail::to_chars(buf.data(), buf.data() + 32, number); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
std::string actual(buf.data(), end); const std::string actual(buf.data(), end);
CHECK(actual == expected); CHECK(actual == expected);
}; };
+1 -1
View File
@@ -2515,7 +2515,7 @@ TEST_CASE("UBJSON roundtrips" * doctest::skip())
INFO_WITH_TEMP(filename + ": uint8_t* and size"); INFO_WITH_TEMP(filename + ": uint8_t* and size");
// parse JSON file // parse JSON file
std::ifstream f_json(filename); std::ifstream f_json(filename);
json j1 = json::parse(f_json); const json j1 = json::parse(f_json);
// parse UBJSON file // parse UBJSON file
auto const packed = utils::read_binary_file(filename + ".ubjson"); auto const packed = utils::read_binary_file(filename + ".ubjson");
+11 -11
View File
@@ -735,14 +735,14 @@ TEST_CASE("different basic_json types conversions")
SECTION("null") SECTION("null")
{ {
json const j; json const j;
custom_json cj = j; const custom_json cj = j;
CHECK(cj == nullptr); CHECK(cj == nullptr);
} }
SECTION("boolean") SECTION("boolean")
{ {
json const j = true; json const j = true;
custom_json cj = j; const custom_json cj = j;
CHECK(cj == true); CHECK(cj == true);
} }
@@ -764,28 +764,28 @@ TEST_CASE("different basic_json types conversions")
SECTION("integer") SECTION("integer")
{ {
json const j = 42; json const j = 42;
custom_json cj = j; const custom_json cj = j;
CHECK(cj == 42); CHECK(cj == 42);
} }
SECTION("float") SECTION("float")
{ {
json const j = 42.0; json const j = 42.0;
custom_json cj = j; const custom_json cj = j;
CHECK(cj == 42.0); CHECK(cj == 42.0);
} }
SECTION("unsigned") SECTION("unsigned")
{ {
json const j = 42u; json const j = 42u;
custom_json cj = j; const custom_json cj = j;
CHECK(cj == 42u); CHECK(cj == 42u);
} }
SECTION("string") SECTION("string")
{ {
json const j = "forty-two"; json const j = "forty-two";
custom_json cj = j; const custom_json cj = j;
CHECK(cj == "forty-two"); CHECK(cj == "forty-two");
} }
@@ -794,7 +794,7 @@ TEST_CASE("different basic_json types conversions")
json j = json::binary({1, 2, 3}, 42); json j = json::binary({1, 2, 3}, 42);
custom_json cj = j; custom_json cj = j;
CHECK(cj.get_binary().subtype() == 42); CHECK(cj.get_binary().subtype() == 42);
std::vector<std::uint8_t> cv = cj.get_binary(); const std::vector<std::uint8_t>& cv = cj.get_binary();
std::vector<std::uint8_t> v = j.get_binary(); std::vector<std::uint8_t> v = j.get_binary();
CHECK(cv == v); CHECK(cv == v);
} }
@@ -802,7 +802,7 @@ TEST_CASE("different basic_json types conversions")
SECTION("object") SECTION("object")
{ {
json const j = {{"forty", "two"}}; json const j = {{"forty", "two"}};
custom_json cj = j; const custom_json cj = j;
auto m = j.get<std::map<std::string, std::string>>(); auto m = j.get<std::map<std::string, std::string>>();
CHECK(cj == m); CHECK(cj == m);
} }
@@ -810,7 +810,7 @@ TEST_CASE("different basic_json types conversions")
SECTION("get<custom_json>") SECTION("get<custom_json>")
{ {
json const j = 42; json const j = 42;
custom_json cj = j.get<custom_json>(); const custom_json cj = j.get<custom_json>();
CHECK(cj == 42); CHECK(cj == 42);
} }
} }
@@ -861,11 +861,11 @@ TEST_CASE("Issue #924")
CHECK_NOTHROW(j.get<std::vector<Evil>>()); CHECK_NOTHROW(j.get<std::vector<Evil>>());
// silence Wunused-template warnings // silence Wunused-template warnings
Evil e(1); const Evil e(1);
CHECK(e.m_i >= 0); CHECK(e.m_i >= 0);
// suppress warning: function "<unnamed>::Evil::Evil(T) [with T=std::string]" was declared but never referenced [declared_but_not_referenced] // suppress warning: function "<unnamed>::Evil::Evil(T) [with T=std::string]" was declared but never referenced [declared_but_not_referenced]
Evil e2(std::string("foo")); const Evil e2(std::string("foo"));
CHECK(e2.m_i >= 0); CHECK(e2.m_i >= 0);
} }
+1 -1
View File
@@ -640,7 +640,7 @@ TEST_CASE_TEMPLATE("Serialization/deserialization of classes with 26 public/priv
SECTION("alphabet") SECTION("alphabet")
{ {
T obj1; T obj1; // NOLINT(misc-const-correctness)
Json const j = obj1; Json const j = obj1;
T obj2; T obj2;
j.get_to(obj2); j.get_to(obj2);
+33 -5
View File
@@ -48,7 +48,7 @@
#define DOCTEST_VERSION_MAJOR 2 #define DOCTEST_VERSION_MAJOR 2
#define DOCTEST_VERSION_MINOR 4 #define DOCTEST_VERSION_MINOR 4
#define DOCTEST_VERSION_PATCH 11 #define DOCTEST_VERSION_PATCH 12
// util we need here // util we need here
#define DOCTEST_TOSTR_IMPL(x) #x #define DOCTEST_TOSTR_IMPL(x) #x
@@ -925,6 +925,7 @@ struct ContextOptions //!OCLINT too many fields
bool no_skip; // don't skip test cases which are marked to be skipped bool no_skip; // don't skip test cases which are marked to be skipped
bool gnu_file_line; // if line numbers should be surrounded with :x: and not (x): bool gnu_file_line; // if line numbers should be surrounded with :x: and not (x):
bool no_path_in_filenames; // if the path to files should be removed from the output bool no_path_in_filenames; // if the path to files should be removed from the output
String strip_file_prefixes;// remove the longest matching one of these prefixes from any file paths in the output
bool no_line_numbers; // if source code line numbers should be omitted from the output bool no_line_numbers; // if source code line numbers should be omitted from the output
bool no_debug_output; // no output in the debug console when a debugger is attached bool no_debug_output; // no output in the debug console when a debugger is attached
bool no_skipped_summary; // don't print "skipped" in the summary !!! UNDOCUMENTED !!! bool no_skipped_summary; // don't print "skipped" in the summary !!! UNDOCUMENTED !!!
@@ -1578,8 +1579,8 @@ DOCTEST_CLANG_SUPPRESS_WARNING_POP
// https://github.com/catchorg/Catch2/issues/870 // https://github.com/catchorg/Catch2/issues/870
// https://github.com/catchorg/Catch2/issues/565 // https://github.com/catchorg/Catch2/issues/565
template <typename L> template <typename L>
Expression_lhs<L> operator<<(L&& operand) { Expression_lhs<const L&&> operator<<(const L&& operand) { //bitfields bind to universal ref but not const rvalue ref
return Expression_lhs<L>(static_cast<L&&>(operand), m_at); return Expression_lhs<const L&&>(static_cast<const L&&>(operand), m_at);
} }
template <typename L,typename types::enable_if<!doctest::detail::types::is_rvalue_reference<L>::value,void >::type* = nullptr> template <typename L,typename types::enable_if<!doctest::detail::types::is_rvalue_reference<L>::value,void >::type* = nullptr>
@@ -3243,6 +3244,10 @@ DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END
#define DOCTEST_CONFIG_OPTIONS_PREFIX "dt-" #define DOCTEST_CONFIG_OPTIONS_PREFIX "dt-"
#endif #endif
#ifndef DOCTEST_CONFIG_OPTIONS_FILE_PREFIX_SEPARATOR
#define DOCTEST_CONFIG_OPTIONS_FILE_PREFIX_SEPARATOR ':'
#endif
#ifndef DOCTEST_THREAD_LOCAL #ifndef DOCTEST_THREAD_LOCAL
#if defined(DOCTEST_CONFIG_NO_MULTITHREADING) || DOCTEST_MSVC && (DOCTEST_MSVC < DOCTEST_COMPILER(19, 0, 0)) #if defined(DOCTEST_CONFIG_NO_MULTITHREADING) || DOCTEST_MSVC && (DOCTEST_MSVC < DOCTEST_COMPILER(19, 0, 0))
#define DOCTEST_THREAD_LOCAL #define DOCTEST_THREAD_LOCAL
@@ -3751,7 +3756,7 @@ String::size_type String::capacity() const {
} }
String String::substr(size_type pos, size_type cnt) && { String String::substr(size_type pos, size_type cnt) && {
cnt = std::min(cnt, size() - 1 - pos); cnt = std::min(cnt, size() - pos);
char* cptr = c_str(); char* cptr = c_str();
memmove(cptr, cptr + pos, cnt); memmove(cptr, cptr + pos, cnt);
setSize(cnt); setSize(cnt);
@@ -3759,7 +3764,7 @@ String String::substr(size_type pos, size_type cnt) && {
} }
String String::substr(size_type pos, size_type cnt) const & { String String::substr(size_type pos, size_type cnt) const & {
cnt = std::min(cnt, size() - 1 - pos); cnt = std::min(cnt, size() - pos);
return String{ c_str() + pos, cnt }; return String{ c_str() + pos, cnt };
} }
@@ -3891,6 +3896,26 @@ const char* skipPathFromFilename(const char* file) {
forward = back; forward = back;
return forward + 1; return forward + 1;
} }
} else {
const auto prefixes = getContextOptions()->strip_file_prefixes;
const char separator = DOCTEST_CONFIG_OPTIONS_FILE_PREFIX_SEPARATOR;
String::size_type longest_match = 0U;
for(String::size_type pos = 0U; pos < prefixes.size(); ++pos)
{
const auto prefix_start = pos;
pos = std::min(prefixes.find(separator, prefix_start), prefixes.size());
const auto prefix_size = pos - prefix_start;
if(prefix_size > longest_match)
{
// TODO under DOCTEST_MSVC: does the comparison need strnicmp() to work with drive letter capitalization?
if(0 == std::strncmp(prefixes.c_str() + prefix_start, file, prefix_size))
{
longest_match = prefix_size;
}
}
}
return &file[longest_match];
} }
#endif // DOCTEST_CONFIG_DISABLE #endif // DOCTEST_CONFIG_DISABLE
return file; return file;
@@ -6181,6 +6206,8 @@ namespace {
<< Whitespace(sizePrefixDisplay*1) << ":n: vs (n): for line numbers in output\n"; << Whitespace(sizePrefixDisplay*1) << ":n: vs (n): for line numbers in output\n";
s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "npf, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-path-filenames=<bool> " s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "npf, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-path-filenames=<bool> "
<< Whitespace(sizePrefixDisplay*1) << "only filenames and no paths in output\n"; << Whitespace(sizePrefixDisplay*1) << "only filenames and no paths in output\n";
s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "spp, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "skip-path-prefixes=<p1:p2> "
<< Whitespace(sizePrefixDisplay*1) << "whenever file paths start with this prefix, remove it from the output\n";
s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "nln, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-line-numbers=<bool> " s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "nln, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-line-numbers=<bool> "
<< Whitespace(sizePrefixDisplay*1) << "0 instead of real line numbers in output\n"; << Whitespace(sizePrefixDisplay*1) << "0 instead of real line numbers in output\n";
// ================================================================================== << 79 // ================================================================================== << 79
@@ -6685,6 +6712,7 @@ void Context::parseArgs(int argc, const char* const* argv, bool withDefaults) {
DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-skip", "ns", no_skip, false); DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-skip", "ns", no_skip, false);
DOCTEST_PARSE_AS_BOOL_OR_FLAG("gnu-file-line", "gfl", gnu_file_line, !bool(DOCTEST_MSVC)); DOCTEST_PARSE_AS_BOOL_OR_FLAG("gnu-file-line", "gfl", gnu_file_line, !bool(DOCTEST_MSVC));
DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-path-filenames", "npf", no_path_in_filenames, false); DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-path-filenames", "npf", no_path_in_filenames, false);
DOCTEST_PARSE_STR_OPTION("strip-file-prefixes", "sfp", strip_file_prefixes, "");
DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-line-numbers", "nln", no_line_numbers, false); DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-line-numbers", "nln", no_line_numbers, false);
DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-debug-output", "ndo", no_debug_output, false); DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-debug-output", "ndo", no_debug_output, false);
DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-skipped-summary", "nss", no_skipped_summary, false); DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-skipped-summary", "nss", no_skipped_summary, false);