1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
13 // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
14 // class Alloc = allocator<Value>>
15 // class unordered_multiset
17 // unordered_multiset(initializer_list<value_type> il);
19 #include <unordered_set>
25 #include "test_macros.h"
26 #include "../../../test_compare.h"
27 #include "../../../test_hash.h"
28 #include "test_allocator.h"
29 #include "min_allocator.h"
34 typedef std::unordered_multiset
<int,
48 assert(c
.bucket_count() >= 7);
49 assert(c
.size() == 6);
50 assert(c
.count(1) == 2);
51 assert(c
.count(2) == 2);
52 assert(c
.count(3) == 1);
53 assert(c
.count(4) == 1);
54 assert(c
.hash_function() == test_hash
<int>());
55 assert(c
.key_eq() == test_equal_to
<int>());
56 assert(c
.get_allocator() == test_allocator
<int>());
58 assert(static_cast<std::size_t>(std::distance(c
.begin(), c
.end())) == c
.size());
59 assert(static_cast<std::size_t>(std::distance(c
.cbegin(), c
.cend())) == c
.size());
60 assert(fabs(c
.load_factor() - (float)c
.size()/c
.bucket_count()) < FLT_EPSILON
);
61 assert(c
.max_load_factor() == 1);
64 typedef std::unordered_multiset
<int,
78 assert(c
.bucket_count() >= 7);
79 assert(c
.size() == 6);
80 assert(c
.count(1) == 2);
81 assert(c
.count(2) == 2);
82 assert(c
.count(3) == 1);
83 assert(c
.count(4) == 1);
84 assert(c
.hash_function() == test_hash
<int>());
85 assert(c
.key_eq() == test_equal_to
<int>());
86 assert(c
.get_allocator() == min_allocator
<int>());
88 assert(static_cast<std::size_t>(std::distance(c
.begin(), c
.end())) == c
.size());
89 assert(static_cast<std::size_t>(std::distance(c
.cbegin(), c
.cend())) == c
.size());
90 assert(fabs(c
.load_factor() - (float)c
.size()/c
.bucket_count()) < FLT_EPSILON
);
91 assert(c
.max_load_factor() == 1);
96 typedef test_hash
<T
> HF
;
97 typedef test_equal_to
<T
> Comp
;
98 typedef test_allocator
<T
> A
;
99 typedef std::unordered_multiset
<T
, HF
, Comp
, A
> C
;
111 assert(c
.bucket_count() >= 12);
112 assert(c
.size() == 6);
113 assert(c
.count(1) == 2);
114 assert(c
.count(2) == 2);
115 assert(c
.count(3) == 1);
116 assert(c
.count(4) == 1);
117 assert(c
.hash_function() == HF());
118 assert(c
.key_eq() == Comp());
119 assert(c
.get_allocator() == a
);
120 assert(!(c
.get_allocator() == A()));
122 assert(static_cast<std::size_t>(std::distance(c
.begin(), c
.end())) == c
.size());
123 assert(static_cast<std::size_t>(std::distance(c
.cbegin(), c
.cend())) == c
.size());
124 assert(fabs(c
.load_factor() - (float)c
.size()/c
.bucket_count()) < FLT_EPSILON
);
125 assert(c
.max_load_factor() == 1);
129 typedef test_hash
<T
> HF
;
130 typedef test_equal_to
<T
> Comp
;
131 typedef test_allocator
<T
> A
;
132 typedef std::unordered_multiset
<T
, HF
, Comp
, A
> C
;
145 assert(c
.bucket_count() >= 12);
146 assert(c
.size() == 6);
147 assert(c
.count(1) == 2);
148 assert(c
.count(2) == 2);
149 assert(c
.count(3) == 1);
150 assert(c
.count(4) == 1);
151 assert(c
.hash_function() == hf
);
152 assert(!(c
.hash_function() == HF()));
153 assert(c
.key_eq() == Comp());
154 assert(c
.get_allocator() == a
);
155 assert(!(c
.get_allocator() == A()));
157 assert(static_cast<std::size_t>(std::distance(c
.begin(), c
.end())) == c
.size());
158 assert(static_cast<std::size_t>(std::distance(c
.cbegin(), c
.cend())) == c
.size());
159 assert(fabs(c
.load_factor() - (float)c
.size()/c
.bucket_count()) < FLT_EPSILON
);
160 assert(c
.max_load_factor() == 1);
162 #endif // TEST_STD_VER > 11