[libcxx-commits] [libcxx] [libc++] Move some standard tests from test/libcxx (PR #152982)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Aug 11 02:31:36 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp -- libcxx/test/std/language.support/support.c.headers/support.c.headers.other/math.lerp.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_for.signals.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/visibility_inlines_hidden.cpp libcxx/test/std/utilities/function.objects/refwrap/binary.pass.cpp libcxx/test/std/utilities/function.objects/refwrap/unary.pass.cpp libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/race_condition.pass.cpp libcxx/test/std/utilities/utility/pairs/pairs.pair/pair.incomplete.compile.pass.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libcxx/test/std/language.support/support.c.headers/support.c.headers.other/math.lerp.pass.cpp b/libcxx/test/std/language.support/support.c.headers/support.c.headers.other/math.lerp.pass.cpp
index 5267f6f52..f1dd021d2 100644
--- a/libcxx/test/std/language.support/support.c.headers/support.c.headers.other/math.lerp.pass.cpp
+++ b/libcxx/test/std/language.support/support.c.headers/support.c.headers.other/math.lerp.pass.cpp
@@ -16,13 +16,19 @@
 #include <math.h>
 
 template <class = int>
-int lerp(float, float, float) { return 32; }
+int lerp(float, float, float) {
+  return 32;
+}
 
 template <class = int>
-int lerp(double, double, double) { return 32; }
+int lerp(double, double, double) {
+  return 32;
+}
 
 template <class = int>
-int lerp(long double, long double, long double) { return 32; }
+int lerp(long double, long double, long double) {
+  return 32;
+}
 
 int main(int, char**) {
   assert(lerp(0.f, 0.f, 0.f) == 32);
diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp
index e64a873fa..75479966a 100644
--- a/libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp
+++ b/libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp
@@ -19,8 +19,7 @@
 #include <cassert>
 #include <chrono>
 
-int main(int, char**)
-{
+int main(int, char**) {
   typedef std::chrono::system_clock Clock;
   typedef Clock::time_point time_point;
   std::chrono::milliseconds ms(500);
diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_for.signals.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_for.signals.pass.cpp
index 1dba5d8a4..c7baa7ab2 100644
--- a/libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_for.signals.pass.cpp
+++ b/libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_for.signals.pass.cpp
@@ -33,8 +33,7 @@
 
 void sig_action(int) {}
 
-int main(int, char**)
-{
+int main(int, char**) {
   int ec;
   struct sigaction action;
   action.sa_handler = &sig_action;
@@ -46,7 +45,7 @@ int main(int, char**)
 
   struct itimerval it;
   std::memset(&it, 0, sizeof(itimerval));
-  it.it_value.tv_sec = 0;
+  it.it_value.tv_sec  = 0;
   it.it_value.tv_usec = 250000;
   // This will result in a SIGALRM getting fired resulting in the nanosleep
   // inside sleep_for getting EINTR.
diff --git a/libcxx/test/std/utilities/function.objects/refwrap/binary.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/binary.pass.cpp
index f14359f54..194075308 100644
--- a/libcxx/test/std/utilities/function.objects/refwrap/binary.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/refwrap/binary.pass.cpp
@@ -21,67 +21,52 @@
 
 #include "test_macros.h"
 
-class functor1
-    : public std::unary_function<int, char>
-{
-};
+class functor1 : public std::unary_function<int, char> {};
 
-class functor2
-    : public std::binary_function<char, int, double>
-{
-};
+class functor2 : public std::binary_function<char, int, double> {};
 
-class functor3
-    : public std::unary_function<int, int>,
-      public std::binary_function<char, int, double>
-{
+class functor3 : public std::unary_function<int, int>, public std::binary_function<char, int, double> {
 public:
-    typedef float result_type;
+  typedef float result_type;
 };
 
-class functor4
-    : public std::unary_function<int, int>,
-      public std::binary_function<char, int, double>
-{
+class functor4 : public std::unary_function<int, int>, public std::binary_function<char, int, double> {
 public:
 };
 
-struct C
-{
-    typedef int argument_type;
-    typedef int result_type;
+struct C {
+  typedef int argument_type;
+  typedef int result_type;
 };
 
-int main(int, char**)
-{
-    static_assert((!std::is_base_of<std::binary_function<int, char, int>,
-                                    std::reference_wrapper<functor1> >::value), "");
-    static_assert((std::is_base_of<std::binary_function<char, int, double>,
-                                   std::reference_wrapper<functor2> >::value), "");
-    static_assert((std::is_base_of<std::binary_function<char, int, double>,
-                                   std::reference_wrapper<functor3> >::value), "");
-    static_assert((std::is_base_of<std::binary_function<char, int, double>,
-                                   std::reference_wrapper<functor4> >::value), "");
-    static_assert((!std::is_base_of<std::binary_function<int, int, int>,
-                                    std::reference_wrapper<C> >::value), "");
-    static_assert((!std::is_base_of<std::binary_function<int, int, float>,
-                                    std::reference_wrapper<float ()> >::value), "");
-    static_assert((!std::is_base_of<std::binary_function<int, int, float>,
-                                   std::reference_wrapper<float (int)> >::value), "");
-    static_assert((std::is_base_of<std::binary_function<int, int, float>,
-                                    std::reference_wrapper<float (int, int)> >::value), "");
-    static_assert((!std::is_base_of<std::binary_function<int, int, float>,
-                                    std::reference_wrapper<float(*)()> >::value), "");
-    static_assert((!std::is_base_of<std::binary_function<int, int, float>,
-                                   std::reference_wrapper<float(*)(int)> >::value), "");
-    static_assert((std::is_base_of<std::binary_function<int, int, float>,
-                                    std::reference_wrapper<float(*)(int, int)> >::value), "");
-    static_assert((!std::is_base_of<std::binary_function<C*, int, float>,
-                                   std::reference_wrapper<float(C::*)()> >::value), "");
-    static_assert((std::is_base_of<std::binary_function<C*, int, float>,
-                                   std::reference_wrapper<float(C::*)(int)> >::value), "");
-    static_assert((std::is_base_of<std::binary_function<const volatile C*, int, float>,
-                                   std::reference_wrapper<float(C::*)(int) const volatile> >::value), "");
+int main(int, char**) {
+  static_assert((!std::is_base_of<std::binary_function<int, char, int>, std::reference_wrapper<functor1> >::value), "");
+  static_assert(
+      (std::is_base_of<std::binary_function<char, int, double>, std::reference_wrapper<functor2> >::value), "");
+  static_assert(
+      (std::is_base_of<std::binary_function<char, int, double>, std::reference_wrapper<functor3> >::value), "");
+  static_assert(
+      (std::is_base_of<std::binary_function<char, int, double>, std::reference_wrapper<functor4> >::value), "");
+  static_assert((!std::is_base_of<std::binary_function<int, int, int>, std::reference_wrapper<C> >::value), "");
+  static_assert((!std::is_base_of<std::binary_function<int, int, float>, std::reference_wrapper<float()> >::value), "");
+  static_assert(
+      (!std::is_base_of<std::binary_function<int, int, float>, std::reference_wrapper<float(int)> >::value), "");
+  static_assert(
+      (std::is_base_of<std::binary_function<int, int, float>, std::reference_wrapper<float(int, int)> >::value), "");
+  static_assert(
+      (!std::is_base_of<std::binary_function<int, int, float>, std::reference_wrapper<float (*)()> >::value), "");
+  static_assert(
+      (!std::is_base_of<std::binary_function<int, int, float>, std::reference_wrapper<float (*)(int)> >::value), "");
+  static_assert(
+      (std::is_base_of<std::binary_function<int, int, float>, std::reference_wrapper<float (*)(int, int)> >::value),
+      "");
+  static_assert(
+      (!std::is_base_of<std::binary_function<C*, int, float>, std::reference_wrapper<float (C::*)()> >::value), "");
+  static_assert(
+      (std::is_base_of<std::binary_function<C*, int, float>, std::reference_wrapper<float (C::*)(int)> >::value), "");
+  static_assert((std::is_base_of<std::binary_function<const volatile C*, int, float>,
+                                 std::reference_wrapper<float (C::*)(int) const volatile> >::value),
+                "");
 
   return 0;
 }
diff --git a/libcxx/test/std/utilities/function.objects/refwrap/unary.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/unary.pass.cpp
index 4d7ab16ec..ef9dcb4ec 100644
--- a/libcxx/test/std/utilities/function.objects/refwrap/unary.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/refwrap/unary.pass.cpp
@@ -21,65 +21,43 @@
 
 #include "test_macros.h"
 
-class functor1
-    : public std::unary_function<int, char>
-{
-};
+class functor1 : public std::unary_function<int, char> {};
 
-class functor2
-    : public std::binary_function<char, int, double>
-{
-};
+class functor2 : public std::binary_function<char, int, double> {};
 
-class functor3
-    : public std::unary_function<int, int>,
-      public std::binary_function<char, int, double>
-{
+class functor3 : public std::unary_function<int, int>, public std::binary_function<char, int, double> {
 public:
-    typedef float result_type;
+  typedef float result_type;
 };
 
-class functor4
-    : public std::unary_function<int, int>,
-      public std::binary_function<char, int, double>
-{
+class functor4 : public std::unary_function<int, int>, public std::binary_function<char, int, double> {
 public:
 };
 
-struct C
-{
-    typedef int argument_type;
-    typedef int result_type;
+struct C {
+  typedef int argument_type;
+  typedef int result_type;
 };
 
-int main(int, char**)
-{
-    static_assert((std::is_base_of<std::unary_function<int, char>,
-                                   std::reference_wrapper<functor1> >::value), "");
-    static_assert((!std::is_base_of<std::unary_function<char, int>,
-                                    std::reference_wrapper<functor2> >::value), "");
-    static_assert((std::is_base_of<std::unary_function<int, int>,
-                                   std::reference_wrapper<functor3> >::value), "");
-    static_assert((std::is_base_of<std::unary_function<int, int>,
-                                   std::reference_wrapper<functor4> >::value), "");
-    static_assert((!std::is_base_of<std::unary_function<int, int>,
-                                    std::reference_wrapper<C> >::value), "");
-    static_assert((!std::is_base_of<std::unary_function<int, float>,
-                                    std::reference_wrapper<float(*)()> >::value), "");
-    static_assert((std::is_base_of<std::unary_function<int, float>,
-                                   std::reference_wrapper<float (int)> >::value), "");
-    static_assert((!std::is_base_of<std::unary_function<int, float>,
-                                    std::reference_wrapper<float (int, int)> >::value), "");
-    static_assert((std::is_base_of<std::unary_function<int, float>,
-                                   std::reference_wrapper<float(*)(int)> >::value), "");
-    static_assert((!std::is_base_of<std::unary_function<int, float>,
-                                    std::reference_wrapper<float(*)(int, int)> >::value), "");
-    static_assert((std::is_base_of<std::unary_function<C*, float>,
-                                   std::reference_wrapper<float(C::*)()> >::value), "");
-    static_assert((std::is_base_of<std::unary_function<const volatile C*, float>,
-                                   std::reference_wrapper<float(C::*)() const volatile> >::value), "");
-    static_assert((!std::is_base_of<std::unary_function<C*, float>,
-                                   std::reference_wrapper<float(C::*)(int)> >::value), "");
+int main(int, char**) {
+  static_assert((std::is_base_of<std::unary_function<int, char>, std::reference_wrapper<functor1> >::value), "");
+  static_assert((!std::is_base_of<std::unary_function<char, int>, std::reference_wrapper<functor2> >::value), "");
+  static_assert((std::is_base_of<std::unary_function<int, int>, std::reference_wrapper<functor3> >::value), "");
+  static_assert((std::is_base_of<std::unary_function<int, int>, std::reference_wrapper<functor4> >::value), "");
+  static_assert((!std::is_base_of<std::unary_function<int, int>, std::reference_wrapper<C> >::value), "");
+  static_assert((!std::is_base_of<std::unary_function<int, float>, std::reference_wrapper<float (*)()> >::value), "");
+  static_assert((std::is_base_of<std::unary_function<int, float>, std::reference_wrapper<float(int)> >::value), "");
+  static_assert(
+      (!std::is_base_of<std::unary_function<int, float>, std::reference_wrapper<float(int, int)> >::value), "");
+  static_assert((std::is_base_of<std::unary_function<int, float>, std::reference_wrapper<float (*)(int)> >::value), "");
+  static_assert(
+      (!std::is_base_of<std::unary_function<int, float>, std::reference_wrapper<float (*)(int, int)> >::value), "");
+  static_assert((std::is_base_of<std::unary_function<C*, float>, std::reference_wrapper<float (C::*)()> >::value), "");
+  static_assert((std::is_base_of<std::unary_function<const volatile C*, float>,
+                                 std::reference_wrapper<float (C::*)() const volatile> >::value),
+                "");
+  static_assert(
+      (!std::is_base_of<std::unary_function<C*, float>, std::reference_wrapper<float (C::*)(int)> >::value), "");
 
   return 0;
 }
diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/race_condition.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/race_condition.pass.cpp
index cbecd2d1d..896df13c3 100644
--- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/race_condition.pass.cpp
+++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/race_condition.pass.cpp
@@ -30,54 +30,57 @@ std::atomic_bool Start;
 std::atomic_bool KeepRunning;
 
 struct TestRunner {
-    TestRunner(Ptr xx) : x(xx) {}
-    void operator()() {
-        while (Start == false) {}
-        while (KeepRunning) {
-            // loop to prevent always checking the atomic.
-            for (int i=0; i < 100000; ++i) {
-                Ptr x2 = x; // increment shared count
-                WeakPtr x3 = x; // increment weak count
-                Ptr x4 = x3.lock(); // increment shared count via lock
-                WeakPtr x5 = x3; // increment weak count
-            }
-        }
+  TestRunner(Ptr xx) : x(xx) {}
+  void operator()() {
+    while (Start == false) {
     }
-    Ptr x;
+    while (KeepRunning) {
+      // loop to prevent always checking the atomic.
+      for (int i = 0; i < 100000; ++i) {
+        Ptr x2     = x;         // increment shared count
+        WeakPtr x3 = x;         // increment weak count
+        Ptr x4     = x3.lock(); // increment shared count via lock
+        WeakPtr x5 = x3;        // increment weak count
+      }
+    }
+  }
+  Ptr x;
 };
 
 void run_test(Ptr p) {
-    Start = false;
-    KeepRunning = true;
-    assert(p.use_count() == 2);
-    TestRunner r(p);
-    assert(p.use_count() == 3);
-    std::thread t1 = support::make_test_thread(r); // Start the test thread.
-    assert(p.use_count() == 4);
-    Start = true;
-    // Run until we witness 25 use count changes via both
-    // shared and weak pointer methods.
-    WeakPtr w = p;
-    int shared_changes_count = 0;
-    int weak_changes_count = 0;
-    while (shared_changes_count < 25 && weak_changes_count < 25) {
-        // check use_count on the shared_ptr
-       int last = p.use_count();
-       int new_val = p.use_count();
-       assert(last >= 4);
-       assert(new_val >= 4);
-       if (last != new_val) ++shared_changes_count;
-       // Check use_count on the weak_ptr
-       last = w.use_count();
-       new_val = w.use_count();
-       assert(last >= 4);
-       assert(new_val >= 4);
-       if (last != new_val) ++weak_changes_count;
-    }
-    // kill the test thread.
-    KeepRunning = false;
-    t1.join();
-    assert(p.use_count() == 3);
+  Start       = false;
+  KeepRunning = true;
+  assert(p.use_count() == 2);
+  TestRunner r(p);
+  assert(p.use_count() == 3);
+  std::thread t1 = support::make_test_thread(r); // Start the test thread.
+  assert(p.use_count() == 4);
+  Start = true;
+  // Run until we witness 25 use count changes via both
+  // shared and weak pointer methods.
+  WeakPtr w                = p;
+  int shared_changes_count = 0;
+  int weak_changes_count   = 0;
+  while (shared_changes_count < 25 && weak_changes_count < 25) {
+    // check use_count on the shared_ptr
+    int last    = p.use_count();
+    int new_val = p.use_count();
+    assert(last >= 4);
+    assert(new_val >= 4);
+    if (last != new_val)
+      ++shared_changes_count;
+    // Check use_count on the weak_ptr
+    last    = w.use_count();
+    new_val = w.use_count();
+    assert(last >= 4);
+    assert(new_val >= 4);
+    if (last != new_val)
+      ++weak_changes_count;
+  }
+  // kill the test thread.
+  KeepRunning = false;
+  t1.join();
+  assert(p.use_count() == 3);
 }
 
 int main(int, char**) {
@@ -90,7 +93,7 @@ int main(int, char**) {
   {
     // Test with in-place shared_count.
     int val = 42;
-    Ptr p = std::make_shared<int>(val);
+    Ptr p   = std::make_shared<int>(val);
     run_test(p);
     assert(p.use_count() == 1);
   }

``````````

</details>


https://github.com/llvm/llvm-project/pull/152982


More information about the libcxx-commits mailing list