Skip to content

Commit 35796db

Browse files
more test updates
1 parent 123474b commit 35796db

File tree

6 files changed

+70
-6
lines changed

6 files changed

+70
-6
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,6 @@ constexpr bool tests() {
8383

8484
int main(int, char**) {
8585
tests();
86+
static_assert(tests());
8687
return 0;
8788
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// REQUIRES: has-unix-headers, std-at-least-c++26
10+
11+
#include <ranges>
12+
#include <cassert>
13+
14+
#include "../../range_adaptor_types.h"
15+
16+
using ConstIterIncompatibleView = BasicView<forward_iterator<int*>, forward_iterator<int*>,
17+
random_access_iterator<const int*>, random_access_iterator<const int*>>;
18+
static_assert(!std::convertible_to<std::ranges::iterator_t<ConstIterIncompatibleView>,
19+
std::ranges::iterator_t<const ConstIterIncompatibleView>>);
20+
21+
constexpr bool test() {
22+
int buffer[3] = {1, 2, 3};
23+
24+
{
25+
std::ranges::concat_view v(NonSimpleCommon{buffer});
26+
auto iter1 = v.begin();
27+
std::ranges::iterator_t<const decltype(v)> iter2 = iter1;
28+
assert(iter1 == iter2);
29+
30+
static_assert(!std::is_same_v<decltype(iter1), decltype(iter2)>);
31+
32+
// We cannot create a non-const iterator from a const iterator.
33+
static_assert(!std::constructible_from<decltype(iter1), decltype(iter2)>);
34+
}
35+
36+
{
37+
// underlying non-const to const not convertible
38+
std::ranges::concat_view v(ConstIterIncompatibleView{buffer});
39+
auto iter1 = v.begin();
40+
auto iter2 = std::as_const(v).begin();
41+
42+
static_assert(!std::is_same_v<decltype(iter1), decltype(iter2)>);
43+
static_assert(!std::constructible_from<decltype(iter1), decltype(iter2)>);
44+
static_assert(!std::constructible_from<decltype(iter2), decltype(iter1)>);
45+
}
46+
47+
return true;
48+
}
49+
50+
int main(int, char**) {
51+
test();
52+
static_assert(test());
53+
54+
return 0;
55+
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,5 @@ constexpr bool test() {
8282
int main(int, char**) {
8383
test();
8484
static_assert(test());
85-
8685
return 0;
8786
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ constexpr bool test() {
113113
// non bidirectional
114114
{
115115
int buffer[3] = {4, 5, 6};
116-
std::ranges::zip_view v(a, NonBidi{buffer});
116+
std::ranges::concat_view v(a, NonBidi{buffer});
117117
using Iter = std::ranges::iterator_t<decltype(v)>;
118118
static_assert(!canDecrement<Iter>);
119119
}

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct ConstVeryDifferentRange {
6060
forward_iterator<double*> end() const;
6161
};
6262

63-
void test() {
63+
constexpr bool test() {
6464
int buffer[] = {1, 2, 3, 4};
6565
{
6666
// random_access_iterator_tag
@@ -99,8 +99,6 @@ void test() {
9999
static_assert(std::is_same_v<Iter::value_type, int>);
100100
}
101101

102-
103-
104102
{
105103
// forward_iterator_tag
106104
using Iter = std::ranges::iterator_t<std::ranges::concat_view<ForwardView<int>>>;
@@ -161,4 +159,12 @@ void test() {
161159
static_assert(std::is_same_v<ConstIter::value_type, double>);
162160
}
163161

162+
return true;
163+
}
164+
165+
166+
int main(int, char**) {
167+
test();
168+
static_assert(test());
169+
return 0;
164170
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "test_macros.h"
1818
#include "../types.h"
1919

20-
constexpr void test() {
20+
constexpr bool test() {
2121
// Test two iterators
2222
{
2323
std::array<int, 2> array1{0, 1};
@@ -40,9 +40,12 @@ constexpr void test() {
4040
auto res = std::default_sentinel_t{} - it1;
4141
assert(res == 4);
4242
}
43+
44+
return true;
4345
}
4446

4547
int main(int, char**) {
4648
test();
49+
static_assert(test());
4750
return 0;
4851
}

0 commit comments

Comments
 (0)