[libcxx-commits] [libcxx] [libc++][test] Cover move construction of allocators again (PR #110375)

via libcxx-commits libcxx-commits at lists.llvm.org
Sat Sep 28 10:15:49 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: A. Jiang (frederick-vs-ja)

<details>
<summary>Changes</summary>

Previous PR #<!-- -->107344 fixed move constructor of `test_allocator` but dropped test coverage for move construction in some cases. This PR attempts to restore the test coverage.

Thanks @<!-- -->Quuxplusone for reminding.

---
Full diff: https://github.com/llvm/llvm-project/pull/110375.diff


4 Files Affected:

- (modified) libcxx/test/std/containers/associative/map/map.cons/move.pass.cpp (+2) 
- (modified) libcxx/test/std/containers/associative/multimap/multimap.cons/move.pass.cpp (+2) 
- (modified) libcxx/test/std/containers/associative/multiset/multiset.cons/move.pass.cpp (+2) 
- (modified) libcxx/test/std/containers/associative/set/set.cons/move.pass.cpp (+2) 


``````````diff
diff --git a/libcxx/test/std/containers/associative/map/map.cons/move.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/move.pass.cpp
index 0afe64a93d7bdd..7a883bed0d6e8d 100644
--- a/libcxx/test/std/containers/associative/map/map.cons/move.pass.cpp
+++ b/libcxx/test/std/containers/associative/map/map.cons/move.pass.cpp
@@ -36,6 +36,7 @@ int main(int, char**)
         assert(std::distance(m.begin(), m.end()) == 0);
 
         assert(mo.get_allocator() == A(7));
+        assert(mo.get_allocator().get_id() == test_alloc_base::moved_value);
         assert(mo.key_comp() == C(5));
         assert(mo.size() == 0);
         assert(std::distance(mo.begin(), mo.end()) == 0);
@@ -66,6 +67,7 @@ int main(int, char**)
         assert(*std::next(m.begin(), 2) == V(3, 1));
 
         assert(mo.get_allocator() == A(7));
+        assert(mo.get_allocator().get_id() == test_alloc_base::moved_value);
         assert(mo.key_comp() == C(5));
         assert(mo.size() == 0);
         assert(std::distance(mo.begin(), mo.end()) == 0);
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/move.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/move.pass.cpp
index 6458231e9a4d3c..8227b81f0c05c5 100644
--- a/libcxx/test/std/containers/associative/multimap/multimap.cons/move.pass.cpp
+++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/move.pass.cpp
@@ -36,6 +36,7 @@ int main(int, char**)
         assert(std::distance(m.begin(), m.end()) == 0);
 
         assert(mo.get_allocator() == A(7));
+        assert(mo.get_allocator().get_id() == test_alloc_base::moved_value);
         assert(mo.key_comp() == C(5));
         assert(mo.size() == 0);
         assert(std::distance(mo.begin(), mo.end()) == 0);
@@ -72,6 +73,7 @@ int main(int, char**)
         assert(*std::next(m.begin(), 8) == V(3, 2));
 
         assert(mo.get_allocator() == A(7));
+        assert(mo.get_allocator().get_id() == test_alloc_base::moved_value);
         assert(mo.key_comp() == C(5));
         assert(mo.size() == 0);
         assert(std::distance(mo.begin(), mo.end()) == 0);
diff --git a/libcxx/test/std/containers/associative/multiset/multiset.cons/move.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.cons/move.pass.cpp
index 65d297d3bfd45d..63898747180ae7 100644
--- a/libcxx/test/std/containers/associative/multiset/multiset.cons/move.pass.cpp
+++ b/libcxx/test/std/containers/associative/multiset/multiset.cons/move.pass.cpp
@@ -36,6 +36,7 @@ int main(int, char**)
         assert(std::distance(m.begin(), m.end()) == 0);
 
         assert(mo.get_allocator() == A(7));
+        assert(mo.get_allocator().get_id() == test_alloc_base::moved_value);
         assert(mo.key_comp() == C(5));
         assert(mo.size() == 0);
         assert(std::distance(mo.begin(), mo.end()) == 0);
@@ -73,6 +74,7 @@ int main(int, char**)
         assert(*std::next(m.begin(), 8) == 3);
 
         assert(mo.get_allocator() == A(7));
+        assert(mo.get_allocator().get_id() == test_alloc_base::moved_value);
         assert(mo.key_comp() == C(5));
         assert(mo.size() == 0);
         assert(std::distance(mo.begin(), mo.end()) == 0);
diff --git a/libcxx/test/std/containers/associative/set/set.cons/move.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/move.pass.cpp
index 3824ea2d322b8a..3d6ab89ccf82fa 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/move.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/move.pass.cpp
@@ -36,6 +36,7 @@ int main(int, char**)
         assert(std::distance(m.begin(), m.end()) == 0);
 
         assert(mo.get_allocator() == A(7));
+        assert(mo.get_allocator().get_id() == test_alloc_base::moved_value);
         assert(mo.key_comp() == C(5));
         assert(mo.size() == 0);
         assert(std::distance(mo.begin(), mo.end()) == 0);
@@ -67,6 +68,7 @@ int main(int, char**)
         assert(*std::next(m.begin(), 2) == 3);
 
         assert(mo.get_allocator() == A(7));
+        assert(mo.get_allocator().get_id() == test_alloc_base::moved_value);
         assert(mo.key_comp() == C(5));
         assert(mo.size() == 0);
         assert(std::distance(mo.begin(), mo.end()) == 0);

``````````

</details>


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


More information about the libcxx-commits mailing list