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 //===----------------------------------------------------------------------===//
10 // UNSUPPORTED: c++98, c++03
14 // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
15 // class Alloc = allocator<Value>>
16 // class unordered_multiset
18 // unordered_multiset(initializer_list<value_type> il);
20 #include <unordered_set>
26 #include "test_macros.h"
27 #include "../../../test_compare.h"
28 #include "../../../test_hash.h"
29 #include "test_allocator.h"
30 #include "min_allocator.h"
35 typedef std::unordered_multiset<int,
36 test_hash<std::hash<int> >,
37 test_compare<std::equal_to<int> >,
49 assert(c.bucket_count() >= 7);
50 assert(c.size() == 6);
51 assert(c.count(1) == 2);
52 assert(c.count(2) == 2);
53 assert(c.count(3) == 1);
54 assert(c.count(4) == 1);
55 assert(c.hash_function() == test_hash<std::hash<int> >());
56 assert(c.key_eq() == test_compare<std::equal_to<int> >());
57 assert(c.get_allocator() == test_allocator<int>());
59 assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size());
60 assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size());
61 assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
62 assert(c.max_load_factor() == 1);
65 typedef std::unordered_multiset<int,
66 test_hash<std::hash<int> >,
67 test_compare<std::equal_to<int> >,
79 assert(c.bucket_count() >= 7);
80 assert(c.size() == 6);
81 assert(c.count(1) == 2);
82 assert(c.count(2) == 2);
83 assert(c.count(3) == 1);
84 assert(c.count(4) == 1);
85 assert(c.hash_function() == test_hash<std::hash<int> >());
86 assert(c.key_eq() == test_compare<std::equal_to<int> >());
87 assert(c.get_allocator() == min_allocator<int>());
89 assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size());
90 assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size());
91 assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
92 assert(c.max_load_factor() == 1);
97 typedef test_hash<std::hash<T>> HF;
98 typedef test_compare<std::equal_to<T>> Comp;
99 typedef test_allocator<T> A;
100 typedef std::unordered_multiset<T, HF, Comp, A> C;
112 assert(c.bucket_count() >= 12);
113 assert(c.size() == 6);
114 assert(c.count(1) == 2);
115 assert(c.count(2) == 2);
116 assert(c.count(3) == 1);
117 assert(c.count(4) == 1);
118 assert(c.hash_function() == HF());
119 assert(c.key_eq() == Comp());
120 assert(c.get_allocator() == a);
121 assert(!(c.get_allocator() == A()));
123 assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size());
124 assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size());
125 assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
126 assert(c.max_load_factor() == 1);
130 typedef test_hash<std::hash<T>> HF;
131 typedef test_compare<std::equal_to<T>> Comp;
132 typedef test_allocator<T> A;
133 typedef std::unordered_multiset<T, HF, Comp, A> C;
146 assert(c.bucket_count() >= 12);
147 assert(c.size() == 6);
148 assert(c.count(1) == 2);
149 assert(c.count(2) == 2);
150 assert(c.count(3) == 1);
151 assert(c.count(4) == 1);
152 assert(c.hash_function() == hf);
153 assert(!(c.hash_function() == HF()));
154 assert(c.key_eq() == Comp());
155 assert(c.get_allocator() == a);
156 assert(!(c.get_allocator() == A()));
158 assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size());
159 assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size());
160 assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
161 assert(c.max_load_factor() == 1);
163 #endif // TEST_STD_VER > 11