Skip to content

Commit 272da50

Browse files
authored
[libc++] Move a bunch of tests from libcxx/test/libcxx to libcxx/test/std (#150199)
These tests test standard behaviour, so they shouldn't be in the libc++-specific tests.
1 parent c63c2f4 commit 272da50

File tree

8 files changed

+81
-154
lines changed

8 files changed

+81
-154
lines changed

libcxx/test/libcxx/containers/sequences/forwardlist/bool-conversion.pass.cpp

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

libcxx/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp

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

libcxx/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp

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

libcxx/test/std/containers/sequences/forwardlist/forwardlist.erasure/erase.pass.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,25 @@ TEST_CONSTEXPR_CXX26 bool test() {
6969
test<std::forward_list<long>>();
7070
test<std::forward_list<double>>();
7171

72+
{ // Ensure that the result of operator== is converted to bool
73+
// See LWG4135.
74+
struct Bool {
75+
Bool() = default;
76+
Bool(const Bool&) = delete;
77+
operator bool() const { return true; }
78+
};
79+
80+
struct Int {
81+
Bool& operator==(Int) const {
82+
static Bool b;
83+
return b;
84+
}
85+
};
86+
87+
std::forward_list<Int> l;
88+
std::erase(l, Int{});
89+
}
90+
7291
return true;
7392
}
7493

libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ TEST_CONSTEXPR_CXX20 void emplaceable_concept_tests() {
127127
}
128128

129129
void test_ctor_under_alloc() {
130-
#if TEST_STD_VER >= 11
131130
int arr1[] = {42};
132131
int arr2[] = {1, 101, 42};
132+
#if TEST_STD_VER >= 11
133133
{
134134
using C = TCT::vector<>;
135135
using It = forward_iterator<int*>;
@@ -155,6 +155,35 @@ void test_ctor_under_alloc() {
155155
}
156156
}
157157
#endif
158+
// FIXME: This is mostly the same test as above, just worse. They should be merged.
159+
{
160+
typedef std::vector<int, cpp03_allocator<int> > C;
161+
typedef C::allocator_type Alloc;
162+
{
163+
Alloc::construct_called = false;
164+
C v(arr1, arr1 + 1);
165+
assert(Alloc::construct_called);
166+
}
167+
{
168+
Alloc::construct_called = false;
169+
C v(arr2, arr2 + 3);
170+
assert(Alloc::construct_called);
171+
}
172+
}
173+
{
174+
typedef std::vector<int, cpp03_overload_allocator<int> > C;
175+
typedef C::allocator_type Alloc;
176+
{
177+
Alloc::construct_called = false;
178+
C v(arr1, arr1 + 1);
179+
assert(Alloc::construct_called);
180+
}
181+
{
182+
Alloc::construct_called = false;
183+
C v(arr2, arr2 + 3);
184+
assert(Alloc::construct_called);
185+
}
186+
}
158187
}
159188

160189
// In C++03, you can't instantiate a template with a local type.

libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ TEST_CONSTEXPR_CXX20 void emplaceable_concept_tests() {
141141
}
142142

143143
void test_ctor_under_alloc() {
144-
#if TEST_STD_VER >= 11
145144
int arr1[] = {42};
146145
int arr2[] = {1, 101, 42};
146+
#if TEST_STD_VER >= 11
147147
{
148148
using C = TCT::vector<>;
149149
using It = forward_iterator<int*>;
@@ -173,6 +173,37 @@ void test_ctor_under_alloc() {
173173
}
174174
}
175175
#endif
176+
// FIXME: This is mostly the same test as above, just worse. They should be merged.
177+
{
178+
typedef std::vector<int, cpp03_allocator<int> > C;
179+
typedef C::allocator_type Alloc;
180+
Alloc a;
181+
{
182+
Alloc::construct_called = false;
183+
C v(arr1, arr1 + 1, a);
184+
assert(Alloc::construct_called);
185+
}
186+
{
187+
Alloc::construct_called = false;
188+
C v(arr2, arr2 + 3, a);
189+
assert(Alloc::construct_called);
190+
}
191+
}
192+
{
193+
typedef std::vector<int, cpp03_overload_allocator<int> > C;
194+
typedef C::allocator_type Alloc;
195+
Alloc a;
196+
{
197+
Alloc::construct_called = false;
198+
C v(arr1, arr1 + 1, a);
199+
assert(Alloc::construct_called);
200+
}
201+
{
202+
Alloc::construct_called = false;
203+
C v(arr2, arr2 + 3, a);
204+
assert(Alloc::construct_called);
205+
}
206+
}
176207
}
177208

178209
TEST_CONSTEXPR_CXX20 bool test() {

0 commit comments

Comments
 (0)