[libcxx-commits] [libcxx] cfd24cd - [libc++][NFC] Inline function in string.cons/copy_alloc.pass.cpp that is used only once (#157429)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Sep 9 00:23:54 PDT 2025


Author: Nikolas Klauser
Date: 2025-09-09T09:23:50+02:00
New Revision: cfd24cd878d54c14f190776cc1e64f0be35fd07e

URL: https://github.com/llvm/llvm-project/commit/cfd24cd878d54c14f190776cc1e64f0be35fd07e
DIFF: https://github.com/llvm/llvm-project/commit/cfd24cd878d54c14f190776cc1e64f0be35fd07e.diff

LOG: [libc++][NFC] Inline function in string.cons/copy_alloc.pass.cpp that is used only once (#157429)

This makes the test a bit easier to understand.

Added: 
    

Modified: 
    libcxx/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp
index b0045cb4afbba..c4fd5afe83a44 100644
--- a/libcxx/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp
@@ -65,16 +65,6 @@ template <typename T, typename U>
 bool operator!=(const poca_alloc<T>& lhs, const poca_alloc<U>& rhs) {
   return lhs.imp != rhs.imp;
 }
-
-template <class S>
-TEST_CONSTEXPR_CXX20 void test_assign(S& s1, const S& s2) {
-  try {
-    s1 = s2;
-  } catch (std::bad_alloc&) {
-    return;
-  }
-  assert(false);
-}
 #endif
 
 template <class S>
@@ -122,7 +112,11 @@ TEST_CONSTEXPR_CXX20 bool test() {
     assert(s2 == p2);
 
     imp2.deactivate();
-    test_assign(s1, s2);
+    try {
+      s1 = s2;
+      assert(false);
+    } catch (std::bad_alloc&) {
+    }
     assert(s1 == p1);
     assert(s2 == p2);
   }


        


More information about the libcxx-commits mailing list