[libcxx-commits] [libcxx] [libc++] Improve test coverage for copy/move ctors for vector<bool> (PR #120132)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Mar 19 09:06:16 PDT 2025
================
@@ -9,63 +9,79 @@
// UNSUPPORTED: c++03
// <vector>
+// vector<bool>
// vector(vector&& c, const allocator_type& a);
-#include <vector>
+#include <array>
#include <cassert>
-#include "test_macros.h"
-#include "test_allocator.h"
+#include <vector>
+
#include "min_allocator.h"
+#include "test_allocator.h"
+#include "test_macros.h"
+
+template <unsigned N, class A>
+TEST_CONSTEXPR_CXX20 void test(const A& a, const A& a0) {
+ std::vector<bool, A> v(N, false, a);
+ std::vector<bool, A> v0(N, false, a0);
+ for (unsigned i = 1; i < N; i += 2) {
+ v[i] = true;
+ v0[i] = true;
+ }
+ std::vector<bool, A> v2(std::move(v), a0);
+ assert(v2 == v0);
+ assert(v2.get_allocator() == a0);
+ if (a == a0)
+ assert(v.empty()); // After container-move, the vector is guarantted to be empty
----------------
ldionne wrote:
```suggestion
assert(v.empty()); // After container-move, the vector is guaranteed to be empty
```
https://github.com/llvm/llvm-project/pull/120132
More information about the libcxx-commits
mailing list