Skip to content

Commit

Permalink
✅ add test for #4440
Browse files Browse the repository at this point in the history
  • Loading branch information
nlohmann committed Nov 17, 2024
1 parent 1c5923e commit 9a45e6a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/src/unit-regression2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ using ordered_json = nlohmann::ordered_json;
#endif
#endif

// for #4440
#if 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")
Expand Down Expand Up @@ -938,6 +943,19 @@ TEST_CASE("regression tests 2")
CHECK(p.x == 1);
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

0 comments on commit 9a45e6a

Please sign in to comment.