]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
Vendor import of libc++ release_39 branch r276489:
[FreeBSD/FreeBSD.git] / test / std / containers / sequences / list / list.modifiers / insert_iter_size_value.pass.cpp
1 //===----------------------------------------------------------------------===//
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
10 // XFAIL: libcpp-no-exceptions
11 // <list>
12
13 // iterator insert(const_iterator position, size_type n, const value_type& x);
14
15 // UNSUPPORTED: sanitizer-new-delete
16
17 #include <list>
18 #include <cstdlib>
19 #include <cassert>
20
21 #include "min_allocator.h"
22 #include "count_new.hpp"
23
24 template <class List>
25 void test() {
26     int a1[] = {1, 2, 3};
27     int a2[] = {1, 4, 4, 4, 4, 4, 2, 3};
28     List l1(a1, a1+3);
29     typename List::iterator i = l1.insert(next(l1.cbegin()), 5, 4);
30     assert(i == next(l1.begin()));
31     assert(l1 == List(a2, a2+8));
32     globalMemCounter.throw_after = 4;
33     int save_count = globalMemCounter.outstanding_new;
34     try
35     {
36         i = l1.insert(i, 5, 5);
37         assert(false);
38     }
39     catch (...)
40     {
41     }
42     assert(globalMemCounter.checkOutstandingNewEq(save_count));
43     assert(l1 == List(a2, a2+8));
44 }
45
46 int main()
47 {
48     test<std::list<int> >();
49 #if TEST_STD_VER >= 11
50     test<std::list<int, min_allocator<int>>>();
51 #endif
52 }