blob: 2ae3a2e3c87a4dba9507c248e319c0efa5b0393f [file] [log] [blame]
Eric Fiselier83c9dc12016-04-15 23:27:27 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9#ifndef MAP_ALLOCATOR_REQUIREMENT_TEST_TEMPLATES_H
10#define MAP_ALLOCATOR_REQUIREMENT_TEST_TEMPLATES_H
11
12// <map>
13// <unordered_map>
14
15// class map
16// class unordered_map
17
18// insert(...);
19// emplace(...);
20// emplace_hint(...);
21
22// UNSUPPORTED: c++98, c++03
23
24#include <cassert>
25
26#include "test_macros.h"
27#include "count_new.hpp"
28#include "container_test_types.h"
29#include "assert_checkpoint.h"
30
31
32template <class Container>
33void testMapInsert()
34{
35 typedef typename Container::value_type ValueTp;
Eric Fiselier91a15652016-04-18 01:40:45 +000036 typedef typename Container::key_type Key;
37 typedef typename Container::mapped_type Mapped;
Eric Fiselier83c9dc12016-04-15 23:27:27 +000038 typedef Container C;
39 typedef std::pair<typename C::iterator, bool> R;
40 ConstructController* cc = getConstructController();
41 cc->reset();
42 {
43 CHECKPOINT("Testing C::insert(const value_type&)");
44 Container c;
45 const ValueTp v(42, 1);
46 cc->expect<const ValueTp&>();
47 assert(c.insert(v).second);
48 assert(!cc->unchecked());
49 {
50 DisableAllocationGuard g;
51 const ValueTp v2(42, 1);
52 assert(c.insert(v2).second == false);
53 }
54 }
55 {
56 CHECKPOINT("Testing C::insert(value_type&)");
57 Container c;
58 ValueTp v(42, 1);
59 cc->expect<const ValueTp&>();
60 assert(c.insert(v).second);
61 assert(!cc->unchecked());
62 {
63 DisableAllocationGuard g;
64 ValueTp v2(42, 1);
65 assert(c.insert(v2).second == false);
66 }
67 }
68 {
69 CHECKPOINT("Testing C::insert(value_type&&)");
70 Container c;
71 ValueTp v(42, 1);
72 cc->expect<ValueTp&&>();
73 assert(c.insert(std::move(v)).second);
74 assert(!cc->unchecked());
75 {
76 DisableAllocationGuard g;
77 ValueTp v2(42, 1);
78 assert(c.insert(std::move(v2)).second == false);
79 }
80 }
81 {
82 CHECKPOINT("Testing C::insert(const value_type&&)");
83 Container c;
84 const ValueTp v(42, 1);
85 cc->expect<const ValueTp&>();
86 assert(c.insert(std::move(v)).second);
87 assert(!cc->unchecked());
88 {
89 DisableAllocationGuard g;
90 const ValueTp v2(42, 1);
91 assert(c.insert(std::move(v2)).second == false);
92 }
93 }
94 {
Eric Fiselier91a15652016-04-18 01:40:45 +000095 CHECKPOINT("Testing C::insert({key, value})");
96 Container c;
97 cc->expect<ValueTp&&>();
98 assert(c.insert({42, 1}).second);
99 assert(!cc->unchecked());
100 {
101 DisableAllocationGuard g;
102 const ValueTp v2(42, 1);
103 assert(c.insert(std::move(v2)).second == false);
104 }
105 }
106 {
Eric Fiselier83c9dc12016-04-15 23:27:27 +0000107 CHECKPOINT("Testing C::insert(std::initializer_list<ValueTp>)");
108 Container c;
109 std::initializer_list<ValueTp> il = { ValueTp(1, 1), ValueTp(2, 1) };
110 cc->expect<ValueTp const&>(2);
111 c.insert(il);
112 assert(!cc->unchecked());
113 {
114 DisableAllocationGuard g;
115 c.insert(il);
116 }
117 }
118 {
119 CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type const&");
120 Container c;
121 const ValueTp ValueList[] = { ValueTp(1, 1), ValueTp(2, 1), ValueTp(3, 1) };
122 cc->expect<ValueTp const&>(3);
123 c.insert(std::begin(ValueList), std::end(ValueList));
124 assert(!cc->unchecked());
125 {
126 DisableAllocationGuard g;
127 c.insert(std::begin(ValueList), std::end(ValueList));
128 }
129 }
130 {
131 CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type&&");
132 Container c;
133 ValueTp ValueList[] = { ValueTp(1, 1), ValueTp(2, 1) , ValueTp(3, 1) };
134 cc->expect<ValueTp&&>(3);
135 c.insert(std::move_iterator<ValueTp*>(std::begin(ValueList)),
136 std::move_iterator<ValueTp*>(std::end(ValueList)));
137 assert(!cc->unchecked());
138 {
139 DisableAllocationGuard g;
140 ValueTp ValueList2[] = { ValueTp(1, 1), ValueTp(2, 1) , ValueTp(3, 1) };
141 c.insert(std::move_iterator<ValueTp*>(std::begin(ValueList2)),
142 std::move_iterator<ValueTp*>(std::end(ValueList2)));
143 }
144 }
145 {
146 CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type&");
147 Container c;
148 ValueTp ValueList[] = { ValueTp(1, 1), ValueTp(2, 1) , ValueTp(3, 1) };
149 cc->expect<ValueTp const&>(3);
150 c.insert(std::begin(ValueList), std::end(ValueList));
151 assert(!cc->unchecked());
152 {
153 DisableAllocationGuard g;
154 c.insert(std::begin(ValueList), std::end(ValueList));
155 }
156 }
157}
158
Eric Fiselier91a15652016-04-18 01:40:45 +0000159
160template <class Container>
161void testMapInsertHint()
162{
163 typedef typename Container::value_type ValueTp;
164 typedef typename Container::key_type Key;
165 typedef typename Container::mapped_type Mapped;
166 typedef typename std::pair<Key, Mapped> NonConstKeyPair;
167 typedef Container C;
168 typedef typename C::iterator It;
169 ConstructController* cc = getConstructController();
170 cc->reset();
171 {
172 CHECKPOINT("Testing C::insert(p, const value_type&)");
173 Container c;
174 const ValueTp v(42, 1);
175 cc->expect<const ValueTp&>();
176 It ret = c.insert(c.end(), v);
177 assert(ret != c.end());
178 assert(c.size() == 1);
179 assert(!cc->unchecked());
180 {
181 DisableAllocationGuard g;
182 const ValueTp v2(42, 1);
183 It ret2 = c.insert(c.begin(), v2);
184 assert(&(*ret2) == &(*ret));
185 assert(c.size() == 1);
186 }
187 }
188 {
189 CHECKPOINT("Testing C::insert(p, value_type&)");
190 Container c;
191 ValueTp v(42, 1);
192 cc->expect<ValueTp const&>();
193 It ret = c.insert(c.end(), v);
194 assert(ret != c.end());
195 assert(c.size() == 1);
196 assert(!cc->unchecked());
197 {
198 DisableAllocationGuard g;
199 ValueTp v2(42, 1);
200 It ret2 = c.insert(c.begin(), v2);
201 assert(&(*ret2) == &(*ret));
202 assert(c.size() == 1);
203 }
204 }
205 {
206 CHECKPOINT("Testing C::insert(p, value_type&&)");
207 Container c;
208 ValueTp v(42, 1);
209 cc->expect<ValueTp&&>();
210 It ret = c.insert(c.end(), std::move(v));
211 assert(ret != c.end());
212 assert(c.size() == 1);
213 assert(!cc->unchecked());
214 {
215 DisableAllocationGuard g;
216 ValueTp v2(42, 1);
217 It ret2 = c.insert(c.begin(), std::move(v2));
218 assert(&(*ret2) == &(*ret));
219 assert(c.size() == 1);
220 }
221 }
222 {
223 CHECKPOINT("Testing C::insert(p, {key, value})");
224 Container c;
225 cc->expect<ValueTp&&>();
226 It ret = c.insert(c.end(), {42, 1});
227 assert(ret != c.end());
228 assert(c.size() == 1);
229 assert(!cc->unchecked());
230 {
231 DisableAllocationGuard g;
232 It ret2 = c.insert(c.begin(), {42, 1});
233 assert(&(*ret2) == &(*ret));
234 assert(c.size() == 1);
235 }
236 }
237 {
238 CHECKPOINT("Testing C::insert(p, const value_type&&)");
239 Container c;
240 const ValueTp v(42, 1);
241 cc->expect<const ValueTp&>();
242 It ret = c.insert(c.end(), std::move(v));
243 assert(ret != c.end());
244 assert(c.size() == 1);
245 assert(!cc->unchecked());
246 {
247 DisableAllocationGuard g;
248 const ValueTp v2(42, 1);
249 It ret2 = c.insert(c.begin(), std::move(v2));
250 assert(&(*ret2) == &(*ret));
251 assert(c.size() == 1);
252 }
253 }
254 {
255 CHECKPOINT("Testing C::insert(p, pair<Key, Mapped> const&)");
256 Container c;
257 const NonConstKeyPair v(42, 1);
258 cc->expect<const NonConstKeyPair&>();
259 It ret = c.insert(c.end(), v);
260 assert(ret != c.end());
261 assert(c.size() == 1);
262 assert(!cc->unchecked());
263 {
264 DisableAllocationGuard g;
265 const NonConstKeyPair v2(42, 1);
266 It ret2 = c.insert(c.begin(), v2);
267 assert(&(*ret2) == &(*ret));
268 assert(c.size() == 1);
269 }
270 }
271 {
272 CHECKPOINT("Testing C::insert(p, pair<Key, Mapped>&&)");
273 Container c;
274 NonConstKeyPair v(42, 1);
275 cc->expect<NonConstKeyPair&&>();
276 It ret = c.insert(c.end(), std::move(v));
277 assert(ret != c.end());
278 assert(c.size() == 1);
279 assert(!cc->unchecked());
280 {
281 DisableAllocationGuard g;
282 NonConstKeyPair v2(42, 1);
283 It ret2 = c.insert(c.begin(), std::move(v2));
284 assert(&(*ret2) == &(*ret));
285 assert(c.size() == 1);
286 }
287 }
288
289
290}
291
292
Eric Fiselier83c9dc12016-04-15 23:27:27 +0000293template <class Container>
294void testMapEmplace()
295{
296 typedef typename Container::value_type ValueTp;
297 typedef typename Container::key_type Key;
298 typedef typename Container::mapped_type Mapped;
299 typedef typename std::pair<Key, Mapped> NonConstKeyPair;
300 typedef Container C;
301 typedef std::pair<typename C::iterator, bool> R;
302 ConstructController* cc = getConstructController();
303 cc->reset();
304 {
305 CHECKPOINT("Testing C::emplace(const value_type&)");
306 Container c;
307 const ValueTp v(42, 1);
308 cc->expect<const ValueTp&>();
309 assert(c.emplace(v).second);
310 assert(!cc->unchecked());
311 {
312 DisableAllocationGuard g;
313 const ValueTp v2(42, 1);
314 assert(c.emplace(v2).second == false);
315 }
316 }
317 {
318 CHECKPOINT("Testing C::emplace(value_type&)");
319 Container c;
320 ValueTp v(42, 1);
321 cc->expect<ValueTp&>();
322 assert(c.emplace(v).second);
323 assert(!cc->unchecked());
324 {
325 DisableAllocationGuard g;
326 ValueTp v2(42, 1);
327 assert(c.emplace(v2).second == false);
328 }
329 }
330 {
331 CHECKPOINT("Testing C::emplace(value_type&&)");
332 Container c;
333 ValueTp v(42, 1);
334 cc->expect<ValueTp&&>();
335 assert(c.emplace(std::move(v)).second);
336 assert(!cc->unchecked());
337 {
338 DisableAllocationGuard g;
339 ValueTp v2(42, 1);
340 assert(c.emplace(std::move(v2)).second == false);
341 }
342 }
343 {
344 CHECKPOINT("Testing C::emplace(const value_type&&)");
345 Container c;
346 const ValueTp v(42, 1);
347 cc->expect<const ValueTp&&>();
348 assert(c.emplace(std::move(v)).second);
349 assert(!cc->unchecked());
350 {
351 DisableAllocationGuard g;
352 const ValueTp v2(42, 1);
353 assert(c.emplace(std::move(v2)).second == false);
354 }
355 }
356 {
357 CHECKPOINT("Testing C::emplace(pair<Key, Mapped> const&)");
358 Container c;
359 const NonConstKeyPair v(42, 1);
360 cc->expect<const NonConstKeyPair&>();
361 assert(c.emplace(v).second);
362 assert(!cc->unchecked());
363 {
364 DisableAllocationGuard g;
365 const NonConstKeyPair v2(42, 1);
366 assert(c.emplace(v2).second == false);
367 }
368 }
369 {
370 CHECKPOINT("Testing C::emplace(pair<Key, Mapped> &&)");
371 Container c;
372 NonConstKeyPair v(42, 1);
373 cc->expect<NonConstKeyPair&&>();
374 assert(c.emplace(std::move(v)).second);
375 assert(!cc->unchecked());
376 {
377 DisableAllocationGuard g;
378 NonConstKeyPair v2(42, 1);
379 assert(c.emplace(std::move(v2)).second == false);
380 }
381 }
Eric Fiselierdc414cd2016-04-16 00:23:12 +0000382 {
383 CHECKPOINT("Testing C::emplace(const Key&, ConvertibleToMapped&&)");
384 Container c;
385 const Key k(42);
386 cc->expect<Key const&, int&&>();
387 assert(c.emplace(k, 1).second);
388 assert(!cc->unchecked());
389 {
390 DisableAllocationGuard g;
391 const Key k2(42);
392 assert(c.emplace(k2, 2).second == false);
393 }
394 }
395 {
396 CHECKPOINT("Testing C::emplace(Key&, Mapped&)");
397 Container c;
398 Key k(42);
399 Mapped m(1);
400 cc->expect<Key&, Mapped&>();
401 assert(c.emplace(k, m).second);
402 assert(!cc->unchecked());
403 {
404 DisableAllocationGuard g;
405 Key k2(42);
406 assert(c.emplace(k2, m).second == false);
407 }
408 }
409 {
410 CHECKPOINT("Testing C::emplace(Key&&, Mapped&&)");
411 Container c;
412 Key k(42);
413 Mapped m(1);
414 cc->expect<Key&&, Mapped&&>();
415 assert(c.emplace(std::move(k), std::move(m)).second);
416 assert(!cc->unchecked());
417 {
418 DisableAllocationGuard g;
419 Key k2(42);
420 Mapped m2(2);
421 assert(c.emplace(std::move(k2), std::move(m2)).second == false);
422 }
423 }
424 {
425 CHECKPOINT("Testing C::emplace(ConvertibleToKey&&, ConvertibleToMapped&&)");
426 Container c;
427 cc->expect<int&&, int&&>();
428 assert(c.emplace(42, 1).second);
429 assert(!cc->unchecked());
430 {
431 // test that emplacing a duplicate item allocates. We cannot optimize
432 // this case because int&& does not match the type of key exactly.
433 cc->expect<int&&, int&&>();
434 assert(c.emplace(42, 1).second == false);
435 assert(!cc->unchecked());
436 }
437 }
Eric Fiselier83c9dc12016-04-15 23:27:27 +0000438}
439
440
441template <class Container>
442void testMapEmplaceHint()
443{
444 typedef typename Container::value_type ValueTp;
445 typedef typename Container::key_type Key;
446 typedef typename Container::mapped_type Mapped;
447 typedef typename std::pair<Key, Mapped> NonConstKeyPair;
448 typedef Container C;
449 typedef typename C::iterator It;
450 ConstructController* cc = getConstructController();
451 cc->reset();
452 {
453 CHECKPOINT("Testing C::emplace_hint(p, const value_type&)");
454 Container c;
455 const ValueTp v(42, 1);
456 cc->expect<const ValueTp&>();
457 It ret = c.emplace_hint(c.end(), v);
458 assert(ret != c.end());
459 assert(c.size() == 1);
460 assert(!cc->unchecked());
461 {
462 DisableAllocationGuard g;
463 const ValueTp v2(42, 1);
464 It ret2 = c.emplace_hint(c.begin(), v2);
465 assert(&(*ret2) == &(*ret));
466 assert(c.size() == 1);
467 }
468 }
469 {
470 CHECKPOINT("Testing C::emplace_hint(p, value_type&)");
471 Container c;
472 ValueTp v(42, 1);
473 cc->expect<ValueTp&>();
474 It ret = c.emplace_hint(c.end(), v);
475 assert(ret != c.end());
476 assert(c.size() == 1);
477 assert(!cc->unchecked());
478 {
479 DisableAllocationGuard g;
480 ValueTp v2(42, 1);
481 It ret2 = c.emplace_hint(c.begin(), v2);
482 assert(&(*ret2) == &(*ret));
483 assert(c.size() == 1);
484 }
485 }
486 {
487 CHECKPOINT("Testing C::emplace_hint(p, value_type&&)");
488 Container c;
489 ValueTp v(42, 1);
490 cc->expect<ValueTp&&>();
491 It ret = c.emplace_hint(c.end(), std::move(v));
492 assert(ret != c.end());
493 assert(c.size() == 1);
494 assert(!cc->unchecked());
495 {
496 DisableAllocationGuard g;
497 ValueTp v2(42, 1);
498 It ret2 = c.emplace_hint(c.begin(), std::move(v2));
499 assert(&(*ret2) == &(*ret));
500 assert(c.size() == 1);
501 }
502 }
503 {
504 CHECKPOINT("Testing C::emplace_hint(p, const value_type&&)");
505 Container c;
506 const ValueTp v(42, 1);
507 cc->expect<const ValueTp&&>();
508 It ret = c.emplace_hint(c.end(), std::move(v));
509 assert(ret != c.end());
510 assert(c.size() == 1);
511 assert(!cc->unchecked());
512 {
513 DisableAllocationGuard g;
514 const ValueTp v2(42, 1);
515 It ret2 = c.emplace_hint(c.begin(), std::move(v2));
516 assert(&(*ret2) == &(*ret));
517 assert(c.size() == 1);
518 }
519 }
520 {
521 CHECKPOINT("Testing C::emplace_hint(p, pair<Key, Mapped> const&)");
522 Container c;
523 const NonConstKeyPair v(42, 1);
524 cc->expect<const NonConstKeyPair&>();
525 It ret = c.emplace_hint(c.end(), v);
526 assert(ret != c.end());
527 assert(c.size() == 1);
528 assert(!cc->unchecked());
529 {
530 DisableAllocationGuard g;
531 const NonConstKeyPair v2(42, 1);
532 It ret2 = c.emplace_hint(c.begin(), v2);
533 assert(&(*ret2) == &(*ret));
534 assert(c.size() == 1);
535 }
536 }
537 {
538 CHECKPOINT("Testing C::emplace_hint(p, pair<Key, Mapped>&&)");
539 Container c;
540 NonConstKeyPair v(42, 1);
541 cc->expect<NonConstKeyPair&&>();
542 It ret = c.emplace_hint(c.end(), std::move(v));
543 assert(ret != c.end());
544 assert(c.size() == 1);
545 assert(!cc->unchecked());
546 {
547 DisableAllocationGuard g;
548 NonConstKeyPair v2(42, 1);
549 It ret2 = c.emplace_hint(c.begin(), std::move(v2));
550 assert(&(*ret2) == &(*ret));
551 assert(c.size() == 1);
552 }
553 }
Eric Fiselierdc414cd2016-04-16 00:23:12 +0000554 {
555 CHECKPOINT("Testing C::emplace_hint(p, const Key&, ConvertibleToMapped&&)");
556 Container c;
557 const Key k(42);
558 cc->expect<Key const&, int&&>();
559 It ret = c.emplace_hint(c.end(), k, 42);
560 assert(ret != c.end());
561 assert(c.size() == 1);
562 assert(!cc->unchecked());
563 {
564 DisableAllocationGuard g;
565 const Key k2(42);
566 It ret2 = c.emplace_hint(c.begin(), k2, 1);
567 assert(&(*ret2) == &(*ret));
568 assert(c.size() == 1);
569 }
570 }
571 {
572 CHECKPOINT("Testing C::emplace_hint(p, Key&, Mapped&)");
573 Container c;
574 Key k(42);
575 Mapped m(1);
576 cc->expect<Key&, Mapped&>();
577 It ret = c.emplace_hint(c.end(), k, m);
578 assert(ret != c.end());
579 assert(c.size() == 1);
580 assert(!cc->unchecked());
581 {
582 DisableAllocationGuard g;
583 Key k2(42);
584 Mapped m2(2);
585 It ret2 = c.emplace_hint(c.begin(), k2, m2);
586 assert(&(*ret2) == &(*ret));
587 assert(c.size() == 1);
588 }
589 }
590 {
591 CHECKPOINT("Testing C::emplace_hint(p, Key&&, Mapped&&)");
592 Container c;
593 Key k(42);
594 Mapped m(1);
595 cc->expect<Key&&, Mapped&&>();
596 It ret = c.emplace_hint(c.end(), std::move(k), std::move(m));
597 assert(ret != c.end());
598 assert(c.size() == 1);
599 assert(!cc->unchecked());
600 {
601 DisableAllocationGuard g;
602 Key k2(42);
603 Mapped m2(2);
604 It ret2 = c.emplace_hint(c.begin(), std::move(k2), std::move(m2));
605 assert(&(*ret2) == &(*ret));
606 assert(c.size() == 1);
607 }
608 }
609 {
610 CHECKPOINT("Testing C::emplace_hint(p, ConvertibleToKey&&, ConvertibleToMapped&&)");
611 Container c;
612 cc->expect<int&&, int&&>();
613 It ret = c.emplace_hint(c.end(), 42, 1);
614 assert(ret != c.end());
615 assert(c.size() == 1);
616 assert(!cc->unchecked());
617 {
618 cc->expect<int&&, int&&>();
619 It ret2 = c.emplace_hint(c.begin(), 42, 2);
620 assert(&(*ret2) == &(*ret));
621 assert(c.size() == 1);
622 assert(!cc->unchecked());
623 }
624 }
625
Eric Fiselier83c9dc12016-04-15 23:27:27 +0000626}
627
628
629template <class Container>
630void testMultimapInsert()
631{
632 typedef typename Container::value_type ValueTp;
633 typedef Container C;
634 ConstructController* cc = getConstructController();
635 cc->reset();
636 {
637 CHECKPOINT("Testing C::insert(const value_type&)");
638 Container c;
639 const ValueTp v(42, 1);
640 cc->expect<const ValueTp&>();
641 c.insert(v);
642 assert(!cc->unchecked());
643 }
644 {
645 CHECKPOINT("Testing C::insert(value_type&)");
646 Container c;
647 ValueTp v(42, 1);
648 cc->expect<ValueTp&>();
649 c.insert(v);
650 assert(!cc->unchecked());
651 }
652 {
653 CHECKPOINT("Testing C::insert(value_type&&)");
654 Container c;
655 ValueTp v(42, 1);
656 cc->expect<ValueTp&&>();
657 c.insert(std::move(v));
658 assert(!cc->unchecked());
659 }
660 {
Eric Fiselier91a15652016-04-18 01:40:45 +0000661 CHECKPOINT("Testing C::insert({key, value})");
662 Container c;
663 cc->expect<ValueTp&&>();
664 c.insert({42, 1});
665 assert(!cc->unchecked());
666 }
667 {
Eric Fiselier83c9dc12016-04-15 23:27:27 +0000668 CHECKPOINT("Testing C::insert(std::initializer_list<ValueTp>)");
669 Container c;
670 std::initializer_list<ValueTp> il = { ValueTp(1, 1), ValueTp(2, 1) };
671 cc->expect<ValueTp const&>(2);
672 c.insert(il);
673 assert(!cc->unchecked());
674 }
675 {
676 CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type const&");
677 Container c;
678 const ValueTp ValueList[] = { ValueTp(1, 1), ValueTp(2, 1), ValueTp(3, 1) };
679 cc->expect<ValueTp const&>(3);
680 c.insert(std::begin(ValueList), std::end(ValueList));
681 assert(!cc->unchecked());
682 }
683 {
684 CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type&&");
685 Container c;
686 ValueTp ValueList[] = { ValueTp(1, 1), ValueTp(2, 1) , ValueTp(3, 1) };
687 cc->expect<ValueTp&&>(3);
688 c.insert(std::move_iterator<ValueTp*>(std::begin(ValueList)),
689 std::move_iterator<ValueTp*>(std::end(ValueList)));
690 assert(!cc->unchecked());
691 }
692 {
693 CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type&");
694 Container c;
695 ValueTp ValueList[] = { ValueTp(1, 1), ValueTp(2, 1) , ValueTp(3, 1) };
696 cc->expect<ValueTp&>(3);
697 c.insert(std::begin(ValueList), std::end(ValueList));
698 assert(!cc->unchecked());
699 }
Eric Fiselier91a15652016-04-18 01:40:45 +0000700}
Eric Fiselierdc414cd2016-04-16 00:23:12 +0000701
Eric Fiselier91a15652016-04-18 01:40:45 +0000702
703template <class Container>
704void testMultimapInsertHint()
705{
706 typedef typename Container::value_type ValueTp;
707 typedef Container C;
708 ConstructController* cc = getConstructController();
709 cc->reset();
710 {
711 CHECKPOINT("Testing C::insert(p, const value_type&)");
712 Container c;
713 const ValueTp v(42, 1);
714 cc->expect<const ValueTp&>();
715 c.insert(c.begin(), v);
716 assert(!cc->unchecked());
717 }
718 {
719 CHECKPOINT("Testing C::insert(p, value_type&)");
720 Container c;
721 ValueTp v(42, 1);
722 cc->expect<ValueTp&>();
723 c.insert(c.begin(), v);
724 assert(!cc->unchecked());
725 }
726 {
727 CHECKPOINT("Testing C::insert(p, value_type&&)");
728 Container c;
729 ValueTp v(42, 1);
730 cc->expect<ValueTp&&>();
731 c.insert(c.begin(), std::move(v));
732 assert(!cc->unchecked());
733 }
734 {
735 CHECKPOINT("Testing C::insert(p, {key, value})");
736 Container c;
737 cc->expect<ValueTp&&>();
738 c.insert(c.begin(), {42, 1});
739 assert(!cc->unchecked());
740 }
Eric Fiselier83c9dc12016-04-15 23:27:27 +0000741}
742
Eric Fiselierdc414cd2016-04-16 00:23:12 +0000743#endif