[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / containers / sequences / vector.bool / insert_iter_value.pass.cpp
blobbb59de3b185a9be6aed8df07ad0c9410871656d4
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 // iterator insert(const_iterator position, const value_type& x);
14 #include <vector>
15 #include <cassert>
16 #include <cstddef>
18 #include "test_macros.h"
19 #include "min_allocator.h"
21 TEST_CONSTEXPR_CXX20 bool tests()
24 std::vector<bool> v(100);
25 std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 1);
26 assert(v.size() == 101);
27 assert(i == v.begin() + 10);
28 std::size_t j;
29 for (j = 0; j < 10; ++j)
30 assert(v[j] == 0);
31 assert(v[j] == 1);
32 for (++j; j < v.size(); ++j)
33 assert(v[j] == 0);
36 std::vector<bool> v(100);
37 while(v.size() < v.capacity()) v.push_back(false);
38 std::size_t sz = v.size();
39 std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 1);
40 assert(v.size() == sz + 1);
41 assert(i == v.begin() + 10);
42 std::size_t j;
43 for (j = 0; j < 10; ++j)
44 assert(v[j] == 0);
45 assert(v[j] == 1);
46 for (++j; j < v.size(); ++j)
47 assert(v[j] == 0);
50 std::vector<bool> v(100);
51 while(v.size() < v.capacity()) v.push_back(false);
52 v.pop_back(); v.pop_back();
53 std::size_t sz = v.size();
54 std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 1);
55 assert(v.size() == sz + 1);
56 assert(i == v.begin() + 10);
57 std::size_t j;
58 for (j = 0; j < 10; ++j)
59 assert(v[j] == 0);
60 assert(v[j] == 1);
61 for (++j; j < v.size(); ++j)
62 assert(v[j] == 0);
64 #if TEST_STD_VER >= 11
66 std::vector<bool, explicit_allocator<bool>> v(10);
67 std::vector<bool, explicit_allocator<bool>>::iterator i
68 = v.insert(v.cbegin() + 10, 1);
69 assert(v.size() == 11);
70 assert(i == v.begin() + 10);
71 assert(*i == 1);
74 std::vector<bool, min_allocator<bool>> v(100);
75 std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, 1);
76 assert(v.size() == 101);
77 assert(i == v.begin() + 10);
78 std::size_t j;
79 for (j = 0; j < 10; ++j)
80 assert(v[j] == 0);
81 assert(v[j] == 1);
82 for (++j; j < v.size(); ++j)
83 assert(v[j] == 0);
85 #endif
87 return true;
90 int main(int, char**)
92 tests();
93 #if TEST_STD_VER > 17
94 static_assert(tests());
95 #endif
96 return 0;