Skip to content

Commit 4f215b0

Browse files
fix test
1 parent 9be881d commit 4f215b0

File tree

5 files changed

+48
-84
lines changed

5 files changed

+48
-84
lines changed

libcxx/test/std/ranges/range.adaptors/range.concat/constraints.pass.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ struct InputRange {
3535
int* end_;
3636
};
3737

38+
template <typename... Ts>
39+
concept ConcatViewConstraintsPass = requires(Ts&&... a) { std::views::concat(a...); };
3840

3941
int main(int, char**) {
4042

@@ -59,5 +61,28 @@ int main(int, char**) {
5961
static_assert(WellFormedView<std::vector<int>>);
6062
}
6163

64+
{
65+
// LWG 4082
66+
std::vector<int> v{1, 2, 3};
67+
auto r = std::views::counted(std::back_inserter(v), 3);
68+
//auto c = std::views::concat(r);
69+
static_assert(!ConcatViewConstraintsPass<decltype(r)>);
70+
}
71+
72+
{
73+
// input is a view and has 0 size
74+
static_assert(!ConcatViewConstraintsPass<>);
75+
}
76+
77+
{
78+
// input is a view and has at least an element
79+
static_assert(ConcatViewConstraintsPass<std::vector<int>>);
80+
}
81+
82+
{
83+
// inputs are non-concatable
84+
static_assert(!ConcatViewConstraintsPass<std::vector<int>, std::vector<std::string>>);
85+
}
86+
6287
return 0;
6388
}

libcxx/test/std/ranges/range.adaptors/range.concat/ctor.verify.cpp

Lines changed: 0 additions & 56 deletions
This file was deleted.

libcxx/test/std/ranges/range.adaptors/range.concat/iterator/compare.pass.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ constexpr void test() {
6666
decltype(auto) it2 = view.begin() + 3;
6767

6868
assert(it1 != it2);
69-
assert(*it1 = 0);
70-
assert(*it1 = 4);
69+
assert(*it1 == 0);
70+
assert(*it2 == 4);
7171
it1++;
7272
it2++;
73-
assert(*it1 = 1);
74-
assert(*it1 = 5);
73+
assert(*it1 == 1);
74+
assert(*it2 == 5);
7575
}
7676

7777
{

libcxx/test/std/ranges/range.adaptors/range.concat/iterator/deref.pass.cpp

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <array>
1414
#include <cassert>
1515
#include <ranges>
16+
#include <vector>
1617

1718
#include "test_iterators.h"
1819
#include "../types.h"
@@ -50,29 +51,6 @@ constexpr void test() {
5051
assert(*it1 == *it2);
5152
}
5253

53-
{
54-
// test with more than one view of different types
55-
using View = minimal_view<Iter, Sent>;
56-
using ConcatView = std::ranges::concat_view<View>;
57-
using ConcatIterator = std::ranges::iterator_t<ConcatView>;
58-
59-
auto make_concat_view = [](auto begin, auto end) {
60-
View view{Iter(begin), Sent(Iter(end))};
61-
return ConcatView(std::move(view));
62-
};
63-
64-
std::array<int, 3> array1{0, 1, 2};
65-
std::array<int, 3> array2{3, 4, 5};
66-
ConcatView view = make_concat_view(array1.data(), array1.data() + array1.size());
67-
std::ranges::concat_view cv(view, std::views::all(array2));
68-
decltype(auto) it1 = cv.begin();
69-
decltype(auto) it2 = cv.begin() + 3;
70-
71-
ASSERT_SAME_TYPE(int&, decltype(*it1));
72-
assert(*it1 == 0);
73-
assert(*it2 == 3);
74-
}
75-
7654
{
7755
// constness
7856
constexpr static std::array<int, 3> array1{0, 1, 2};
@@ -94,6 +72,23 @@ constexpr bool tests() {
9472
test<contiguous_iterator<int*>>();
9573
test<int*>();
9674

75+
{
76+
// test with more than one view of different types
77+
std::vector<int> array1{0, 1, 2};
78+
std::array<int, 3> array2{3, 4, 5};
79+
std::ranges::concat_view cv(std::views::all(array1), std::views::all(array2));
80+
decltype(auto) it1 = cv.begin();
81+
decltype(auto) it2 = cv.begin();
82+
83+
ASSERT_SAME_TYPE(int&, decltype(*it1));
84+
it2++;
85+
assert(*it1 == 0);
86+
assert(*it2 == 1);
87+
it2++;
88+
it2++;
89+
assert(*it2 == 3);
90+
}
91+
9792
return true;
9893
}
9994

libcxx/test/std/ranges/range.adaptors/range.concat/size.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ constexpr bool test() {
111111

112112
{
113113
//two ranges with different size type
114-
std::ranges::concat_view v(UnsignedSizeView(), IntSizeView());
114+
std::ranges::concat_view v(UnsignedSizeView{}, IntSizeView{});
115115
assert(v.size() == 18);
116116
// common type between size_t and int should be size_t
117117
ASSERT_SAME_TYPE(decltype(v.size()), unsigned int);

0 commit comments

Comments
 (0)