Changeset View
Changeset View
Standalone View
Standalone View
libcxx/test/std/containers/unord/unord.multimap/eq.pass.cpp
Show All 19 Lines | |||||
#include <unordered_map> | #include <unordered_map> | ||||
#include <string> | #include <string> | ||||
#include <cassert> | #include <cassert> | ||||
#include "test_macros.h" | #include "test_macros.h" | ||||
#include "min_allocator.h" | #include "min_allocator.h" | ||||
#include "test_comparisons.h" | |||||
int main(int, char**) | int main(int, char**) | ||||
{ | { | ||||
{ | { | ||||
typedef std::unordered_multimap<int, std::string> C; | typedef std::unordered_multimap<int, std::string> C; | ||||
typedef std::pair<int, std::string> P; | typedef std::pair<int, std::string> P; | ||||
P a[] = | P a[] = | ||||
{ | { | ||||
P(10, "ten"), | P(10, "ten"), | ||||
P(20, "twenty"), | P(20, "twenty"), | ||||
P(20, "twenty 2"), | P(20, "twenty 2"), | ||||
P(30, "thirty"), | P(30, "thirty"), | ||||
P(40, "forty"), | P(40, "forty"), | ||||
P(50, "fifty"), | P(50, "fifty"), | ||||
P(50, "fifty 2"), | P(50, "fifty 2"), | ||||
P(50, "fifty 3"), | P(50, "fifty 3"), | ||||
P(60, "sixty"), | P(60, "sixty"), | ||||
P(70, "seventy"), | P(70, "seventy"), | ||||
P(80, "eighty"), | P(80, "eighty"), | ||||
}; | }; | ||||
const C c1(std::begin(a), std::end(a)); | const C c1(std::begin(a), std::end(a)); | ||||
const C c2; | const C c2; | ||||
assert(!(c1 == c2)); | assert(testComparisons2(c1, c2, false)); | ||||
assert( (c1 != c2)); | |||||
} | } | ||||
{ | { | ||||
typedef std::unordered_multimap<int, std::string> C; | typedef std::unordered_multimap<int, std::string> C; | ||||
typedef std::pair<int, std::string> P; | typedef std::pair<int, std::string> P; | ||||
P a[] = | P a[] = | ||||
{ | { | ||||
P(10, "ten"), | P(10, "ten"), | ||||
P(20, "twenty"), | P(20, "twenty"), | ||||
P(20, "twenty 2"), | P(20, "twenty 2"), | ||||
P(30, "thirty"), | P(30, "thirty"), | ||||
P(40, "forty"), | P(40, "forty"), | ||||
P(50, "fifty"), | P(50, "fifty"), | ||||
P(50, "fifty 2"), | P(50, "fifty 2"), | ||||
P(50, "fifty 3"), | P(50, "fifty 3"), | ||||
P(60, "sixty"), | P(60, "sixty"), | ||||
P(70, "seventy"), | P(70, "seventy"), | ||||
P(80, "eighty"), | P(80, "eighty"), | ||||
}; | }; | ||||
const C c1(std::begin(a), std::end(a)); | const C c1(std::begin(a), std::end(a)); | ||||
const C c2 = c1; | const C c2 = c1; | ||||
assert( (c1 == c2)); | assert(testComparisons2(c1, c2, true)); | ||||
assert(!(c1 != c2)); | |||||
} | } | ||||
{ | { | ||||
typedef std::unordered_multimap<int, std::string> C; | typedef std::unordered_multimap<int, std::string> C; | ||||
typedef std::pair<int, std::string> P; | typedef std::pair<int, std::string> P; | ||||
P a[] = | P a[] = | ||||
{ | { | ||||
P(10, "ten"), | P(10, "ten"), | ||||
P(20, "twenty"), | P(20, "twenty"), | ||||
P(20, "twenty 2"), | P(20, "twenty 2"), | ||||
P(30, "thirty"), | P(30, "thirty"), | ||||
P(40, "forty"), | P(40, "forty"), | ||||
P(50, "fifty"), | P(50, "fifty"), | ||||
P(50, "fifty 2"), | P(50, "fifty 2"), | ||||
P(50, "fifty 3"), | P(50, "fifty 3"), | ||||
P(60, "sixty"), | P(60, "sixty"), | ||||
P(70, "seventy"), | P(70, "seventy"), | ||||
P(80, "eighty"), | P(80, "eighty"), | ||||
}; | }; | ||||
C c1(std::begin(a), std::end(a)); | C c1(std::begin(a), std::end(a)); | ||||
C c2 = c1; | C c2 = c1; | ||||
c2.rehash(30); | c2.rehash(30); | ||||
assert( (c1 == c2)); | assert(testComparisons2(c1, c2, true)); | ||||
assert(!(c1 != c2)); | |||||
c2.insert(P(90, "ninety")); | c2.insert(P(90, "ninety")); | ||||
assert(!(c1 == c2)); | assert(testComparisons2(c1, c2, false)); | ||||
assert( (c1 != c2)); | |||||
c1.insert(P(90, "ninety")); | c1.insert(P(90, "ninety")); | ||||
assert( (c1 == c2)); | assert(testComparisons2(c1, c2, true)); | ||||
assert(!(c1 != c2)); | } | ||||
{ | |||||
typedef std::unordered_multimap<int, std::string> C; | |||||
typedef std::pair<int, std::string> P; | |||||
P a[] = | |||||
{ | |||||
P(10, "ten"), | |||||
P(20, "twenty"), | |||||
P(20, "twenty 2"), | |||||
P(30, "thirty"), | |||||
P(40, "forty"), | |||||
P(50, "fifty"), | |||||
P(50, "fifty 2"), | |||||
P(50, "fifty 3"), | |||||
P(60, "sixty"), | |||||
P(70, "seventy"), | |||||
P(80, "eighty"), | |||||
}; | |||||
C c1(std::begin(a), std::end(a)); | |||||
C c2 = c1; | |||||
assert(testComparisons2(c1, c2, true)); | |||||
c1.insert(P(70, "seventy 2")); | |||||
c2.insert(P(80, "eighty 2")); | |||||
assert(testComparisons2(c1, c2, false)); | |||||
} | } | ||||
#if TEST_STD_VER >= 11 | #if TEST_STD_VER >= 11 | ||||
{ | { | ||||
typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, | typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, | ||||
min_allocator<std::pair<const int, std::string>>> C; | min_allocator<std::pair<const int, std::string>>> C; | ||||
typedef std::pair<int, std::string> P; | typedef std::pair<int, std::string> P; | ||||
P a[] = | P a[] = | ||||
{ | { | ||||
P(10, "ten"), | P(10, "ten"), | ||||
P(20, "twenty"), | P(20, "twenty"), | ||||
P(20, "twenty 2"), | P(20, "twenty 2"), | ||||
P(30, "thirty"), | P(30, "thirty"), | ||||
P(40, "forty"), | P(40, "forty"), | ||||
P(50, "fifty"), | P(50, "fifty"), | ||||
P(50, "fifty 2"), | P(50, "fifty 2"), | ||||
P(50, "fifty 3"), | P(50, "fifty 3"), | ||||
P(60, "sixty"), | P(60, "sixty"), | ||||
P(70, "seventy"), | P(70, "seventy"), | ||||
P(80, "eighty"), | P(80, "eighty"), | ||||
}; | }; | ||||
const C c1(std::begin(a), std::end(a)); | const C c1(std::begin(a), std::end(a)); | ||||
const C c2; | const C c2; | ||||
assert(!(c1 == c2)); | assert(testComparisons2(c1, c2, false)); | ||||
assert( (c1 != c2)); | |||||
} | } | ||||
{ | { | ||||
typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, | typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, | ||||
min_allocator<std::pair<const int, std::string>>> C; | min_allocator<std::pair<const int, std::string>>> C; | ||||
typedef std::pair<int, std::string> P; | typedef std::pair<int, std::string> P; | ||||
P a[] = | P a[] = | ||||
{ | { | ||||
P(10, "ten"), | P(10, "ten"), | ||||
P(20, "twenty"), | P(20, "twenty"), | ||||
P(20, "twenty 2"), | P(20, "twenty 2"), | ||||
P(30, "thirty"), | P(30, "thirty"), | ||||
P(40, "forty"), | P(40, "forty"), | ||||
P(50, "fifty"), | P(50, "fifty"), | ||||
P(50, "fifty 2"), | P(50, "fifty 2"), | ||||
P(50, "fifty 3"), | P(50, "fifty 3"), | ||||
P(60, "sixty"), | P(60, "sixty"), | ||||
P(70, "seventy"), | P(70, "seventy"), | ||||
P(80, "eighty"), | P(80, "eighty"), | ||||
}; | }; | ||||
const C c1(std::begin(a), std::end(a)); | const C c1(std::begin(a), std::end(a)); | ||||
const C c2 = c1; | const C c2 = c1; | ||||
assert( (c1 == c2)); | assert(testComparisons2(c1, c2, true)); | ||||
assert(!(c1 != c2)); | |||||
} | } | ||||
{ | { | ||||
typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, | typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, | ||||
min_allocator<std::pair<const int, std::string>>> C; | min_allocator<std::pair<const int, std::string>>> C; | ||||
typedef std::pair<int, std::string> P; | typedef std::pair<int, std::string> P; | ||||
P a[] = | P a[] = | ||||
{ | { | ||||
P(10, "ten"), | P(10, "ten"), | ||||
P(20, "twenty"), | P(20, "twenty"), | ||||
P(20, "twenty 2"), | P(20, "twenty 2"), | ||||
P(30, "thirty"), | P(30, "thirty"), | ||||
P(40, "forty"), | P(40, "forty"), | ||||
P(50, "fifty"), | P(50, "fifty"), | ||||
P(50, "fifty 2"), | P(50, "fifty 2"), | ||||
P(50, "fifty 3"), | P(50, "fifty 3"), | ||||
P(60, "sixty"), | P(60, "sixty"), | ||||
P(70, "seventy"), | P(70, "seventy"), | ||||
P(80, "eighty"), | P(80, "eighty"), | ||||
}; | }; | ||||
C c1(std::begin(a), std::end(a)); | C c1(std::begin(a), std::end(a)); | ||||
C c2 = c1; | C c2 = c1; | ||||
c2.rehash(30); | c2.rehash(30); | ||||
assert( (c1 == c2)); | assert(testComparisons2(c1, c2, true)); | ||||
assert(!(c1 != c2)); | |||||
c2.insert(P(90, "ninety")); | c2.insert(P(90, "ninety")); | ||||
assert(!(c1 == c2)); | assert(testComparisons2(c1, c2, false)); | ||||
assert( (c1 != c2)); | |||||
c1.insert(P(90, "ninety")); | c1.insert(P(90, "ninety")); | ||||
assert( (c1 == c2)); | assert(testComparisons2(c1, c2, true)); | ||||
assert(!(c1 != c2)); | } | ||||
{ | |||||
typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, | |||||
min_allocator<std::pair<const int, std::string>>> C; | |||||
typedef std::pair<int, std::string> P; | |||||
P a[] = | |||||
{ | |||||
P(10, "ten"), | |||||
P(20, "twenty"), | |||||
P(20, "twenty 2"), | |||||
P(30, "thirty"), | |||||
P(40, "forty"), | |||||
P(50, "fifty"), | |||||
P(50, "fifty 2"), | |||||
P(50, "fifty 3"), | |||||
P(60, "sixty"), | |||||
P(70, "seventy"), | |||||
P(80, "eighty"), | |||||
}; | |||||
C c1(std::begin(a), std::end(a)); | |||||
C c2 = c1; | |||||
assert(testComparisons2(c1, c2, true)); | |||||
c1.insert(P(70, "seventy 2")); | |||||
c2.insert(P(80, "eighty 2")); | |||||
assert(testComparisons2(c1, c2, false)); | |||||
} | } | ||||
#endif | #endif | ||||
return 0; | return 0; | ||||
} | } |