# This is a combination of 2 commits.

# This is the 1st commit message:

 add test for #4440

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

# Conflicts:
#	tests/src/unit-regression2.cpp

# This is the commit message #2:

 add test for #4440

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann 2025-05-22 12:30:38 +02:00
parent 4b17f90f65
commit b4a5a4fbbc
No known key found for this signature in database
GPG Key ID: 7F3CEA63AE251B69

View File

@ -50,6 +50,11 @@ using ordered_json = nlohmann::ordered_json;
#endif
#endif
// for #4440
#ifdef JSON_HAS_RANGES
#include <ranges>
#endif
// NLOHMANN_JSON_SERIALIZE_ENUM uses a static std::pair
DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
DOCTEST_CLANG_SUPPRESS_WARNING("-Wexit-time-destructors")
@ -1094,6 +1099,20 @@ TEST_CASE("regression tests 2")
CHECK(j.type_name() == "invalid");
}
#endif
#ifdef JSON_HAS_RANGES
SECTION("issue 4440")
{
auto noOpFilter = std::views::filter([](auto&&)
{
return true;
});
json j = {1, 2, 3};
auto filtered = j | noOpFilter;
CHECK(j == *filtered.begin());
}
#endif
}
DOCTEST_CLANG_SUPPRESS_WARNING_POP