netgen/tests/catch/ranges.cpp
Drew Parsons cb1e8d1269 support Catch2 v3
- uses Cmake config files for Catch2
- supports both v2 and v3 of Catch2
- Catch2 v3 includes <catch2/catch_all.hpp> instead of <catch2/catch.hpp>
- v3 moves Catch::Contains to Catch::Matchers::ContainsSubstring

see https://github.com/catchorg/Catch2/blob/devel/docs/migrate-v2-to-v3.md

Patch adapted from debian patch catch2_v3.patch
d7ca1c564d/debian/patches/catch2_v3.patch
2025-01-05 13:34:44 +01:00

23 lines
394 B
C++

#ifdef CATCH2_v3
#include "catch2/catch_all.hpp"
#else
#include <catch2/catch.hpp>
#endif
#include <core/array.hpp>
#include <core/ranges.hpp>
using namespace ngcore;
TEST_CASE("ranges")
{
Array<int> a { 3, -1, 10, -5 };
Array<int> positive { 3, 10 };
int i = 0;
for(auto pos_val : a | filter([](auto val) { return val >= 0; }))
{
CHECK(pos_val == positive[i++]);
}
}