[mlir][Vector] Fix `vector.shuffle` folder for poison indices (#124863)
[llvm-project.git] / libcxx / test / std / containers / sequences / vector / vector.cons / move_alloc.pass.cpp
blobfd0b995b54d54e2bcb214a021e179062c63781b2
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 // UNSUPPORTED: c++03 && !stdlib=libc++
11 // <vector>
13 // vector(vector&& c, const allocator_type& a);
15 #include <vector>
16 #include <cassert>
17 #include "test_macros.h"
18 #include "MoveOnly.h"
19 #include "test_allocator.h"
20 #include "min_allocator.h"
21 #include "asan_testing.h"
23 TEST_CONSTEXPR_CXX20 bool tests()
26 std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
27 std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
28 assert(is_contiguous_container_asan_correct(l));
29 assert(is_contiguous_container_asan_correct(lo));
30 for (int i = 1; i <= 3; ++i)
32 l.push_back(i);
33 lo.push_back(i);
35 assert(is_contiguous_container_asan_correct(l));
36 assert(is_contiguous_container_asan_correct(lo));
37 std::vector<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(6));
38 assert(l2 == lo);
39 assert(!l.empty());
40 assert(l2.get_allocator() == test_allocator<MoveOnly>(6));
41 assert(is_contiguous_container_asan_correct(l2));
44 std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
45 std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
46 assert(is_contiguous_container_asan_correct(l));
47 assert(is_contiguous_container_asan_correct(lo));
48 for (int i = 1; i <= 3; ++i)
50 l.push_back(i);
51 lo.push_back(i);
53 assert(is_contiguous_container_asan_correct(l));
54 assert(is_contiguous_container_asan_correct(lo));
55 std::vector<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(5));
56 assert(l2 == lo);
57 assert(l.empty());
58 assert(l2.get_allocator() == test_allocator<MoveOnly>(5));
59 assert(is_contiguous_container_asan_correct(l2));
62 std::vector<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
63 std::vector<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
64 assert(is_contiguous_container_asan_correct(l));
65 assert(is_contiguous_container_asan_correct(lo));
66 for (int i = 1; i <= 3; ++i)
68 l.push_back(i);
69 lo.push_back(i);
71 assert(is_contiguous_container_asan_correct(l));
72 assert(is_contiguous_container_asan_correct(lo));
73 std::vector<MoveOnly, other_allocator<MoveOnly> > l2(std::move(l), other_allocator<MoveOnly>(4));
74 assert(l2 == lo);
75 assert(!l.empty());
76 assert(l2.get_allocator() == other_allocator<MoveOnly>(4));
77 assert(is_contiguous_container_asan_correct(l2));
80 std::vector<MoveOnly, min_allocator<MoveOnly> > l((min_allocator<MoveOnly>()));
81 std::vector<MoveOnly, min_allocator<MoveOnly> > lo((min_allocator<MoveOnly>()));
82 assert(is_contiguous_container_asan_correct(l));
83 assert(is_contiguous_container_asan_correct(lo));
84 for (int i = 1; i <= 3; ++i)
86 l.push_back(i);
87 lo.push_back(i);
89 assert(is_contiguous_container_asan_correct(l));
90 assert(is_contiguous_container_asan_correct(lo));
91 std::vector<MoveOnly, min_allocator<MoveOnly> > l2(std::move(l), min_allocator<MoveOnly>());
92 assert(l2 == lo);
93 assert(l.empty());
94 assert(l2.get_allocator() == min_allocator<MoveOnly>());
95 assert(is_contiguous_container_asan_correct(l2));
98 std::vector<MoveOnly, safe_allocator<MoveOnly> > l((safe_allocator<MoveOnly>()));
99 std::vector<MoveOnly, safe_allocator<MoveOnly> > lo((safe_allocator<MoveOnly>()));
100 assert(is_contiguous_container_asan_correct(l));
101 assert(is_contiguous_container_asan_correct(lo));
102 for (int i = 1; i <= 3; ++i) {
103 l.push_back(i);
104 lo.push_back(i);
106 assert(is_contiguous_container_asan_correct(l));
107 assert(is_contiguous_container_asan_correct(lo));
108 std::vector<MoveOnly, safe_allocator<MoveOnly> > l2(std::move(l), safe_allocator<MoveOnly>());
109 assert(l2 == lo);
110 assert(l.empty());
111 assert(l2.get_allocator() == safe_allocator<MoveOnly>());
112 assert(is_contiguous_container_asan_correct(l2));
115 return true;
118 int main(int, char**)
120 tests();
121 #if TEST_STD_VER > 17
122 static_assert(tests());
123 #endif
124 return 0;