1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
13 // class Alloc = allocator<Value>>
14 // class unordered_multiset
16 // unordered_multiset& operator=(const unordered_multiset& u);
18 #include <unordered_set>
22 #include "../../../test_compare.h"
23 #include "../../../test_hash.h"
24 #include "test_allocator.h"
25 #include "min_allocator.h"
30 typedef test_allocator<int> A;
31 typedef std::unordered_multiset<int,
32 test_hash<std::hash<int> >,
33 test_compare<std::equal_to<int> >,
46 C c0(a, a + sizeof(a)/sizeof(a[0]),
48 test_hash<std::hash<int> >(8),
49 test_compare<std::equal_to<int> >(9),
54 test_hash<std::hash<int> >(2),
55 test_compare<std::equal_to<int> >(3),
59 assert(c.bucket_count() == 7);
60 assert(c.size() == 6);
61 C::const_iterator i = c.cbegin();
73 assert(c.hash_function() == test_hash<std::hash<int> >(8));
74 assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
75 assert(c.get_allocator() == A(4));
77 assert(std::distance(c.begin(), c.end()) == c.size());
78 assert(std::distance(c.cbegin(), c.cend()) == c.size());
79 assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
80 assert(c.max_load_factor() == 1);
83 typedef std::unordered_multiset<int> C;
94 C c(a, a + sizeof(a)/sizeof(a[0]));
98 assert(c.size() == 6);
99 assert(std::is_permutation(c.begin(), c.end(), a));
102 typedef other_allocator<int> A;
103 typedef std::unordered_multiset<int,
104 test_hash<std::hash<int> >,
105 test_compare<std::equal_to<int> >,
118 C c0(a, a + sizeof(a)/sizeof(a[0]),
120 test_hash<std::hash<int> >(8),
121 test_compare<std::equal_to<int> >(9),
126 test_hash<std::hash<int> >(2),
127 test_compare<std::equal_to<int> >(3),
131 assert(c.bucket_count() >= 7);
132 assert(c.size() == 6);
133 C::const_iterator i = c.cbegin();
145 assert(c.hash_function() == test_hash<std::hash<int> >(8));
146 assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
147 assert(c.get_allocator() == A(10));
149 assert(std::distance(c.begin(), c.end()) == c.size());
150 assert(std::distance(c.cbegin(), c.cend()) == c.size());
151 assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
152 assert(c.max_load_factor() == 1);
154 #if __cplusplus >= 201103L
156 typedef min_allocator<int> A;
157 typedef std::unordered_multiset<int,
158 test_hash<std::hash<int> >,
159 test_compare<std::equal_to<int> >,
172 C c0(a, a + sizeof(a)/sizeof(a[0]),
174 test_hash<std::hash<int> >(8),
175 test_compare<std::equal_to<int> >(9),
180 test_hash<std::hash<int> >(2),
181 test_compare<std::equal_to<int> >(3),
185 assert(c.bucket_count() == 7);
186 assert(c.size() == 6);
187 C::const_iterator i = c.cbegin();
199 assert(c.hash_function() == test_hash<std::hash<int> >(8));
200 assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
201 assert(c.get_allocator() == A());
203 assert(std::distance(c.begin(), c.end()) == c.size());
204 assert(std::distance(c.cbegin(), c.cend()) == c.size());
205 assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
206 assert(c.max_load_factor() == 1);