[mlir][Vector] Fix `vector.shuffle` folder for poison indices (#124863)
[llvm-project.git] / libcxx / test / std / containers / sequences / vector / vector.cons / assign_move.pass.cpp
blob58081fa0ecef596118271ce56b6267cf8f1bdf91
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& operator=(vector&& c);
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() {
25 std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
26 std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
27 for (int i = 1; i <= 3; ++i)
29 l.push_back(i);
30 lo.push_back(i);
32 assert(is_contiguous_container_asan_correct(l));
33 assert(is_contiguous_container_asan_correct(lo));
34 std::vector<MoveOnly, test_allocator<MoveOnly> > l2(test_allocator<MoveOnly>(5));
35 l2 = std::move(l);
36 assert(l2 == lo);
37 assert(l.empty());
38 assert(l2.get_allocator() == lo.get_allocator());
39 assert(is_contiguous_container_asan_correct(l2));
42 std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
43 std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
44 assert(is_contiguous_container_asan_correct(l));
45 assert(is_contiguous_container_asan_correct(lo));
46 for (int i = 1; i <= 3; ++i)
48 l.push_back(i);
49 lo.push_back(i);
51 assert(is_contiguous_container_asan_correct(l));
52 assert(is_contiguous_container_asan_correct(lo));
53 std::vector<MoveOnly, test_allocator<MoveOnly> > l2(test_allocator<MoveOnly>(6));
54 l2 = std::move(l);
55 assert(l2 == lo);
56 assert(!l.empty());
57 assert(l2.get_allocator() == test_allocator<MoveOnly>(6));
58 assert(is_contiguous_container_asan_correct(l2));
61 std::vector<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
62 std::vector<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
63 assert(is_contiguous_container_asan_correct(l));
64 assert(is_contiguous_container_asan_correct(lo));
65 for (int i = 1; i <= 3; ++i)
67 l.push_back(i);
68 lo.push_back(i);
70 assert(is_contiguous_container_asan_correct(l));
71 assert(is_contiguous_container_asan_correct(lo));
72 std::vector<MoveOnly, other_allocator<MoveOnly> > l2(other_allocator<MoveOnly>(6));
73 l2 = std::move(l);
74 assert(l2 == lo);
75 assert(l.empty());
76 assert(l2.get_allocator() == lo.get_allocator());
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((min_allocator<MoveOnly>()));
92 l2 = std::move(l);
93 assert(l2 == lo);
94 assert(l.empty());
95 assert(l2.get_allocator() == lo.get_allocator());
96 assert(is_contiguous_container_asan_correct(l2));
99 std::vector<MoveOnly, safe_allocator<MoveOnly> > l((safe_allocator<MoveOnly>()));
100 std::vector<MoveOnly, safe_allocator<MoveOnly> > lo((safe_allocator<MoveOnly>()));
101 assert(is_contiguous_container_asan_correct(l));
102 assert(is_contiguous_container_asan_correct(lo));
103 for (int i = 1; i <= 3; ++i) {
104 l.push_back(i);
105 lo.push_back(i);
107 assert(is_contiguous_container_asan_correct(l));
108 assert(is_contiguous_container_asan_correct(lo));
109 std::vector<MoveOnly, safe_allocator<MoveOnly> > l2((safe_allocator<MoveOnly>()));
110 l2 = std::move(l);
111 assert(l2 == lo);
112 assert(l.empty());
113 assert(l2.get_allocator() == lo.get_allocator());
114 assert(is_contiguous_container_asan_correct(l2));
117 return true;
120 int main(int, char**)
122 tests();
123 #if TEST_STD_VER > 17
124 static_assert(tests());
125 #endif
126 return 0;