[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / libcxx / test / std / containers / set_allocator_requirement_test_templates.h
blob5135a16ec8bbb232a9dee01dcac17e1e6146dec6
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 //===----------------------------------------------------------------------===//
8 #ifndef SET_ALLOCATOR_REQUIREMENT_TEST_TEMPLATES_H
9 #define SET_ALLOCATOR_REQUIREMENT_TEST_TEMPLATES_H
11 // <set>
12 // <unordered_set>
14 // class set
15 // class unordered_set
17 // insert(...);
18 // emplace(...);
19 // emplace_hint(...);
22 #include <cassert>
24 #include "test_macros.h"
25 #include "count_new.h"
26 #include "container_test_types.h"
27 #include "assert_checkpoint.h"
30 template <class Container>
31 void testSetInsert()
33 typedef typename Container::value_type ValueTp;
34 ConstructController* cc = getConstructController();
35 cc->reset();
37 CHECKPOINT("Testing C::insert(const value_type&)");
38 Container c;
39 const ValueTp v(42);
40 cc->expect<const ValueTp&>();
41 assert(c.insert(v).second);
42 assert(!cc->unchecked());
44 DisableAllocationGuard g;
45 const ValueTp v2(42);
46 assert(c.insert(v2).second == false);
50 CHECKPOINT("Testing C::insert(value_type&)");
51 Container c;
52 ValueTp v(42);
53 cc->expect<const ValueTp&>();
54 assert(c.insert(v).second);
55 assert(!cc->unchecked());
57 DisableAllocationGuard g;
58 ValueTp v2(42);
59 assert(c.insert(v2).second == false);
63 CHECKPOINT("Testing C::insert(value_type&&)");
64 Container c;
65 ValueTp v(42);
66 cc->expect<ValueTp&&>();
67 assert(c.insert(std::move(v)).second);
68 assert(!cc->unchecked());
70 DisableAllocationGuard g;
71 ValueTp v2(42);
72 assert(c.insert(std::move(v2)).second == false);
76 CHECKPOINT("Testing C::insert(const value_type&&)");
77 Container c;
78 const ValueTp v(42);
79 cc->expect<const ValueTp&>();
80 assert(c.insert(std::move(v)).second);
81 assert(!cc->unchecked());
83 DisableAllocationGuard g;
84 const ValueTp v2(42);
85 assert(c.insert(std::move(v2)).second == false);
89 CHECKPOINT("Testing C::insert(std::initializer_list<ValueTp>)");
90 Container c;
91 std::initializer_list<ValueTp> il = { ValueTp(1), ValueTp(2) };
92 cc->expect<ValueTp const&>(2);
93 c.insert(il);
94 assert(!cc->unchecked());
96 DisableAllocationGuard g;
97 c.insert(il);
101 CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type const&");
102 Container c;
103 const ValueTp ValueList[] = { ValueTp(1), ValueTp(2), ValueTp(3) };
104 cc->expect<ValueTp const&>(3);
105 c.insert(std::begin(ValueList), std::end(ValueList));
106 assert(!cc->unchecked());
108 DisableAllocationGuard g;
109 c.insert(std::begin(ValueList), std::end(ValueList));
113 CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type&&");
114 Container c;
115 ValueTp ValueList[] = { ValueTp(1), ValueTp(2) , ValueTp(3) };
116 cc->expect<ValueTp&&>(3);
117 c.insert(std::move_iterator<ValueTp*>(std::begin(ValueList)),
118 std::move_iterator<ValueTp*>(std::end(ValueList)));
119 assert(!cc->unchecked());
121 DisableAllocationGuard g;
122 ValueTp ValueList2[] = { ValueTp(1), ValueTp(2) , ValueTp(3) };
123 c.insert(std::move_iterator<ValueTp*>(std::begin(ValueList2)),
124 std::move_iterator<ValueTp*>(std::end(ValueList2)));
128 CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type&");
129 Container c;
130 ValueTp ValueList[] = { ValueTp(1), ValueTp(2) , ValueTp(3) };
131 cc->expect<ValueTp const&>(3);
132 c.insert(std::begin(ValueList), std::end(ValueList));
133 assert(!cc->unchecked());
135 DisableAllocationGuard g;
136 c.insert(std::begin(ValueList), std::end(ValueList));
142 template <class Container>
143 void testSetEmplace()
145 typedef typename Container::value_type ValueTp;
146 ConstructController* cc = getConstructController();
147 cc->reset();
149 CHECKPOINT("Testing C::emplace(const value_type&)");
150 Container c;
151 const ValueTp v(42);
152 cc->expect<const ValueTp&>();
153 assert(c.emplace(v).second);
154 assert(!cc->unchecked());
156 DisableAllocationGuard g;
157 const ValueTp v2(42);
158 assert(c.emplace(v2).second == false);
162 CHECKPOINT("Testing C::emplace(value_type&)");
163 Container c;
164 ValueTp v(42);
165 cc->expect<ValueTp&>();
166 assert(c.emplace(v).second);
167 assert(!cc->unchecked());
169 DisableAllocationGuard g;
170 ValueTp v2(42);
171 assert(c.emplace(v2).second == false);
175 CHECKPOINT("Testing C::emplace(value_type&&)");
176 Container c;
177 ValueTp v(42);
178 cc->expect<ValueTp&&>();
179 assert(c.emplace(std::move(v)).second);
180 assert(!cc->unchecked());
182 DisableAllocationGuard g;
183 ValueTp v2(42);
184 assert(c.emplace(std::move(v2)).second == false);
188 CHECKPOINT("Testing C::emplace(const value_type&&)");
189 Container c;
190 const ValueTp v(42);
191 cc->expect<const ValueTp&&>();
192 assert(c.emplace(std::move(v)).second);
193 assert(!cc->unchecked());
195 DisableAllocationGuard g;
196 const ValueTp v2(42);
197 assert(c.emplace(std::move(v2)).second == false);
203 template <class Container>
204 void testSetEmplaceHint()
206 typedef typename Container::value_type ValueTp;
207 typedef Container C;
208 typedef typename C::iterator It;
209 ConstructController* cc = getConstructController();
210 cc->reset();
212 CHECKPOINT("Testing C::emplace_hint(p, const value_type&)");
213 Container c;
214 const ValueTp v(42);
215 cc->expect<const ValueTp&>();
216 It ret = c.emplace_hint(c.end(), v);
217 assert(ret != c.end());
218 assert(c.size() == 1);
219 assert(!cc->unchecked());
221 DisableAllocationGuard g;
222 const ValueTp v2(42);
223 It ret2 = c.emplace_hint(c.begin(), v2);
224 assert(&(*ret2) == &(*ret));
225 assert(c.size() == 1);
229 CHECKPOINT("Testing C::emplace_hint(p, value_type&)");
230 Container c;
231 ValueTp v(42);
232 cc->expect<ValueTp&>();
233 It ret = c.emplace_hint(c.end(), v);
234 assert(ret != c.end());
235 assert(c.size() == 1);
236 assert(!cc->unchecked());
238 DisableAllocationGuard g;
239 ValueTp v2(42);
240 It ret2 = c.emplace_hint(c.begin(), v2);
241 assert(&(*ret2) == &(*ret));
242 assert(c.size() == 1);
246 CHECKPOINT("Testing C::emplace_hint(p, value_type&&)");
247 Container c;
248 ValueTp v(42);
249 cc->expect<ValueTp&&>();
250 It ret = c.emplace_hint(c.end(), std::move(v));
251 assert(ret != c.end());
252 assert(c.size() == 1);
253 assert(!cc->unchecked());
255 DisableAllocationGuard g;
256 ValueTp v2(42);
257 It ret2 = c.emplace_hint(c.begin(), std::move(v2));
258 assert(&(*ret2) == &(*ret));
259 assert(c.size() == 1);
263 CHECKPOINT("Testing C::emplace_hint(p, const value_type&&)");
264 Container c;
265 const ValueTp v(42);
266 cc->expect<const ValueTp&&>();
267 It ret = c.emplace_hint(c.end(), std::move(v));
268 assert(ret != c.end());
269 assert(c.size() == 1);
270 assert(!cc->unchecked());
272 DisableAllocationGuard g;
273 const ValueTp v2(42);
274 It ret2 = c.emplace_hint(c.begin(), std::move(v2));
275 assert(&(*ret2) == &(*ret));
276 assert(c.size() == 1);
282 template <class Container>
283 void testMultisetInsert()
285 typedef typename Container::value_type ValueTp;
286 ConstructController* cc = getConstructController();
287 cc->reset();
289 CHECKPOINT("Testing C::insert(const value_type&)");
290 Container c;
291 const ValueTp v(42);
292 cc->expect<const ValueTp&>();
293 c.insert(v);
294 assert(!cc->unchecked());
297 CHECKPOINT("Testing C::insert(value_type&)");
298 Container c;
299 ValueTp v(42);
300 cc->expect<const ValueTp&>();
301 c.insert(v);
302 assert(!cc->unchecked());
305 CHECKPOINT("Testing C::insert(value_type&&)");
306 Container c;
307 ValueTp v(42);
308 cc->expect<ValueTp&&>();
309 c.insert(std::move(v));
310 assert(!cc->unchecked());
313 CHECKPOINT("Testing C::insert(std::initializer_list<ValueTp>)");
314 Container c;
315 std::initializer_list<ValueTp> il = { ValueTp(1), ValueTp(2) };
316 cc->expect<ValueTp const&>(2);
317 c.insert(il);
318 assert(!cc->unchecked());
321 CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type const&");
322 Container c;
323 const ValueTp ValueList[] = { ValueTp(1), ValueTp(2), ValueTp(3) };
324 cc->expect<ValueTp const&>(3);
325 c.insert(std::begin(ValueList), std::end(ValueList));
326 assert(!cc->unchecked());
329 CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type&&");
330 Container c;
331 ValueTp ValueList[] = { ValueTp(1), ValueTp(2) , ValueTp(3) };
332 cc->expect<ValueTp&&>(3);
333 c.insert(std::move_iterator<ValueTp*>(std::begin(ValueList)),
334 std::move_iterator<ValueTp*>(std::end(ValueList)));
335 assert(!cc->unchecked());
338 CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type&");
339 Container c;
340 ValueTp ValueList[] = { ValueTp(1), ValueTp(2) , ValueTp(1) };
341 cc->expect<ValueTp&>(3);
342 c.insert(std::begin(ValueList), std::end(ValueList));
343 assert(!cc->unchecked());
348 template <class Container>
349 void testMultisetEmplace()
351 typedef typename Container::value_type ValueTp;
352 ConstructController* cc = getConstructController();
353 cc->reset();
355 CHECKPOINT("Testing C::emplace(const value_type&)");
356 Container c;
357 const ValueTp v(42);
358 cc->expect<const ValueTp&>();
359 c.emplace(v);
360 assert(!cc->unchecked());
363 CHECKPOINT("Testing C::emplace(value_type&)");
364 Container c;
365 ValueTp v(42);
366 cc->expect<ValueTp&>();
367 c.emplace(v);
368 assert(!cc->unchecked());
371 CHECKPOINT("Testing C::emplace(value_type&&)");
372 Container c;
373 ValueTp v(42);
374 cc->expect<ValueTp&&>();
375 c.emplace(std::move(v));
376 assert(!cc->unchecked());
379 CHECKPOINT("Testing C::emplace(const value_type&&)");
380 Container c;
381 const ValueTp v(42);
382 cc->expect<const ValueTp&&>();
383 c.emplace(std::move(v));
384 assert(!cc->unchecked());
388 #endif