[libcxx] r349780 - [libcxx] Fix order checking in unordered_multimap tests.
Louis Dionne
ldionne at apple.com
Thu Dec 20 09:55:31 PST 2018
Author: ldionne
Date: Thu Dec 20 09:55:31 2018
New Revision: 349780
URL: http://llvm.org/viewvc/llvm-project?rev=349780&view=rev
Log:
[libcxx] Fix order checking in unordered_multimap tests.
Some tests assume that iteration through an unordered multimap elements
will return them in the same order as at the container creation. This
assumption is not true since the container is unordered, so that no
specific order of elements is ever guaranteed for such container. This
patch introduces checks verifying that any iteration will return elements
exactly from a set of valid values and without repetition, but in no
particular order.
Reviewed as https://reviews.llvm.org/D54838.
Thanks to Andrey Maksimov for the patch.
Modified:
libcxx/trunk/test/std/containers/unord/unord.multimap/equal_range_const.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.multimap/equal_range_non_const.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.multimap/local_iterators.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.multimap/rehash.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.multimap/reserve.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.multimap/swap_member.pass.cpp
Modified: libcxx/trunk/test/std/containers/unord/unord.multimap/equal_range_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/equal_range_const.pass.cpp?rev=349780&r1=349779&r2=349780&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/equal_range_const.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/equal_range_const.pass.cpp Thu Dec 20 09:55:31 2018
@@ -17,6 +17,7 @@
#include <unordered_map>
#include <string>
+#include <set>
#include <cassert>
#include "min_allocator.h"
@@ -48,14 +49,17 @@ int main()
r = c.equal_range(5);
assert(std::distance(r.first, r.second) == 0);
r = c.equal_range(50);
- assert(r.first->first == 50);
- assert(r.first->second == "fifty");
- ++r.first;
- assert(r.first->first == 50);
- assert(r.first->second == "fiftyA");
- ++r.first;
- assert(r.first->first == 50);
- assert(r.first->second == "fiftyB");
+ std::set<std::string> s;
+ s.insert("fifty");
+ s.insert("fiftyA");
+ s.insert("fiftyB");
+ for ( int i = 0; i < 3; ++i )
+ {
+ assert(r.first->first == 50);
+ assert(s.find(r.first->second) != s.end());
+ s.erase(s.find(r.first->second));
+ ++r.first;
+ }
}
#if TEST_STD_VER >= 11
{
@@ -84,14 +88,17 @@ int main()
r = c.equal_range(5);
assert(std::distance(r.first, r.second) == 0);
r = c.equal_range(50);
- assert(r.first->first == 50);
- assert(r.first->second == "fifty");
- ++r.first;
- assert(r.first->first == 50);
- assert(r.first->second == "fiftyA");
- ++r.first;
- assert(r.first->first == 50);
- assert(r.first->second == "fiftyB");
+ std::set<std::string> s;
+ s.insert("fifty");
+ s.insert("fiftyA");
+ s.insert("fiftyB");
+ for ( int i = 0; i < 3; ++i )
+ {
+ assert(r.first->first == 50);
+ assert(s.find(r.first->second) != s.end());
+ s.erase(s.find(r.first->second));
+ ++r.first;
+ }
}
#endif
}
Modified: libcxx/trunk/test/std/containers/unord/unord.multimap/equal_range_non_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/equal_range_non_const.pass.cpp?rev=349780&r1=349779&r2=349780&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/equal_range_non_const.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/equal_range_non_const.pass.cpp Thu Dec 20 09:55:31 2018
@@ -17,6 +17,7 @@
#include <unordered_map>
#include <string>
+#include <set>
#include <cassert>
#include "min_allocator.h"
@@ -48,14 +49,17 @@ int main()
r = c.equal_range(5);
assert(std::distance(r.first, r.second) == 0);
r = c.equal_range(50);
- assert(r.first->first == 50);
- assert(r.first->second == "fifty");
- ++r.first;
- assert(r.first->first == 50);
- assert(r.first->second == "fiftyA");
- ++r.first;
- assert(r.first->first == 50);
- assert(r.first->second == "fiftyB");
+ std::set<std::string> s;
+ s.insert("fifty");
+ s.insert("fiftyA");
+ s.insert("fiftyB");
+ for ( int i = 0; i < 3; ++i )
+ {
+ assert(r.first->first == 50);
+ assert(s.find(r.first->second) != s.end());
+ s.erase(s.find(r.first->second));
+ ++r.first;
+ }
}
#if TEST_STD_VER >= 11
{
@@ -84,14 +88,17 @@ int main()
r = c.equal_range(5);
assert(std::distance(r.first, r.second) == 0);
r = c.equal_range(50);
- assert(r.first->first == 50);
- assert(r.first->second == "fifty");
- ++r.first;
- assert(r.first->first == 50);
- assert(r.first->second == "fiftyA");
- ++r.first;
- assert(r.first->first == 50);
- assert(r.first->second == "fiftyB");
+ std::set<std::string> s;
+ s.insert("fifty");
+ s.insert("fiftyA");
+ s.insert("fiftyB");
+ for ( int i = 0; i < 3; ++i )
+ {
+ assert(r.first->first == 50);
+ assert(s.find(r.first->second) != s.end());
+ s.erase(s.find(r.first->second));
+ ++r.first;
+ }
}
#endif
}
Modified: libcxx/trunk/test/std/containers/unord/unord.multimap/local_iterators.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/local_iterators.pass.cpp?rev=349780&r1=349779&r2=349780&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/local_iterators.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/local_iterators.pass.cpp Thu Dec 20 09:55:31 2018
@@ -22,6 +22,7 @@
#include <unordered_map>
#include <string>
+#include <set>
#include <cassert>
#include "min_allocator.h"
@@ -52,21 +53,35 @@ int main()
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 2);
- assert(i->first == 1);
- assert(i->second == "one");
- ++i;
- assert(i->first == 1);
- assert(i->second == "four");
+ {
+ std::set<std::string> s;
+ s.insert("one");
+ s.insert("four");
+ for ( int n = 0; n < 2; ++n )
+ {
+ assert(i->first == 1);
+ assert(s.find(i->second) != s.end());
+ s.erase(s.find(i->second));
+ ++i;
+ }
+ }
b = c.bucket(2);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 2);
- assert(i->first == 2);
- assert(i->second == "two");
- ++i;
- assert(i->first == 2);
- assert(i->second == "four");
+ {
+ std::set<std::string> s;
+ s.insert("two");
+ s.insert("four");
+ for ( int n = 0; n < 2; ++n )
+ {
+ assert(i->first == 2);
+ assert(s.find(i->second) != s.end());
+ s.erase(s.find(i->second));
+ ++i;
+ }
+ }
b = c.bucket(3);
i = c.begin(b);
@@ -116,21 +131,35 @@ int main()
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 2);
- assert(i->first == 1);
- assert(i->second == "one");
- ++i;
- assert(i->first == 1);
- assert(i->second == "four");
+ {
+ std::set<std::string> s;
+ s.insert("one");
+ s.insert("four");
+ for ( int n = 0; n < 2; ++n )
+ {
+ assert(i->first == 1);
+ assert(s.find(i->second) != s.end());
+ s.erase(s.find(i->second));
+ ++i;
+ }
+ }
b = c.bucket(2);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 2);
- assert(i->first == 2);
- assert(i->second == "two");
- ++i;
- assert(i->first == 2);
- assert(i->second == "four");
+ {
+ std::set<std::string> s;
+ s.insert("two");
+ s.insert("four");
+ for ( int n = 0; n < 2; ++n )
+ {
+ assert(i->first == 2);
+ assert(s.find(i->second) != s.end());
+ s.erase(s.find(i->second));
+ ++i;
+ }
+ }
b = c.bucket(3);
i = c.begin(b);
@@ -180,21 +209,35 @@ int main()
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 2);
- assert(i->first == 1);
- assert(i->second == "one");
- ++i;
- assert(i->first == 1);
- assert(i->second == "four");
+ {
+ std::set<std::string> s;
+ s.insert("one");
+ s.insert("four");
+ for ( int n = 0; n < 2; ++n )
+ {
+ assert(i->first == 1);
+ assert(s.find(i->second) != s.end());
+ s.erase(s.find(i->second));
+ ++i;
+ }
+ }
b = c.bucket(2);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 2);
- assert(i->first == 2);
- assert(i->second == "two");
- ++i;
- assert(i->first == 2);
- assert(i->second == "four");
+ {
+ std::set<std::string> s;
+ s.insert("two");
+ s.insert("four");
+ for ( int n = 0; n < 2; ++n )
+ {
+ assert(i->first == 2);
+ assert(s.find(i->second) != s.end());
+ s.erase(s.find(i->second));
+ ++i;
+ }
+ }
b = c.bucket(3);
i = c.cbegin(b);
@@ -244,21 +287,35 @@ int main()
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 2);
- assert(i->first == 1);
- assert(i->second == "one");
- ++i;
- assert(i->first == 1);
- assert(i->second == "four");
+ {
+ std::set<std::string> s;
+ s.insert("one");
+ s.insert("four");
+ for ( int n = 0; n < 2; ++n )
+ {
+ assert(i->first == 1);
+ assert(s.find(i->second) != s.end());
+ s.erase(s.find(i->second));
+ ++i;
+ }
+ }
b = c.bucket(2);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 2);
- assert(i->first == 2);
- assert(i->second == "two");
- ++i;
- assert(i->first == 2);
- assert(i->second == "four");
+ {
+ std::set<std::string> s;
+ s.insert("two");
+ s.insert("four");
+ for ( int n = 0; n < 2; ++n )
+ {
+ assert(i->first == 2);
+ assert(s.find(i->second) != s.end());
+ s.erase(s.find(i->second));
+ ++i;
+ }
+ }
b = c.bucket(3);
i = c.cbegin(b);
@@ -310,21 +367,35 @@ int main()
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 2);
- assert(i->first == 1);
- assert(i->second == "one");
- ++i;
- assert(i->first == 1);
- assert(i->second == "four");
+ {
+ std::set<std::string> s;
+ s.insert("one");
+ s.insert("four");
+ for ( int n = 0; n < 2; ++n )
+ {
+ assert(i->first == 1);
+ assert(s.find(i->second) != s.end());
+ s.erase(s.find(i->second));
+ ++i;
+ }
+ }
b = c.bucket(2);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 2);
- assert(i->first == 2);
- assert(i->second == "two");
- ++i;
- assert(i->first == 2);
- assert(i->second == "four");
+ {
+ std::set<std::string> s;
+ s.insert("two");
+ s.insert("four");
+ for ( int n = 0; n < 2; ++n )
+ {
+ assert(i->first == 2);
+ assert(s.find(i->second) != s.end());
+ s.erase(s.find(i->second));
+ ++i;
+ }
+ }
b = c.bucket(3);
i = c.begin(b);
@@ -375,21 +446,35 @@ int main()
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 2);
- assert(i->first == 1);
- assert(i->second == "one");
- ++i;
- assert(i->first == 1);
- assert(i->second == "four");
+ {
+ std::set<std::string> s;
+ s.insert("one");
+ s.insert("four");
+ for ( int n = 0; n < 2; ++n )
+ {
+ assert(i->first == 1);
+ assert(s.find(i->second) != s.end());
+ s.erase(s.find(i->second));
+ ++i;
+ }
+ }
b = c.bucket(2);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 2);
- assert(i->first == 2);
- assert(i->second == "two");
- ++i;
- assert(i->first == 2);
- assert(i->second == "four");
+ {
+ std::set<std::string> s;
+ s.insert("two");
+ s.insert("four");
+ for ( int n = 0; n < 2; ++n )
+ {
+ assert(i->first == 2);
+ assert(s.find(i->second) != s.end());
+ s.erase(s.find(i->second));
+ ++i;
+ }
+ }
b = c.bucket(3);
i = c.begin(b);
@@ -440,21 +525,35 @@ int main()
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 2);
- assert(i->first == 1);
- assert(i->second == "one");
- ++i;
- assert(i->first == 1);
- assert(i->second == "four");
+ {
+ std::set<std::string> s;
+ s.insert("one");
+ s.insert("four");
+ for ( int n = 0; n < 2; ++n )
+ {
+ assert(i->first == 1);
+ assert(s.find(i->second) != s.end());
+ s.erase(s.find(i->second));
+ ++i;
+ }
+ }
b = c.bucket(2);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 2);
- assert(i->first == 2);
- assert(i->second == "two");
- ++i;
- assert(i->first == 2);
- assert(i->second == "four");
+ {
+ std::set<std::string> s;
+ s.insert("two");
+ s.insert("four");
+ for ( int n = 0; n < 2; ++n )
+ {
+ assert(i->first == 2);
+ assert(s.find(i->second) != s.end());
+ s.erase(s.find(i->second));
+ ++i;
+ }
+ }
b = c.bucket(3);
i = c.cbegin(b);
@@ -505,21 +604,35 @@ int main()
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 2);
- assert(i->first == 1);
- assert(i->second == "one");
- ++i;
- assert(i->first == 1);
- assert(i->second == "four");
+ {
+ std::set<std::string> s;
+ s.insert("one");
+ s.insert("four");
+ for ( int n = 0; n < 2; ++n )
+ {
+ assert(i->first == 1);
+ assert(s.find(i->second) != s.end());
+ s.erase(s.find(i->second));
+ ++i;
+ }
+ }
b = c.bucket(2);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 2);
- assert(i->first == 2);
- assert(i->second == "two");
- ++i;
- assert(i->first == 2);
- assert(i->second == "four");
+ {
+ std::set<std::string> s;
+ s.insert("two");
+ s.insert("four");
+ for ( int n = 0; n < 2; ++n )
+ {
+ assert(i->first == 2);
+ assert(s.find(i->second) != s.end());
+ s.erase(s.find(i->second));
+ ++i;
+ }
+ }
b = c.bucket(3);
i = c.cbegin(b);
Modified: libcxx/trunk/test/std/containers/unord/unord.multimap/rehash.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/rehash.pass.cpp?rev=349780&r1=349779&r2=349780&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/rehash.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/rehash.pass.cpp Thu Dec 20 09:55:31 2018
@@ -17,6 +17,7 @@
#include <unordered_map>
#include <string>
+#include <set>
#include <cassert>
#include <cfloat>
#include <cmath>
@@ -39,20 +40,33 @@ void test(const C& c)
Eq eq = c.equal_range(1);
assert(std::distance(eq.first, eq.second) == 2);
typename C::const_iterator i = eq.first;
- assert(i->first == 1);
- assert(i->second == "one");
- ++i;
- assert(i->first == 1);
- assert(i->second == "four");
+ {
+ std::set<std::string> s;
+ s.insert("one");
+ s.insert("four");
+ for ( int n = 0; n < 2; ++n )
+ {
+ assert(i->first == 1);
+ assert(s.find(i->second) != s.end());
+ s.erase(s.find(i->second));
+ ++i;
+ }
+ }
eq = c.equal_range(2);
assert(std::distance(eq.first, eq.second) == 2);
i = eq.first;
- assert(i->first == 2);
- assert(i->second == "two");
- ++i;
- assert(i->first == 2);
- assert(i->second == "four");
-
+ {
+ std::set<std::string> s;
+ s.insert("two");
+ s.insert("four");
+ for ( int n = 0; n < 2; ++n )
+ {
+ assert(i->first == 2);
+ assert(s.find(i->second) != s.end());
+ s.erase(s.find(i->second));
+ ++i;
+ }
+ }
eq = c.equal_range(3);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
Modified: libcxx/trunk/test/std/containers/unord/unord.multimap/reserve.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/reserve.pass.cpp?rev=349780&r1=349779&r2=349780&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/reserve.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/reserve.pass.cpp Thu Dec 20 09:55:31 2018
@@ -13,10 +13,11 @@
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
-// void rehash(size_type n);
+// void reserve(size_type n);
#include <unordered_map>
#include <string>
+#include <set>
#include <cassert>
#include "test_macros.h"
@@ -26,10 +27,22 @@ template <class C>
void test(const C& c)
{
assert(c.size() == 6);
- assert(c.find(1)->second == "one");
- assert(next(c.find(1))->second == "four");
- assert(c.find(2)->second == "two");
- assert(next(c.find(2))->second == "four");
+ {
+ std::set<std::string> s;
+ s.insert("one");
+ s.insert("four");
+ assert(s.find(c.find(1)->second) != s.end());
+ s.erase(s.find(c.find(1)->second));
+ assert(s.find(next(c.find(1))->second) != s.end());
+ }
+ {
+ std::set<std::string> s;
+ s.insert("two");
+ s.insert("four");
+ assert(s.find(c.find(2)->second) != s.end());
+ s.erase(s.find(c.find(2)->second));
+ assert(s.find(next(c.find(2))->second) != s.end());
+ }
assert(c.find(3)->second == "three");
assert(c.find(4)->second == "four");
}
Modified: libcxx/trunk/test/std/containers/unord/unord.multimap/swap_member.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/swap_member.pass.cpp?rev=349780&r1=349779&r2=349780&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/swap_member.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/swap_member.pass.cpp Thu Dec 20 09:55:31 2018
@@ -17,6 +17,7 @@
#include <unordered_map>
#include <string>
+#include <set>
#include <cassert>
#include <cstddef>
@@ -136,10 +137,22 @@ int main()
assert(c2.bucket_count() >= 6);
assert(c2.size() == 6);
- assert(c2.find(1)->second == "one");
- assert(next(c2.find(1))->second == "four");
- assert(c2.find(2)->second == "two");
- assert(next(c2.find(2))->second == "four");
+ {
+ std::set<std::string> s;
+ s.insert("one");
+ s.insert("four");
+ assert(s.find(c2.find(1)->second) != s.end());
+ s.erase(s.find(c2.find(1)->second));
+ assert(s.find(next(c2.find(1))->second) != s.end());
+ }
+ {
+ std::set<std::string> s;
+ s.insert("two");
+ s.insert("four");
+ assert(s.find(c2.find(2)->second) != s.end());
+ s.erase(s.find(c2.find(2)->second));
+ assert(s.find(next(c2.find(2))->second) != s.end());
+ }
assert(c2.find(3)->second == "three");
assert(c2.find(4)->second == "four");
assert(c2.hash_function() == Hash(1));
@@ -199,10 +212,22 @@ int main()
assert(c2.bucket_count() >= 6);
assert(c2.size() == 6);
- assert(c2.find(1)->second == "one");
- assert(next(c2.find(1))->second == "four");
- assert(c2.find(2)->second == "two");
- assert(next(c2.find(2))->second == "four");
+ {
+ std::set<std::string> s;
+ s.insert("one");
+ s.insert("four");
+ assert(s.find(c2.find(1)->second) != s.end());
+ s.erase(s.find(c2.find(1)->second));
+ assert(s.find(next(c2.find(1))->second) != s.end());
+ }
+ {
+ std::set<std::string> s;
+ s.insert("two");
+ s.insert("four");
+ assert(s.find(c2.find(2)->second) != s.end());
+ s.erase(s.find(c2.find(2)->second));
+ assert(s.find(next(c2.find(2))->second) != s.end());
+ }
assert(c2.find(3)->second == "three");
assert(c2.find(4)->second == "four");
assert(c2.hash_function() == Hash(1));
@@ -320,10 +345,22 @@ int main()
assert(c2.bucket_count() >= 6);
assert(c2.size() == 6);
- assert(c2.find(1)->second == "one");
- assert(next(c2.find(1))->second == "four");
- assert(c2.find(2)->second == "two");
- assert(next(c2.find(2))->second == "four");
+ {
+ std::set<std::string> s;
+ s.insert("one");
+ s.insert("four");
+ assert(s.find(c2.find(1)->second) != s.end());
+ s.erase(s.find(c2.find(1)->second));
+ assert(s.find(next(c2.find(1))->second) != s.end());
+ }
+ {
+ std::set<std::string> s;
+ s.insert("two");
+ s.insert("four");
+ assert(s.find(c2.find(2)->second) != s.end());
+ s.erase(s.find(c2.find(2)->second));
+ assert(s.find(next(c2.find(2))->second) != s.end());
+ }
assert(c2.find(3)->second == "three");
assert(c2.find(4)->second == "four");
assert(c2.hash_function() == Hash(1));
@@ -383,10 +420,22 @@ int main()
assert(c2.bucket_count() >= 6);
assert(c2.size() == 6);
- assert(c2.find(1)->second == "one");
- assert(next(c2.find(1))->second == "four");
- assert(c2.find(2)->second == "two");
- assert(next(c2.find(2))->second == "four");
+ {
+ std::set<std::string> s;
+ s.insert("one");
+ s.insert("four");
+ assert(s.find(c2.find(1)->second) != s.end());
+ s.erase(s.find(c2.find(1)->second));
+ assert(s.find(next(c2.find(1))->second) != s.end());
+ }
+ {
+ std::set<std::string> s;
+ s.insert("two");
+ s.insert("four");
+ assert(s.find(c2.find(2)->second) != s.end());
+ s.erase(s.find(c2.find(2)->second));
+ assert(s.find(next(c2.find(2))->second) != s.end());
+ }
assert(c2.find(3)->second == "three");
assert(c2.find(4)->second == "four");
assert(c2.hash_function() == Hash(1));
@@ -504,10 +553,22 @@ int main()
assert(c2.bucket_count() >= 6);
assert(c2.size() == 6);
- assert(c2.find(1)->second == "one");
- assert(next(c2.find(1))->second == "four");
- assert(c2.find(2)->second == "two");
- assert(next(c2.find(2))->second == "four");
+ {
+ std::set<std::string> s;
+ s.insert("one");
+ s.insert("four");
+ assert(s.find(c2.find(1)->second) != s.end());
+ s.erase(s.find(c2.find(1)->second));
+ assert(s.find(next(c2.find(1))->second) != s.end());
+ }
+ {
+ std::set<std::string> s;
+ s.insert("two");
+ s.insert("four");
+ assert(s.find(c2.find(2)->second) != s.end());
+ s.erase(s.find(c2.find(2)->second));
+ assert(s.find(next(c2.find(2))->second) != s.end());
+ }
assert(c2.find(3)->second == "three");
assert(c2.find(4)->second == "four");
assert(c2.hash_function() == Hash(1));
@@ -567,10 +628,22 @@ int main()
assert(c2.bucket_count() >= 6);
assert(c2.size() == 6);
- assert(c2.find(1)->second == "one");
- assert(next(c2.find(1))->second == "four");
- assert(c2.find(2)->second == "two");
- assert(next(c2.find(2))->second == "four");
+ {
+ std::set<std::string> s;
+ s.insert("one");
+ s.insert("four");
+ assert(s.find(c2.find(1)->second) != s.end());
+ s.erase(s.find(c2.find(1)->second));
+ assert(s.find(next(c2.find(1))->second) != s.end());
+ }
+ {
+ std::set<std::string> s;
+ s.insert("two");
+ s.insert("four");
+ assert(s.find(c2.find(2)->second) != s.end());
+ s.erase(s.find(c2.find(2)->second));
+ assert(s.find(next(c2.find(2))->second) != s.end());
+ }
assert(c2.find(3)->second == "three");
assert(c2.find(4)->second == "four");
assert(c2.hash_function() == Hash(1));
More information about the libcxx-commits
mailing list