1
0
mirror of https://github.com/nlohmann/json synced 2024-11-30 15:40:07 +00:00

add test for #4440

This commit is contained in:
Niels Lohmann 2024-11-17 11:07:35 +01:00
parent 1c5923e5d6
commit 9a45e6ab77
No known key found for this signature in database
GPG Key ID: 7F3CEA63AE251B69

View File

@ -42,6 +42,11 @@ using ordered_json = nlohmann::ordered_json;
#endif #endif
#endif #endif
// for #4440
#if JSON_HAS_RANGES
#include <ranges>
#endif
// NLOHMANN_JSON_SERIALIZE_ENUM uses a static std::pair // NLOHMANN_JSON_SERIALIZE_ENUM uses a static std::pair
DOCTEST_CLANG_SUPPRESS_WARNING_PUSH DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
DOCTEST_CLANG_SUPPRESS_WARNING("-Wexit-time-destructors") DOCTEST_CLANG_SUPPRESS_WARNING("-Wexit-time-destructors")
@ -938,6 +943,19 @@ TEST_CASE("regression tests 2")
CHECK(p.x == 1); CHECK(p.x == 1);
CHECK(p.y == 2); CHECK(p.y == 2);
} }
#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 DOCTEST_CLANG_SUPPRESS_WARNING_POP