Skip to content

Commit 1d0aa5f

Browse files
[libc++] Add missing CPO tests for range adaptors (#149557)
Co-authored-by: A. Jiang <[email protected]>
1 parent 6cbcfb9 commit 1d0aa5f

File tree

1 file changed

+35
-6
lines changed

1 file changed

+35
-6
lines changed

libcxx/test/std/library/description/conventions/customization.point.object/cpo.compile.pass.cpp

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <concepts>
1616
#include <iterator>
1717
#include <ranges>
18+
#include <sstream>
1819
#include <type_traits>
1920
#include <utility>
2021

@@ -45,7 +46,10 @@ constexpr bool test(CPO& o, Args&&...) {
4546

4647
int a[10];
4748
int arrays[10][10];
48-
//std::pair<int, int> pairs[10];
49+
std::pair<int, int> pairs[10];
50+
#ifndef TEST_HAS_NO_LOCALIZATION
51+
std::istringstream stream;
52+
#endif
4953

5054
// [concept.swappable]
5155
static_assert(test(std::ranges::swap, a, a));
@@ -81,25 +85,50 @@ static_assert(test(std::ranges::ssize, a));
8185
// views::empty<T> is not a CPO
8286
static_assert(test(std::views::iota, 1));
8387
static_assert(test(std::views::iota, 1, 10));
84-
//static_assert(test(std::views::istream<int>, 1);
88+
#ifndef TEST_HAS_NO_LOCALIZATION
89+
static_assert(test(std::views::istream<int>, stream));
90+
#endif
8591
static_assert(test(std::views::single, 4));
8692

93+
#if TEST_STD_VER >= 23
94+
static_assert(test(std::views::repeat, 1));
95+
#endif
96+
8797
// [range.adaptors]
8898
static_assert(test(std::views::all, a));
8999
static_assert(test(std::views::common, a));
90100
static_assert(test(std::views::counted, a, 10));
91101
static_assert(test(std::views::drop, a, 10));
92-
//static_assert(test(std::views::drop_while, a, [](int x){ return x < 10; }));
93-
//static_assert(test(std::views::elements<0>, pairs));
102+
static_assert(test(std::views::drop_while, a, [](int x) { return x < 10; }));
103+
static_assert(test(std::views::elements<0>, pairs));
94104
static_assert(test(std::views::filter, a, [](int x) { return x < 10; }));
95105
static_assert(test(std::views::join, arrays));
96-
//static_assert(test(std::views::split, a, 4));
106+
static_assert(test(std::views::keys, pairs));
97107
static_assert(test(std::views::lazy_split, a, 4));
98108
static_assert(test(std::views::reverse, a));
109+
static_assert(test(std::views::split, a, 4));
99110
static_assert(test(std::views::take, a, 10));
100-
//static_assert(test(std::views::take_while, a, [](int x){ return x < 10; }));
111+
static_assert(test(std::views::take_while, a, [](int x) { return x < 10; }));
101112
static_assert(test(std::views::transform, a, [](int x) { return x + 1; }));
113+
static_assert(test(std::views::values, pairs));
102114

103115
#if TEST_STD_VER >= 23
116+
// static_assert(test(std::views::adjacent_transform<2>, [](int x, int y) { return x + y; }, a));
117+
// static_assert(test(std::views::adjacent<2>, a));
118+
// static_assert(test(std::views::as_const, a));
119+
static_assert(test(std::views::as_rvalue, a));
120+
// static_assert(test(std::views::cartesian_product, a, a, a));
121+
static_assert(test(std::views::chunk_by, a, [](int x, int y) { return x < y; }));
122+
// static_assert(test(std::views::chunk, a, 1));
123+
// static_assert(test(std::views::enumerate, a));
124+
static_assert(test(std::views::join_with, 1));
125+
// static_assert(test(std::views::stride, a, 1));
104126
static_assert(test(std::views::zip_transform, [](int x, int y) { return x + y; }, a, a));
127+
static_assert(test(std::views::zip, a, a));
128+
#endif
129+
130+
#if TEST_STD_VER >= 26
131+
// static_assert(test(std::views::cache_latest, a));
132+
// static_assert(test(std::views::concat, a, a));
133+
// static_assert(test(std::views::to_input, a));
105134
#endif

0 commit comments

Comments
 (0)