[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / libcxx / test / std / containers / sequences / vector.bool / insert_iter_iter_iter.pass.cpp
blobb9a92189169e567dce8f9ad658ae5947a1a1724f
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 // <vector>
10 // vector<bool>
12 // template <class Iter>
13 // iterator insert(const_iterator position, Iter first, Iter last);
15 #include <vector>
16 #include <cassert>
17 #include <cstddef>
19 #include "test_macros.h"
20 #include "test_iterators.h"
21 #include "min_allocator.h"
23 int main(int, char**)
26 std::vector<bool> v(100);
27 bool a[] = {1, 0, 0, 1, 1};
28 const unsigned N = sizeof(a)/sizeof(a[0]);
29 std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const bool*>(a),
30 input_iterator<const bool*>(a+N));
31 assert(v.size() == 100 + N);
32 assert(i == v.begin() + 10);
33 std::size_t j;
34 for (j = 0; j < 10; ++j)
35 assert(v[j] == 0);
36 for (std::size_t k = 0; k < N; ++j, ++k)
37 assert(v[j] == a[k]);
38 for (; j < v.size(); ++j)
39 assert(v[j] == 0);
42 std::vector<bool> v(100);
43 bool a[] = {1, 0, 0, 1, 1};
44 const unsigned N = sizeof(a)/sizeof(a[0]);
45 std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const bool*>(a),
46 forward_iterator<const bool*>(a+N));
47 assert(v.size() == 100 + N);
48 assert(i == v.begin() + 10);
49 int j;
50 for (j = 0; j < 10; ++j)
51 assert(v[j] == 0);
52 for (std::size_t k = 0; k < N; ++j, ++k)
53 assert(v[j] == a[k]);
54 for (; j < 105; ++j)
55 assert(v[j] == 0);
58 std::vector<bool> v(100);
59 while(v.size() < v.capacity()) v.push_back(false);
60 size_t sz = v.size();
61 bool a[] = {1, 0, 0, 1, 1};
62 const unsigned N = sizeof(a)/sizeof(a[0]);
63 std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const bool*>(a),
64 forward_iterator<const bool*>(a+N));
65 assert(v.size() == sz + N);
66 assert(i == v.begin() + 10);
67 std::size_t j;
68 for (j = 0; j < 10; ++j)
69 assert(v[j] == 0);
70 for (std::size_t k = 0; k < N; ++j, ++k)
71 assert(v[j] == a[k]);
72 for (; j < v.size(); ++j)
73 assert(v[j] == 0);
76 std::vector<bool> v(100);
77 while(v.size() < v.capacity()) v.push_back(false);
78 v.pop_back(); v.pop_back(); v.pop_back();
79 size_t sz = v.size();
80 bool a[] = {1, 0, 0, 1, 1};
81 const unsigned N = sizeof(a)/sizeof(a[0]);
82 std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const bool*>(a),
83 forward_iterator<const bool*>(a+N));
84 assert(v.size() == sz + N);
85 assert(i == v.begin() + 10);
86 std::size_t j;
87 for (j = 0; j < 10; ++j)
88 assert(v[j] == 0);
89 for (std::size_t k = 0; k < N; ++j, ++k)
90 assert(v[j] == a[k]);
91 for (; j < v.size(); ++j)
92 assert(v[j] == 0);
94 #if TEST_STD_VER >= 11
96 std::vector<bool, min_allocator<bool>> v(100);
97 bool a[] = {1, 0, 0, 1, 1};
98 const unsigned N = sizeof(a)/sizeof(a[0]);
99 std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const bool*>(a),
100 input_iterator<const bool*>(a+N));
101 assert(v.size() == 100 + N);
102 assert(i == v.begin() + 10);
103 std::size_t j;
104 for (j = 0; j < 10; ++j)
105 assert(v[j] == 0);
106 for (std::size_t k = 0; k < N; ++j, ++k)
107 assert(v[j] == a[k]);
108 for (; j < v.size(); ++j)
109 assert(v[j] == 0);
112 std::vector<bool, min_allocator<bool>> v(100);
113 bool a[] = {1, 0, 0, 1, 1};
114 const unsigned N = sizeof(a)/sizeof(a[0]);
115 std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const bool*>(a),
116 forward_iterator<const bool*>(a+N));
117 assert(v.size() == 100 + N);
118 assert(i == v.begin() + 10);
119 std::size_t j;
120 for (j = 0; j < 10; ++j)
121 assert(v[j] == 0);
122 for (std::size_t k = 0; k < N; ++j, ++k)
123 assert(v[j] == a[k]);
124 for (; j < v.size(); ++j)
125 assert(v[j] == 0);
127 #endif
129 return 0;