mirror of
https://github.com/nlohmann/json.git
synced 2026-09-06 00:08:00 +00:00
Mark parser-callback test lambdas noexcept to fix GCC -Wnoexcept -Werror
GCC's libstdc++ std::function move assignment evaluates a noexcept
check that invokes a wrapped callable in an unevaluated context; a
non-noexcept parser_callback_t lambda then trips -Wnoexcept ("noexcept-
expression evaluates to 'false'"), which CI's ci_test_gcc job builds
with -Werror. The pre-existing parser_callback_t test lambdas in this
file already work around this by declaring themselves noexcept; apply
the same fix to the three added lambdas that didn't.
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
@@ -1569,7 +1569,7 @@ TEST_CASE("issue #5402 - update(merge_objects=true) overwrites a primitive with
|
||||
TEST_CASE("regression test - parser callback must not lose a duplicate key's prior value")
|
||||
{
|
||||
// a callback that rejects only the scalar value 2
|
||||
const json::parser_callback_t drop_value_2 = [](int /*depth*/, json::parse_event_t ev, json & v)
|
||||
const json::parser_callback_t drop_value_2 = [](int /*depth*/, json::parse_event_t ev, json & v) noexcept
|
||||
{
|
||||
return !(ev == json::parse_event_t::value && v == 2);
|
||||
};
|
||||
@@ -1583,7 +1583,7 @@ TEST_CASE("regression test - parser callback must not lose a duplicate key's pri
|
||||
SECTION("duplicate key, second value is an object rejected at object_end - prior value is restored")
|
||||
{
|
||||
const json j = json::parse(R"({"a":1,"a":{"x":2}})",
|
||||
[](int depth, json::parse_event_t ev, json& /*parsed*/)
|
||||
[](int depth, json::parse_event_t ev, json& /*parsed*/) noexcept
|
||||
{
|
||||
return !(ev == json::parse_event_t::object_end && depth == 1);
|
||||
});
|
||||
@@ -1593,7 +1593,7 @@ TEST_CASE("regression test - parser callback must not lose a duplicate key's pri
|
||||
SECTION("duplicate key, second value is an array rejected at array_end - prior value is restored")
|
||||
{
|
||||
const json j = json::parse(R"({"a":1,"a":[9,9]})",
|
||||
[](int depth, json::parse_event_t ev, json& /*parsed*/)
|
||||
[](int depth, json::parse_event_t ev, json& /*parsed*/) noexcept
|
||||
{
|
||||
return !(ev == json::parse_event_t::array_end && depth == 1);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user