[libcxx] [test] D26627: Fix ordering assumptions in unordered container tests.
authorStephan T. Lavavej <stl@exchange.microsoft.com>
Tue, 15 Nov 2016 17:00:38 +0000 (17:00 +0000)
committerStephan T. Lavavej <stl@exchange.microsoft.com>
Tue, 15 Nov 2016 17:00:38 +0000 (17:00 +0000)
llvm-svn: 286984

libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp
libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp
libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp

index 8bccd40..a809513 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "../../../Emplaceable.h"
 #include "min_allocator.h"
+#include "test_macros.h"
 
 int main()
 {
@@ -44,20 +45,20 @@ int main()
         assert(c.size() == 2);
         assert(r->first == 3);
         assert(r->second == Emplaceable(5, 6));
-        assert(r == next(c.begin()));
+        LIBCPP_ASSERT(r == next(c.begin()));
 
         r = c.emplace_hint(r, std::piecewise_construct, std::forward_as_tuple(3),
                                                         std::forward_as_tuple(6, 7));
         assert(c.size() == 3);
         assert(r->first == 3);
         assert(r->second == Emplaceable(6, 7));
-        assert(r == next(c.begin()));
+        LIBCPP_ASSERT(r == next(c.begin()));
         r = c.begin();
         assert(r->first == 3);
-        assert(r->second == Emplaceable());
+        LIBCPP_ASSERT(r->second == Emplaceable());
         r = next(r, 2);
         assert(r->first == 3);
-        assert(r->second == Emplaceable(5, 6));
+        LIBCPP_ASSERT(r->second == Emplaceable(5, 6));
     }
 #if TEST_STD_VER >= 11
     {
@@ -76,20 +77,20 @@ int main()
         assert(c.size() == 2);
         assert(r->first == 3);
         assert(r->second == Emplaceable(5, 6));
-        assert(r == next(c.begin()));
+        LIBCPP_ASSERT(r == next(c.begin()));
 
         r = c.emplace_hint(r, std::piecewise_construct, std::forward_as_tuple(3),
                                                         std::forward_as_tuple(6, 7));
         assert(c.size() == 3);
         assert(r->first == 3);
         assert(r->second == Emplaceable(6, 7));
-        assert(r == next(c.begin()));
+        LIBCPP_ASSERT(r == next(c.begin()));
         r = c.begin();
         assert(r->first == 3);
-        assert(r->second == Emplaceable());
+        LIBCPP_ASSERT(r->second == Emplaceable());
         r = next(r, 2);
         assert(r->first == 3);
-        assert(r->second == Emplaceable(5, 6));
+        LIBCPP_ASSERT(r->second == Emplaceable(5, 6));
     }
 #endif
 #if _LIBCPP_DEBUG >= 1
index 35bbce2..274c039 100644 (file)
@@ -204,18 +204,10 @@ int main()
         c = std::move(c0);
         LIBCPP_ASSERT(c.bucket_count() == 7);
         assert(c.size() == 6);
-        C::const_iterator i = c.cbegin();
-        assert(*i == 4);
-        ++i;
-        assert(*i == 3);
-        ++i;
-        assert(*i == 2);
-        ++i;
-        assert(*i == 2);
-        ++i;
-        assert(*i == 1);
-        ++i;
-        assert(*i == 1);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
         assert(c.hash_function() == test_hash<std::hash<int> >(8));
         assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
         assert(c.get_allocator() == A());
index be7c22e..aad2d7d 100644 (file)
@@ -146,18 +146,10 @@ int main()
         C c(std::move(c0), A());
         assert(c.bucket_count() >= 7);
         assert(c.size() == 6);
-        C::const_iterator i = c.cbegin();
-        assert(*i == 4);
-        ++i;
-        assert(*i == 3);
-        ++i;
-        assert(*i == 2);
-        ++i;
-        assert(*i == 2);
-        ++i;
-        assert(*i == 1);
-        ++i;
-        assert(*i == 1);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
         assert(c.hash_function() == test_hash<std::hash<int> >(8));
         assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
         assert(c.get_allocator() == A());