d: Merge dmd, druntime c7902293d7, phobos 03aeafd20
[gcc.git] / libstdc++-v3 / testsuite / 25_algorithms / contains / 1.cc
blobb44c06032e8ade185db43f96641706e12d4bc171
1 // { dg-do run { target c++23 } }
3 #include <algorithm>
4 #include <testsuite_hooks.h>
5 #include <testsuite_iterators.h>
7 #if __cpp_lib_ranges_contains != 202207L
8 # error "Feature-test macro __cpp_lib_ranges_contains has wrong value in <algorithm>"
9 #endif
11 namespace ranges = std::ranges;
13 void
14 test01()
16 int x[] = {1,2,3};
17 using to_input = __gnu_test::test_input_range<int>;
18 VERIFY( ranges::contains(to_input(x), 1) );
19 VERIFY( ranges::contains(to_input(x), 2) );
20 VERIFY( ranges::contains(to_input(x), 3) );
21 VERIFY( !ranges::contains(to_input(x), 4) );
22 VERIFY( !ranges::contains(x, x+2, 3) );
23 auto neg = [](int n) { return -n; };
24 VERIFY( ranges::contains(to_input(x), -1, neg) );
25 VERIFY( ranges::contains(to_input(x), -2, neg) );
26 VERIFY( ranges::contains(to_input(x), -3, neg) );
27 VERIFY( !ranges::contains(to_input(x), -4, neg) );
29 VERIFY( !ranges::contains(x, x+2, -3, neg) );
32 int
33 main()
35 test01();