1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03 && !stdlib=libc++
13 // vector& operator=(vector&& c);
17 #include "test_macros.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
)
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));
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
)
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));
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
)
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));
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
)
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
>()));
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
) {
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
>()));
113 assert(l2
.get_allocator() == lo
.get_allocator());
114 assert(is_contiguous_container_asan_correct(l2
));
120 int main(int, char**)
123 #if TEST_STD_VER > 17
124 static_assert(tests());