[libc][NFC] Remove extra ; in exhaustive_test.h. (#124216)
[llvm-project.git] / libcxx / test / std / containers / associative / multiset / equal_range.pass.cpp
blob9d1e25d8ab9ee582b660af4393626c04d492bcaf
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 // <set>
11 // class multiset
13 // pair<iterator,iterator> equal_range(const key_type& k);
14 // pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
16 #include <set>
17 #include <cassert>
19 #include "test_macros.h"
20 #include "min_allocator.h"
21 #include "private_constructor.h"
23 int main(int, char**)
26 typedef int V;
27 typedef std::multiset<int> M;
29 typedef std::pair<M::iterator, M::iterator> R;
30 V ar[] =
42 M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
43 R r = m.equal_range(4);
44 assert(r.first == std::next(m.begin(), 0));
45 assert(r.second == std::next(m.begin(), 0));
46 r = m.equal_range(5);
47 assert(r.first == std::next(m.begin(), 0));
48 assert(r.second == std::next(m.begin(), 3));
49 r = m.equal_range(6);
50 assert(r.first == std::next(m.begin(), 3));
51 assert(r.second == std::next(m.begin(), 3));
52 r = m.equal_range(7);
53 assert(r.first == std::next(m.begin(), 3));
54 assert(r.second == std::next(m.begin(), 6));
55 r = m.equal_range(8);
56 assert(r.first == std::next(m.begin(), 6));
57 assert(r.second == std::next(m.begin(), 6));
58 r = m.equal_range(9);
59 assert(r.first == std::next(m.begin(), 6));
60 assert(r.second == std::next(m.begin(), 9));
61 r = m.equal_range(10);
62 assert(r.first == std::next(m.begin(), 9));
63 assert(r.second == std::next(m.begin(), 9));
66 typedef std::pair<M::const_iterator, M::const_iterator> R;
67 V ar[] =
79 const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
80 R r = m.equal_range(4);
81 assert(r.first == std::next(m.begin(), 0));
82 assert(r.second == std::next(m.begin(), 0));
83 r = m.equal_range(5);
84 assert(r.first == std::next(m.begin(), 0));
85 assert(r.second == std::next(m.begin(), 3));
86 r = m.equal_range(6);
87 assert(r.first == std::next(m.begin(), 3));
88 assert(r.second == std::next(m.begin(), 3));
89 r = m.equal_range(7);
90 assert(r.first == std::next(m.begin(), 3));
91 assert(r.second == std::next(m.begin(), 6));
92 r = m.equal_range(8);
93 assert(r.first == std::next(m.begin(), 6));
94 assert(r.second == std::next(m.begin(), 6));
95 r = m.equal_range(9);
96 assert(r.first == std::next(m.begin(), 6));
97 assert(r.second == std::next(m.begin(), 9));
98 r = m.equal_range(10);
99 assert(r.first == std::next(m.begin(), 9));
100 assert(r.second == std::next(m.begin(), 9));
103 #if TEST_STD_VER >= 11
105 typedef int V;
106 typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
108 typedef std::pair<M::iterator, M::iterator> R;
109 V ar[] =
121 M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
122 R r = m.equal_range(4);
123 assert(r.first == std::next(m.begin(), 0));
124 assert(r.second == std::next(m.begin(), 0));
125 r = m.equal_range(5);
126 assert(r.first == std::next(m.begin(), 0));
127 assert(r.second == std::next(m.begin(), 3));
128 r = m.equal_range(6);
129 assert(r.first == std::next(m.begin(), 3));
130 assert(r.second == std::next(m.begin(), 3));
131 r = m.equal_range(7);
132 assert(r.first == std::next(m.begin(), 3));
133 assert(r.second == std::next(m.begin(), 6));
134 r = m.equal_range(8);
135 assert(r.first == std::next(m.begin(), 6));
136 assert(r.second == std::next(m.begin(), 6));
137 r = m.equal_range(9);
138 assert(r.first == std::next(m.begin(), 6));
139 assert(r.second == std::next(m.begin(), 9));
140 r = m.equal_range(10);
141 assert(r.first == std::next(m.begin(), 9));
142 assert(r.second == std::next(m.begin(), 9));
145 typedef std::pair<M::const_iterator, M::const_iterator> R;
146 V ar[] =
158 const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
159 R r = m.equal_range(4);
160 assert(r.first == std::next(m.begin(), 0));
161 assert(r.second == std::next(m.begin(), 0));
162 r = m.equal_range(5);
163 assert(r.first == std::next(m.begin(), 0));
164 assert(r.second == std::next(m.begin(), 3));
165 r = m.equal_range(6);
166 assert(r.first == std::next(m.begin(), 3));
167 assert(r.second == std::next(m.begin(), 3));
168 r = m.equal_range(7);
169 assert(r.first == std::next(m.begin(), 3));
170 assert(r.second == std::next(m.begin(), 6));
171 r = m.equal_range(8);
172 assert(r.first == std::next(m.begin(), 6));
173 assert(r.second == std::next(m.begin(), 6));
174 r = m.equal_range(9);
175 assert(r.first == std::next(m.begin(), 6));
176 assert(r.second == std::next(m.begin(), 9));
177 r = m.equal_range(10);
178 assert(r.first == std::next(m.begin(), 9));
179 assert(r.second == std::next(m.begin(), 9));
182 #endif
183 #if TEST_STD_VER > 11
185 typedef int V;
186 typedef std::multiset<V, std::less<>> M;
187 typedef std::pair<M::iterator, M::iterator> R;
188 V ar[] =
200 M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
201 R r = m.equal_range(4);
202 assert(r.first == std::next(m.begin(), 0));
203 assert(r.second == std::next(m.begin(), 0));
204 r = m.equal_range(5);
205 assert(r.first == std::next(m.begin(), 0));
206 assert(r.second == std::next(m.begin(), 3));
207 r = m.equal_range(6);
208 assert(r.first == std::next(m.begin(), 3));
209 assert(r.second == std::next(m.begin(), 3));
210 r = m.equal_range(7);
211 assert(r.first == std::next(m.begin(), 3));
212 assert(r.second == std::next(m.begin(), 6));
213 r = m.equal_range(8);
214 assert(r.first == std::next(m.begin(), 6));
215 assert(r.second == std::next(m.begin(), 6));
216 r = m.equal_range(9);
217 assert(r.first == std::next(m.begin(), 6));
218 assert(r.second == std::next(m.begin(), 9));
219 r = m.equal_range(10);
220 assert(r.first == std::next(m.begin(), 9));
221 assert(r.second == std::next(m.begin(), 9));
225 typedef PrivateConstructor V;
226 typedef std::multiset<V, std::less<>> M;
227 typedef std::pair<M::iterator, M::iterator> R;
229 M m;
230 m.insert ( V::make ( 5 ));
231 m.insert ( V::make ( 5 ));
232 m.insert ( V::make ( 5 ));
233 m.insert ( V::make ( 7 ));
234 m.insert ( V::make ( 7 ));
235 m.insert ( V::make ( 7 ));
236 m.insert ( V::make ( 9 ));
237 m.insert ( V::make ( 9 ));
238 m.insert ( V::make ( 9 ));
240 R r = m.equal_range(4);
241 assert(r.first == std::next(m.begin(), 0));
242 assert(r.second == std::next(m.begin(), 0));
243 r = m.equal_range(5);
244 assert(r.first == std::next(m.begin(), 0));
245 assert(r.second == std::next(m.begin(), 3));
246 r = m.equal_range(6);
247 assert(r.first == std::next(m.begin(), 3));
248 assert(r.second == std::next(m.begin(), 3));
249 r = m.equal_range(7);
250 assert(r.first == std::next(m.begin(), 3));
251 assert(r.second == std::next(m.begin(), 6));
252 r = m.equal_range(8);
253 assert(r.first == std::next(m.begin(), 6));
254 assert(r.second == std::next(m.begin(), 6));
255 r = m.equal_range(9);
256 assert(r.first == std::next(m.begin(), 6));
257 assert(r.second == std::next(m.begin(), 9));
258 r = m.equal_range(10);
259 assert(r.first == std::next(m.begin(), 9));
260 assert(r.second == std::next(m.begin(), 9));
262 #endif
264 return 0;