Skip to content

[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
merged 2 commits into from
Jul 25, 2025

Conversation

philnik777
Copy link
Contributor

These tests test standard behaviour, so they shouldn't be in the libc++-specific tests.

@philnik777 philnik777 requested a review from a team as a code owner July 23, 2025 09:44
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Jul 23, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 23, 2025

@llvm/pr-subscribers-libcxx

Author: Nikolas Klauser (philnik777)

Changes

These 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:

  • (removed) libcxx/test/libcxx/containers/sequences/forwardlist/bool-conversion.pass.cpp (-37)
  • (removed) libcxx/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp (-56)
  • (removed) libcxx/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp (-59)
  • (renamed) libcxx/test/std/containers/associative/map/find.modules.compile.pass.mm ()
  • (modified) libcxx/test/std/containers/sequences/forwardlist/forwardlist.erasure/erase.pass.cpp (+18)
  • (renamed) libcxx/test/std/containers/sequences/vector/erase.modules.compile.pass.mm ()
  • (modified) libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp (+30-1)
  • (modified) libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp (+32-1)
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() {

Copy link
Member

@ldionne ldionne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM w/ nitpick

@philnik777 philnik777 merged commit 272da50 into llvm:main Jul 25, 2025
11 of 15 checks passed
@philnik777 philnik777 deleted the move_tests_to_std branch July 25, 2025 08:46
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
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants