[libcxx-commits] [libcxx] r353955 - [libcxx] Do not assume the number of elements in a moved-from associative container
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Feb 13 08:43:44 PST 2019
Author: ldionne
Date: Wed Feb 13 08:43:44 2019
New Revision: 353955
URL: http://llvm.org/viewvc/llvm-project?rev=353955&view=rev
Log:
[libcxx] Do not assume the number of elements in a moved-from associative container
Reviewed as https://reviews.llvm.org/D57903.
Thanks to Andrey Maksimov for the patch.
Modified:
libcxx/trunk/test/std/containers/associative/map/map.cons/move_alloc.pass.cpp
libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp
libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp
libcxx/trunk/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp
Modified: libcxx/trunk/test/std/containers/associative/map/map.cons/move_alloc.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/map/map.cons/move_alloc.pass.cpp?rev=353955&r1=353954&r2=353955&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/associative/map/map.cons/move_alloc.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/associative/map/map.cons/move_alloc.pass.cpp Wed Feb 13 08:43:44 2019
@@ -178,15 +178,18 @@ int main(int, char**)
M m3(std::move(m1), A());
assert(m3 == m2);
LIBCPP_ASSERT(m1.empty());
- assert(Counter_base::gConstructed == num+6);
+ assert(Counter_base::gConstructed >= (int)(num+6));
+ assert(Counter_base::gConstructed <= (int)(num+6+m1.size()));
{
M m4(std::move(m2), A(5));
- assert(Counter_base::gConstructed == num+6);
+ assert(Counter_base::gConstructed >= (int)(num+6));
+ assert(Counter_base::gConstructed <= (int)(num+6+m1.size()+m2.size()));
assert(m4 == m3);
LIBCPP_ASSERT(m2.empty());
}
- assert(Counter_base::gConstructed == num+3);
+ assert(Counter_base::gConstructed >= (int)(num+3));
+ assert(Counter_base::gConstructed <= (int)(num+3+m1.size()+m2.size()));
}
assert(Counter_base::gConstructed == 0);
}
Modified: libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp?rev=353955&r1=353954&r2=353955&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp Wed Feb 13 08:43:44 2019
@@ -178,15 +178,18 @@ int main(int, char**)
M m3(std::move(m1), A());
assert(m3 == m2);
LIBCPP_ASSERT(m1.empty());
- assert(Counter_base::gConstructed == 3*num);
+ assert(Counter_base::gConstructed >= (int)(3*num));
+ assert(Counter_base::gConstructed <= (int)(4*num));
{
M m4(std::move(m2), A(5));
- assert(Counter_base::gConstructed == 3*num);
+ assert(Counter_base::gConstructed >= (int)(3*num));
+ assert(Counter_base::gConstructed <= (int)(5*num));
assert(m4 == m3);
LIBCPP_ASSERT(m2.empty());
}
- assert(Counter_base::gConstructed == 2*num);
+ assert(Counter_base::gConstructed >= (int)(2*num));
+ assert(Counter_base::gConstructed <= (int)(4*num));
}
assert(Counter_base::gConstructed == 0);
}
Modified: libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp?rev=353955&r1=353954&r2=353955&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp Wed Feb 13 08:43:44 2019
@@ -172,15 +172,18 @@ int main(int, char**)
M m3(std::move(m1), A());
assert(m3 == m2);
LIBCPP_ASSERT(m1.empty());
- assert(Counter_base::gConstructed == 3*num);
+ assert(Counter_base::gConstructed >= (int)(3*num));
+ assert(Counter_base::gConstructed <= (int)(4*num));
{
M m4(std::move(m2), A(5));
- assert(Counter_base::gConstructed == 3*num);
+ assert(Counter_base::gConstructed >= (int)(3*num));
+ assert(Counter_base::gConstructed <= (int)(5*num));
assert(m4 == m3);
LIBCPP_ASSERT(m2.empty());
}
- assert(Counter_base::gConstructed == 2*num);
+ assert(Counter_base::gConstructed >= (int)(2*num));
+ assert(Counter_base::gConstructed <= (int)(4*num));
}
assert(Counter_base::gConstructed == 0);
}
Modified: libcxx/trunk/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp?rev=353955&r1=353954&r2=353955&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp Wed Feb 13 08:43:44 2019
@@ -172,15 +172,18 @@ int main(int, char**)
M m3(std::move(m1), A());
assert(m3 == m2);
LIBCPP_ASSERT(m1.empty());
- assert(Counter_base::gConstructed == 6+num);
+ assert(Counter_base::gConstructed >= (int)(6+num));
+ assert(Counter_base::gConstructed <= (int)(m1.size()+6+num));
{
M m4(std::move(m2), A(5));
- assert(Counter_base::gConstructed == 6+num);
+ assert(Counter_base::gConstructed >= (int)(6+num));
+ assert(Counter_base::gConstructed <= (int)(m1.size()+m2.size()+6+num));
assert(m4 == m3);
LIBCPP_ASSERT(m2.empty());
}
- assert(Counter_base::gConstructed == 3+num);
+ assert(Counter_base::gConstructed >= (int)(3+num));
+ assert(Counter_base::gConstructed <= (int)(m1.size()+m2.size()+3+num));
}
assert(Counter_base::gConstructed == 0);
}
More information about the libcxx-commits
mailing list