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(unordered_multiset&& u);
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> >,
41 test_hash<std::hash<int> >(8),
42 test_compare<std::equal_to<int> >(9),
43 test_allocator<int>(10)
46 LIBCPP_ASSERT(c.bucket_count() == 7);
47 assert(c.size() == 0);
48 assert(c.hash_function() == test_hash<std::hash<int> >(8));
49 assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
50 assert(c.get_allocator() == test_allocator<int>(10));
52 assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size());
53 assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size());
54 assert(c.load_factor() == 0);
55 assert(c.max_load_factor() == 1);
60 typedef std::unordered_multiset<int,
61 test_hash<std::hash<int> >,
62 test_compare<std::equal_to<int> >,
75 C c0(a, a + sizeof(a)/sizeof(a[0]),
77 test_hash<std::hash<int> >(8),
78 test_compare<std::equal_to<int> >(9),
79 test_allocator<int>(10)
82 LIBCPP_ASSERT(c.bucket_count() == 7);
83 assert(c.size() == 6);
84 assert(c.count(1) == 2);
85 assert(c.count(2) == 2);
86 assert(c.count(3) == 1);
87 assert(c.count(4) == 1);
88 assert(c.hash_function() == test_hash<std::hash<int> >(8));
89 assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
90 assert(c.get_allocator() == test_allocator<int>(10));
92 assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size());
93 assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size());
94 assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
95 assert(c.max_load_factor() == 1);
100 typedef std::unordered_multiset<int,
101 test_hash<std::hash<int> >,
102 test_compare<std::equal_to<int> >,
106 test_hash<std::hash<int> >(8),
107 test_compare<std::equal_to<int> >(9),
111 LIBCPP_ASSERT(c.bucket_count() == 7);
112 assert(c.size() == 0);
113 assert(c.hash_function() == test_hash<std::hash<int> >(8));
114 assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
115 assert(c.get_allocator() == min_allocator<int>());
117 assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size());
118 assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size());
119 assert(c.load_factor() == 0);
120 assert(c.max_load_factor() == 1);
125 typedef std::unordered_multiset<int,
126 test_hash<std::hash<int> >,
127 test_compare<std::equal_to<int> >,
140 C c0(a, a + sizeof(a)/sizeof(a[0]),
142 test_hash<std::hash<int> >(8),
143 test_compare<std::equal_to<int> >(9),
147 LIBCPP_ASSERT(c.bucket_count() == 7);
148 assert(c.size() == 6);
149 assert(c.count(1) == 2);
150 assert(c.count(2) == 2);
151 assert(c.count(3) == 1);
152 assert(c.count(4) == 1);
153 assert(c.hash_function() == test_hash<std::hash<int> >(8));
154 assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
155 assert(c.get_allocator() == min_allocator<int>());
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(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
160 assert(c.max_load_factor() == 1);
164 #if _LIBCPP_DEBUG >= 1
166 std::unordered_multiset<int> s1 = {1, 2, 3};
167 std::unordered_multiset<int>::iterator i = s1.begin();
169 std::unordered_multiset<int> s2 = std::move(s1);
172 assert(s2.size() == 2);