File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed
libcxx/test/std/ranges/range.adaptors/range.cartesian.product.view Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change 1010
1111// std::ranges::cartesian_product_view::size
1212
13+ #include < array>
1314#include < cassert>
14- #include < ranges>
1515#include < initializer_list>
16+ #include < ranges>
1617
1718constexpr bool test () {
18- { // testing: constexpr auto size() const
19- // example taken from: https://en.cppreference.com/w/cpp/ranges/cartesian_product_view/size
19+ { // example taken from: https://en.cppreference.com/w/cpp/ranges/cartesian_product_view/size
2020 constexpr static auto w = {1 };
2121 constexpr static auto x = {2 , 3 };
2222 constexpr static auto y = {4 , 5 , 6 };
@@ -33,6 +33,22 @@ constexpr bool test() {
3333 assert (v.size () == w.size () * x.size () * y.size () * z.size ());
3434 }
3535
36+ { // empty range
37+ std::ranges::empty_view<int > e;
38+ auto v = std::ranges::cartesian_product_view (e);
39+ assert (v.size () == 0 );
40+ }
41+
42+ { // 1..3 range(s)
43+ constexpr size_t N0 = 3 , N1 = 7 , N2 = 42 ;
44+ std::array<int , N0> a0;
45+ std::array<int , N1> a1;
46+ std::array<int , N2> a2;
47+ assert (std::ranges::cartesian_product_view (a0).size () == N0);
48+ assert (std::ranges::cartesian_product_view (a0, a1).size () == N0 * N1);
49+ assert (std::ranges::cartesian_product_view (a0, a1, a2).size () == N0 * N1 * N2);
50+ }
51+
3652 return true ;
3753}
3854
You can’t perform that action at this time.
0 commit comments