[libcxx-commits] [PATCH] D57903: [libcxx] Add missing checks to tests for the move w/allocator constructors of associative containers.
Andrey Maksimov via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Feb 7 09:37:34 PST 2019
amakc11 created this revision.
amakc11 added a reviewer: mclow.lists.
Herald added a reviewer: EricWF.
Herald added subscribers: libcxx-commits, ldionne.
This patch is a continuation of rCXX352512 <https://reviews.llvm.org/rCXX352512>. This revision appears to be incomplete. It makes possible for the source containers to remain not empty after move construction of another container. In this case, less deallocations will be registered by `test_allocator` with counter. So, checks on `Counter_base::gConstructed` also require modification provided by this patch.
Repository:
rCXX libc++
https://reviews.llvm.org/D57903
Files:
test/std/containers/associative/map/map.cons/move_alloc.pass.cpp
test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp
test/std/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp
test/std/containers/associative/set/set.cons/move_alloc.pass.cpp
Index: test/std/containers/associative/set/set.cons/move_alloc.pass.cpp
===================================================================
--- test/std/containers/associative/set/set.cons/move_alloc.pass.cpp
+++ test/std/containers/associative/set/set.cons/move_alloc.pass.cpp
@@ -172,15 +172,15 @@
M m3(std::move(m1), A());
assert(m3 == m2);
LIBCPP_ASSERT(m1.empty());
- assert(Counter_base::gConstructed == 6+num);
+ assert(Counter_base::gConstructed == (m1.empty()?0:3)+6+num);
{
M m4(std::move(m2), A(5));
- assert(Counter_base::gConstructed == 6+num);
+ assert(Counter_base::gConstructed == (m1.empty()?0:3)+(m2.empty()?0:3)+6+num);
assert(m4 == m3);
LIBCPP_ASSERT(m2.empty());
}
- assert(Counter_base::gConstructed == 3+num);
+ assert(Counter_base::gConstructed == (m1.empty()?0:3)+(m2.empty()?0:3)+3+num);
}
assert(Counter_base::gConstructed == 0);
}
Index: test/std/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp
===================================================================
--- test/std/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp
+++ test/std/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp
@@ -172,15 +172,15 @@
M m3(std::move(m1), A());
assert(m3 == m2);
LIBCPP_ASSERT(m1.empty());
- assert(Counter_base::gConstructed == 3*num);
+ assert(Counter_base::gConstructed == (3+(m1.empty()?0:1))*num);
{
M m4(std::move(m2), A(5));
- assert(Counter_base::gConstructed == 3*num);
+ assert(Counter_base::gConstructed == (3+(m1.empty()?0:1)+(m2.empty()?0:1))*num);
assert(m4 == m3);
LIBCPP_ASSERT(m2.empty());
}
- assert(Counter_base::gConstructed == 2*num);
+ assert(Counter_base::gConstructed == (2+(m1.empty()?0:1))*num);
}
assert(Counter_base::gConstructed == 0);
}
Index: test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp
===================================================================
--- test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp
+++ test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp
@@ -178,15 +178,15 @@
M m3(std::move(m1), A());
assert(m3 == m2);
LIBCPP_ASSERT(m1.empty());
- assert(Counter_base::gConstructed == 3*num);
+ assert(Counter_base::gConstructed == (3+(m1.empty()?0:1))*num);
{
M m4(std::move(m2), A(5));
- assert(Counter_base::gConstructed == 3*num);
+ assert(Counter_base::gConstructed == (3+(m1.empty()?0:1)+(m2.empty()?0:1))*num);
assert(m4 == m3);
LIBCPP_ASSERT(m2.empty());
}
- assert(Counter_base::gConstructed == 2*num);
+ assert(Counter_base::gConstructed == (2+(m1.empty()?0:1)+(m2.empty()?0:1))*num);
}
assert(Counter_base::gConstructed == 0);
}
Index: test/std/containers/associative/map/map.cons/move_alloc.pass.cpp
===================================================================
--- test/std/containers/associative/map/map.cons/move_alloc.pass.cpp
+++ test/std/containers/associative/map/map.cons/move_alloc.pass.cpp
@@ -178,15 +178,15 @@
M m3(std::move(m1), A());
assert(m3 == m2);
LIBCPP_ASSERT(m1.empty());
- assert(Counter_base::gConstructed == num+6);
+ assert(Counter_base::gConstructed == num+6+(m1.empty()?0:3));
{
M m4(std::move(m2), A(5));
- assert(Counter_base::gConstructed == num+6);
+ assert(Counter_base::gConstructed == num+6+(m1.empty()?0:3)+(m2.empty()?0:3));
assert(m4 == m3);
LIBCPP_ASSERT(m2.empty());
}
- assert(Counter_base::gConstructed == num+3);
+ assert(Counter_base::gConstructed == num+3+(m1.empty()?0:3)+(m2.empty()?0:3));
}
assert(Counter_base::gConstructed == 0);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57903.185789.patch
Type: text/x-patch
Size: 4271 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190207/ed30ecfa/attachment.bin>
More information about the libcxx-commits
mailing list