[libcxx-commits] [libcxx] [libc++][test] Add exception tests for vector capacity operations (PR #118141)

via libcxx-commits libcxx-commits at lists.llvm.org
Sun Dec 1 20:56:35 PST 2024


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 c4a1e0efe6b0767dfb5861a7e8814d7db0c0de8a 8119fc8ea0515b98a9054619729147e900b46a1b --extensions cpp,h -- libcxx/test/std/containers/sequences/vector/vector.capacity/reserve_exceptions.pass.cpp libcxx/test/std/containers/sequences/vector/vector.capacity/resize_exceptions.pass.cpp libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit_exceptions.pass.cpp libcxx/test/std/containers/sequences/vector/common.h libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp libcxx/test/support/test_allocator.h
``````````

</details>

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

``````````diff
diff --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit_exceptions.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit_exceptions.pass.cpp
index b546c6ee26..edb8f0c2c9 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit_exceptions.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit_exceptions.pass.cpp
@@ -64,7 +64,7 @@ void test_allocation_exceptions() {
     std::vector<int, limited_allocator<int, 101> > v(90, alloc);
     auto p = alloc.allocate(11);
     std::printf("Alloc remaining: %zu\n", v.get_allocator().alloc_max_remaining());
-    
+
     v.erase(v.end() - 10, v.end());
     std::printf("Alloc remaining: %zu\n", v.get_allocator().alloc_max_remaining());
     v.shrink_to_fit();
@@ -77,10 +77,10 @@ void test_allocation_exceptions() {
   check_new_delete_called();
 
   // {
-  //   limited_allocator<int, 101> alloc; 
-  //   std::vector<int, limited_allocator<int, 101> > v1(10, 42, alloc); 
+  //   limited_allocator<int, 101> alloc;
+  //   std::vector<int, limited_allocator<int, 101> > v1(10, 42, alloc);
   //   std::printf("Alloc remaining: %zu\n", alloc.alloc_max_remaining()); // 91
-  //   v1.reserve(20); 
+  //   v1.reserve(20);
   //   std::printf("Alloc remaining: %zu\n", alloc.alloc_max_remaining()); // 71?? 不应该是 81 吗?比较 v1 原始的长度 10 内存已经释放了呀!
   //   std::vector<int, limited_allocator<int, 101> > v2(70, 0, alloc); // 最大为 71??
   //   std::printf("Alloc remaining: %zu\n", alloc.alloc_max_remaining());

``````````

</details>


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


More information about the libcxx-commits mailing list