-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[libc++] Move a bunch of tests from libcxx/test/libcxx to libcxx/test/std #150199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-libcxx Author: Nikolas Klauser (philnik777) ChangesThese tests test standard behaviour, so they shouldn't be in the libc++-specific tests. Full diff: https://github.com/llvm/llvm-project/pull/150199.diff 8 Files Affected:
diff --git a/libcxx/test/libcxx/containers/sequences/forwardlist/bool-conversion.pass.cpp b/libcxx/test/libcxx/containers/sequences/forwardlist/bool-conversion.pass.cpp
deleted file mode 100644
index 237b0f155c7be..0000000000000
--- a/libcxx/test/libcxx/containers/sequences/forwardlist/bool-conversion.pass.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// REQUIRES: std-at-least-c++20
-
-// <forward_list>
-
-// This test shows the effect of implementing `LWG4135`, before it this code
-// was ill-formed, as the predicate is not bool. `LWG4135` suggests that
-// std::erase explicitly specifying the lambda's return type as bool.
-
-#include <forward_list>
-
-struct Bool {
- Bool() = default;
- Bool(const Bool&) = delete;
- operator bool() const { return true; }
-};
-
-struct Int {
- Bool& operator==(Int) const {
- static Bool b;
- return b;
- }
-};
-
-int main(int, char**) {
- std::forward_list<Int> l;
- std::erase(l, Int{});
-
- return 0;
-}
diff --git a/libcxx/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
deleted file mode 100644
index 9e3fb886e6075..0000000000000
--- a/libcxx/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// <vector>
-
-// template <class InputIter> vector(InputIter first, InputIter last);
-
-#include <vector>
-#include <cassert>
-
-#include "test_macros.h"
-#include "min_allocator.h"
-
-void test_ctor_under_alloc() {
- int arr1[] = {42};
- int arr2[] = {1, 101, 42};
- {
- typedef std::vector<int, cpp03_allocator<int> > C;
- typedef C::allocator_type Alloc;
- {
- Alloc::construct_called = false;
- C v(arr1, arr1 + 1);
- assert(Alloc::construct_called);
- }
- {
- Alloc::construct_called = false;
- C v(arr2, arr2 + 3);
- assert(Alloc::construct_called);
- }
- }
- {
- typedef std::vector<int, cpp03_overload_allocator<int> > C;
- typedef C::allocator_type Alloc;
- {
- Alloc::construct_called = false;
- C v(arr1, arr1 + 1);
- assert(Alloc::construct_called);
- }
- {
- Alloc::construct_called = false;
- C v(arr2, arr2 + 3);
- assert(Alloc::construct_called);
- }
- }
-}
-
-int main(int, char**) {
- test_ctor_under_alloc();
-
- return 0;
-}
diff --git a/libcxx/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
deleted file mode 100644
index fa1bd2d4fda32..0000000000000
--- a/libcxx/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// <vector>
-
-// template <class InputIter> vector(InputIter first, InputIter last,
-// const allocator_type& a);
-
-#include <vector>
-#include <cassert>
-
-#include "test_macros.h"
-#include "min_allocator.h"
-
-void test_ctor_under_alloc() {
- int arr1[] = {42};
- int arr2[] = {1, 101, 42};
- {
- typedef std::vector<int, cpp03_allocator<int> > C;
- typedef C::allocator_type Alloc;
- Alloc a;
- {
- Alloc::construct_called = false;
- C v(arr1, arr1 + 1, a);
- assert(Alloc::construct_called);
- }
- {
- Alloc::construct_called = false;
- C v(arr2, arr2 + 3, a);
- assert(Alloc::construct_called);
- }
- }
- {
- typedef std::vector<int, cpp03_overload_allocator<int> > C;
- typedef C::allocator_type Alloc;
- Alloc a;
- {
- Alloc::construct_called = false;
- C v(arr1, arr1 + 1, a);
- assert(Alloc::construct_called);
- }
- {
- Alloc::construct_called = false;
- C v(arr2, arr2 + 3, a);
- assert(Alloc::construct_called);
- }
- }
-}
-
-int main(int, char**) {
- test_ctor_under_alloc();
-
- return 0;
-}
diff --git a/libcxx/test/libcxx/containers/associative/map/find.modules.compile.pass.mm b/libcxx/test/std/containers/associative/map/find.modules.compile.pass.mm
similarity index 100%
rename from libcxx/test/libcxx/containers/associative/map/find.modules.compile.pass.mm
rename to libcxx/test/std/containers/associative/map/find.modules.compile.pass.mm
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.erasure/erase.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.erasure/erase.pass.cpp
index 86d7769fe16ee..630e01a0f36cc 100644
--- a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.erasure/erase.pass.cpp
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.erasure/erase.pass.cpp
@@ -69,6 +69,24 @@ TEST_CONSTEXPR_CXX26 bool test() {
test<std::forward_list<long>>();
test<std::forward_list<double>>();
+ { // Ensure that the result of operator== is converted to bool
+ struct Bool {
+ Bool() = default;
+ Bool(const Bool&) = delete;
+ operator bool() const { return true; }
+ };
+
+ struct Int {
+ Bool& operator==(Int) const {
+ static Bool b;
+ return b;
+ }
+ };
+
+ std::forward_list<Int> l;
+ std::erase(l, Int{});
+ }
+
return true;
}
diff --git a/libcxx/test/libcxx/containers/sequences/vector/erase.modules.compile.pass.mm b/libcxx/test/std/containers/sequences/vector/erase.modules.compile.pass.mm
similarity index 100%
rename from libcxx/test/libcxx/containers/sequences/vector/erase.modules.compile.pass.mm
rename to libcxx/test/std/containers/sequences/vector/erase.modules.compile.pass.mm
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
index bac2ea2b4ca1e..6549735f7b511 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
@@ -127,9 +127,9 @@ TEST_CONSTEXPR_CXX20 void emplaceable_concept_tests() {
}
void test_ctor_under_alloc() {
-#if TEST_STD_VER >= 11
int arr1[] = {42};
int arr2[] = {1, 101, 42};
+#if TEST_STD_VER >= 11
{
using C = TCT::vector<>;
using It = forward_iterator<int*>;
@@ -155,6 +155,35 @@ void test_ctor_under_alloc() {
}
}
#endif
+ // FIXME: This is mostly the same test as above, just worse. They should be merged.
+ {
+ typedef std::vector<int, cpp03_allocator<int> > C;
+ typedef C::allocator_type Alloc;
+ {
+ Alloc::construct_called = false;
+ C v(arr1, arr1 + 1);
+ assert(Alloc::construct_called);
+ }
+ {
+ Alloc::construct_called = false;
+ C v(arr2, arr2 + 3);
+ assert(Alloc::construct_called);
+ }
+ }
+ {
+ typedef std::vector<int, cpp03_overload_allocator<int> > C;
+ typedef C::allocator_type Alloc;
+ {
+ Alloc::construct_called = false;
+ C v(arr1, arr1 + 1);
+ assert(Alloc::construct_called);
+ }
+ {
+ Alloc::construct_called = false;
+ C v(arr2, arr2 + 3);
+ assert(Alloc::construct_called);
+ }
+ }
}
// In C++03, you can't instantiate a template with a local type.
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
index de325040f4a19..019f427c006a1 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
@@ -141,9 +141,9 @@ TEST_CONSTEXPR_CXX20 void emplaceable_concept_tests() {
}
void test_ctor_under_alloc() {
-#if TEST_STD_VER >= 11
int arr1[] = {42};
int arr2[] = {1, 101, 42};
+#if TEST_STD_VER >= 11
{
using C = TCT::vector<>;
using It = forward_iterator<int*>;
@@ -173,6 +173,37 @@ void test_ctor_under_alloc() {
}
}
#endif
+ // FIXME: This is mostly the same test as above, just worse. They should be merged.
+ {
+ typedef std::vector<int, cpp03_allocator<int> > C;
+ typedef C::allocator_type Alloc;
+ Alloc a;
+ {
+ Alloc::construct_called = false;
+ C v(arr1, arr1 + 1, a);
+ assert(Alloc::construct_called);
+ }
+ {
+ Alloc::construct_called = false;
+ C v(arr2, arr2 + 3, a);
+ assert(Alloc::construct_called);
+ }
+ }
+ {
+ typedef std::vector<int, cpp03_overload_allocator<int> > C;
+ typedef C::allocator_type Alloc;
+ Alloc a;
+ {
+ Alloc::construct_called = false;
+ C v(arr1, arr1 + 1, a);
+ assert(Alloc::construct_called);
+ }
+ {
+ Alloc::construct_called = false;
+ C v(arr2, arr2 + 3, a);
+ assert(Alloc::construct_called);
+ }
+ }
}
TEST_CONSTEXPR_CXX20 bool test() {
|
ldionne
approved these changes
Jul 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM w/ nitpick
libcxx/test/std/containers/sequences/forwardlist/forwardlist.erasure/erase.pass.cpp
Show resolved
Hide resolved
…rasure/erase.pass.cpp Co-authored-by: Louis Dionne <[email protected]>
mahesh-attarde
pushed a commit
to mahesh-attarde/llvm-project
that referenced
this pull request
Jul 28, 2025
…/std (llvm#150199) These tests test standard behaviour, so they shouldn't be in the libc++-specific tests.
ajaden-codes
pushed a commit
to Jaddyen/llvm-project
that referenced
this pull request
Jul 28, 2025
…/std (llvm#150199) These tests test standard behaviour, so they shouldn't be in the libc++-specific tests.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These tests test standard behaviour, so they shouldn't be in the libc++-specific tests.