[libcxx-commits] [libcxx] [libc++][test] Cover move construction of allocators again (PR #110375)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Sep 28 18:20:41 PDT 2024
https://github.com/frederick-vs-ja updated https://github.com/llvm/llvm-project/pull/110375
>From 201cb187f80ff79b0edbdf6af5da4fb756fc7143 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Sun, 29 Sep 2024 09:20:06 +0800
Subject: [PATCH] [libc++][test] Cover move construction of allocators again
Previous PR fixed move constructor of `test_allocator` but dropped test
coverage for move construction in some cases. This PR attempts to
restore the test coverage.
---
.../test/std/containers/associative/map/map.cons/move.pass.cpp | 2 ++
.../containers/associative/multimap/multimap.cons/move.pass.cpp | 2 ++
.../containers/associative/multiset/multiset.cons/move.pass.cpp | 2 ++
.../test/std/containers/associative/set/set.cons/move.pass.cpp | 2 ++
.../std/containers/sequences/deque/deque.cons/move.pass.cpp | 1 +
5 files changed, 9 insertions(+)
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);
diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/move.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/move.pass.cpp
index daed255a5f3a75..b3f08da81ff5be 100644
--- a/libcxx/test/std/containers/sequences/deque/deque.cons/move.pass.cpp
+++ b/libcxx/test/std/containers/sequences/deque/deque.cons/move.pass.cpp
@@ -39,6 +39,7 @@ int main(int, char**)
assert(c1.size() == 0);
assert(c3.get_allocator() == old_a);
assert(c1.get_allocator() == A(1));
+ assert(c1.get_allocator().get_id() == test_alloc_base::moved_value);
LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c1));
LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c2));
LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c3));
More information about the libcxx-commits
mailing list