[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / containers / unord / unord.multiset / unord.multiset.cnstr / copy.pass.cpp
blob8ae0be01eb5b50625b7972497c4b9ac4026ca06c
1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 // <unordered_set>
11 // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
12 // class Alloc = allocator<Value>>
13 // class unordered_multiset
15 // unordered_multiset(const unordered_multiset& u);
17 #include <unordered_set>
18 #include <cassert>
19 #include <cfloat>
20 #include <cmath>
21 #include <cstddef>
23 #include "test_macros.h"
24 #include "../../../check_consecutive.h"
25 #include "../../../test_compare.h"
26 #include "../../../test_hash.h"
27 #include "test_allocator.h"
28 #include "min_allocator.h"
30 int main(int, char**)
33 typedef std::unordered_multiset<int,
34 test_hash<int>,
35 test_equal_to<int>,
36 test_allocator<int>
37 > C;
38 typedef int P;
39 P a[] =
41 P(1),
42 P(2),
43 P(3),
44 P(4),
45 P(1),
46 P(2)
48 C c0(a, a + sizeof(a)/sizeof(a[0]),
50 test_hash<int>(8),
51 test_equal_to<int>(9),
52 test_allocator<int>(10)
54 C c = c0;
55 LIBCPP_ASSERT(c.bucket_count() == 7);
56 assert(c.size() == 6);
57 CheckConsecutiveValues<C::const_iterator>(c.find(1), c.end(), 1, 2);
58 CheckConsecutiveValues<C::const_iterator>(c.find(2), c.end(), 2, 2);
59 CheckConsecutiveValues<C::const_iterator>(c.find(3), c.end(), 3, 1);
60 CheckConsecutiveValues<C::const_iterator>(c.find(4), c.end(), 4, 1);
61 assert(c.hash_function() == test_hash<int>(8));
62 assert(c.key_eq() == test_equal_to<int>(9));
63 assert(c.get_allocator() == test_allocator<int>(10));
64 assert(!c.empty());
65 assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size());
66 assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size());
67 assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
68 assert(c.max_load_factor() == 1);
70 #if TEST_STD_VER >= 11
72 typedef std::unordered_multiset<int,
73 test_hash<int>,
74 test_equal_to<int>,
75 other_allocator<int>
76 > C;
77 typedef int P;
78 P a[] =
80 P(1),
81 P(2),
82 P(3),
83 P(4),
84 P(1),
85 P(2)
87 C c0(a, a + sizeof(a)/sizeof(a[0]),
89 test_hash<int>(8),
90 test_equal_to<int>(9),
91 other_allocator<int>(10)
93 C c = c0;
94 LIBCPP_ASSERT(c.bucket_count() == 7);
95 assert(c.size() == 6);
96 CheckConsecutiveValues<C::const_iterator>(c.find(1), c.end(), 1, 2);
97 CheckConsecutiveValues<C::const_iterator>(c.find(2), c.end(), 2, 2);
98 CheckConsecutiveValues<C::const_iterator>(c.find(3), c.end(), 3, 1);
99 CheckConsecutiveValues<C::const_iterator>(c.find(4), c.end(), 4, 1);
100 assert(c.hash_function() == test_hash<int>(8));
101 assert(c.key_eq() == test_equal_to<int>(9));
102 assert(c.get_allocator() == other_allocator<int>(-2));
103 assert(!c.empty());
104 assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size());
105 assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size());
106 assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
107 assert(c.max_load_factor() == 1);
110 typedef std::unordered_multiset<int,
111 test_hash<int>,
112 test_equal_to<int>,
113 min_allocator<int>
114 > C;
115 typedef int P;
116 P a[] =
118 P(1),
119 P(2),
120 P(3),
121 P(4),
122 P(1),
123 P(2)
125 C c0(a, a + sizeof(a)/sizeof(a[0]),
127 test_hash<int>(8),
128 test_equal_to<int>(9),
129 min_allocator<int>()
131 C c = c0;
132 LIBCPP_ASSERT(c.bucket_count() == 7);
133 assert(c.size() == 6);
134 CheckConsecutiveValues<C::const_iterator>(c.find(1), c.end(), 1, 2);
135 CheckConsecutiveValues<C::const_iterator>(c.find(2), c.end(), 2, 2);
136 CheckConsecutiveValues<C::const_iterator>(c.find(3), c.end(), 3, 1);
137 CheckConsecutiveValues<C::const_iterator>(c.find(4), c.end(), 4, 1);
138 assert(c.hash_function() == test_hash<int>(8));
139 assert(c.key_eq() == test_equal_to<int>(9));
140 assert(c.get_allocator() == min_allocator<int>());
141 assert(!c.empty());
142 assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size());
143 assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size());
144 assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
145 assert(c.max_load_factor() == 1);
147 #endif
149 return 0;