Fix more test build failures due to missing noexcept

This commit is contained in:
Florian Albrechtskirchinger 2022-03-09 13:23:56 +01:00
parent d7954b29fc
commit 6d19608007
4 changed files with 20 additions and 20 deletions

View File

@ -37,7 +37,7 @@ SOFTWARE.
/* forward declarations */ /* forward declarations */
class alt_string; class alt_string;
bool operator<(const char* op1, const alt_string& op2); bool operator<(const char* op1, const alt_string& op2) noexcept;
void int_to_string(alt_string& target, std::size_t value); void int_to_string(alt_string& target, std::size_t value);
/* /*
@ -152,7 +152,7 @@ class alt_string
private: private:
std::string str_impl {}; std::string str_impl {};
friend bool ::operator<(const char* /*op1*/, const alt_string& /*op2*/); friend bool ::operator<(const char* /*op1*/, const alt_string& /*op2*/) noexcept;
}; };
void int_to_string(alt_string& target, std::size_t value) void int_to_string(alt_string& target, std::size_t value)
@ -172,7 +172,7 @@ using alt_json = nlohmann::basic_json <
nlohmann::adl_serializer >; nlohmann::adl_serializer >;
bool operator<(const char* op1, const alt_string& op2) bool operator<(const char* op1, const alt_string& op2) noexcept
{ {
return op1 < op2.str_impl; return op1 < op2.str_impl;
} }

View File

@ -1609,7 +1609,7 @@ TEST_CASE("CBOR")
// callback to set binary_seen to true if a binary value was seen // callback to set binary_seen to true if a binary value was seen
bool binary_seen = false; bool binary_seen = false;
auto callback = [&binary_seen](int /*depth*/, json::parse_event_t /*event*/, json & parsed) auto callback = [&binary_seen](int /*depth*/, json::parse_event_t /*event*/, json & parsed) noexcept
{ {
if (parsed.is_binary()) if (parsed.is_binary())
{ {

View File

@ -267,7 +267,7 @@ bool accept_helper(const std::string& s)
CHECK(json::parser(nlohmann::detail::input_adapter(s)).accept(false) == !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 /*unused*/, json::parse_event_t /*unused*/, json& /*unused*/) json::parser_callback_t cb = [](int /*unused*/, json::parse_event_t /*unused*/, json& /*unused*/) noexcept
{ {
return true; return true;
}; };
@ -1499,7 +1499,7 @@ TEST_CASE("parser class")
// test case to make sure the callback is properly evaluated after reading a key // test case to make sure the callback is properly evaluated after reading a key
{ {
json::parser_callback_t cb = [](int /*unused*/, json::parse_event_t event, json& /*unused*/) json::parser_callback_t cb = [](int /*unused*/, json::parse_event_t event, json& /*unused*/) noexcept
{ {
return event != json::parse_event_t::key; return event != json::parse_event_t::key;
}; };
@ -1538,14 +1538,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*/) 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*/) json j_array = json::parse(s_array, [](int /*unused*/, json::parse_event_t /*unused*/, const json& /*unused*/) noexcept
{ {
return true; return true;
}); });
@ -1555,7 +1555,7 @@ TEST_CASE("parser class")
SECTION("filter everything") SECTION("filter everything")
{ {
json j_object = json::parse(s_object, [](int /*unused*/, json::parse_event_t /*unused*/, const json& /*unused*/) json j_object = json::parse(s_object, [](int /*unused*/, json::parse_event_t /*unused*/, const json& /*unused*/) noexcept
{ {
return false; return false;
}); });
@ -1563,7 +1563,7 @@ TEST_CASE("parser class")
// the top-level object will be discarded, leaving a null // the top-level object will be discarded, leaving a null
CHECK (j_object.is_null()); CHECK (j_object.is_null());
json j_array = json::parse(s_array, [](int /*unused*/, json::parse_event_t /*unused*/, const json& /*unused*/) json j_array = json::parse(s_array, [](int /*unused*/, json::parse_event_t /*unused*/, const json& /*unused*/) noexcept
{ {
return false; return false;
}); });
@ -1574,7 +1574,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 /*unused*/, const json & j) 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);
@ -1582,7 +1582,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 /*unused*/, const json & j) 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);
}); });
@ -1601,7 +1601,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*/) 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;
}); });
@ -1616,7 +1616,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*/) 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)
@ -1633,7 +1633,7 @@ TEST_CASE("parser class")
} }
{ {
json j_array = json::parse(s_array, [](int /*unused*/, json::parse_event_t e, const json& /*unused*/) 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)
@ -1657,13 +1657,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*/) 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*/) 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;
}); });
@ -1731,7 +1731,7 @@ TEST_CASE("parser class")
{ {
SECTION("parser with callback") SECTION("parser with callback")
{ {
json::parser_callback_t cb = [](int /*unused*/, json::parse_event_t /*unused*/, json& /*unused*/) json::parser_callback_t cb = [](int /*unused*/, json::parse_event_t /*unused*/, json& /*unused*/) noexcept
{ {
return true; return true;
}; };

View File

@ -1610,7 +1610,7 @@ TEST_CASE("UBJSON")
CHECK_THROWS_AS(_ = json::from_ubjson(v_ubjson), json::out_of_range&); CHECK_THROWS_AS(_ = json::from_ubjson(v_ubjson), json::out_of_range&);
json j; json j;
nlohmann::detail::json_sax_dom_callback_parser<json> scp(j, [](int /*unused*/, json::parse_event_t /*unused*/, const json& /*unused*/) nlohmann::detail::json_sax_dom_callback_parser<json> scp(j, [](int /*unused*/, json::parse_event_t /*unused*/, const json& /*unused*/) noexcept
{ {
return true; return true;
}); });
@ -1624,7 +1624,7 @@ TEST_CASE("UBJSON")
CHECK_THROWS_AS(_ = json::from_ubjson(v_ubjson), json::out_of_range&); CHECK_THROWS_AS(_ = json::from_ubjson(v_ubjson), json::out_of_range&);
json j; json j;
nlohmann::detail::json_sax_dom_callback_parser<json> scp(j, [](int /*unused*/, json::parse_event_t /*unused*/, const json& /*unused*/) nlohmann::detail::json_sax_dom_callback_parser<json> scp(j, [](int /*unused*/, json::parse_event_t /*unused*/, const json& /*unused*/) noexcept
{ {
return true; return true;
}); });