[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / libcxx / test / std / containers / sequences / deque / deque.cons / move.pass.cpp
blob84e278697e4e93a525e42e8f404421a4ff21614b
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
11 // <deque>
13 // deque(deque&&);
15 #include <deque>
16 #include <cassert>
18 #include "test_macros.h"
19 #include "MoveOnly.h"
20 #include "test_allocator.h"
21 #include "min_allocator.h"
23 int main(int, char**)
26 int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
27 int* an = ab + sizeof(ab)/sizeof(ab[0]);
28 typedef test_allocator<MoveOnly> A;
29 std::deque<MoveOnly, A> c1(A(1));
30 for (int* p = ab; p < an; ++p)
31 c1.push_back(MoveOnly(*p));
32 std::deque<MoveOnly, A> c2(A(2));
33 for (int* p = ab; p < an; ++p)
34 c2.push_back(MoveOnly(*p));
35 A old_a = c1.get_allocator();
36 std::deque<MoveOnly, A> c3 = std::move(c1);
37 assert(c2 == c3);
38 assert(c1.size() == 0);
39 assert(c3.get_allocator() == old_a);
40 assert(c1.get_allocator() == A(test_alloc_base::moved_value));
43 int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
44 int* an = ab + sizeof(ab)/sizeof(ab[0]);
45 typedef other_allocator<MoveOnly> A;
46 std::deque<MoveOnly, A> c1(A(1));
47 for (int* p = ab; p < an; ++p)
48 c1.push_back(MoveOnly(*p));
49 std::deque<MoveOnly, A> c2(A(2));
50 for (int* p = ab; p < an; ++p)
51 c2.push_back(MoveOnly(*p));
52 std::deque<MoveOnly, A> c3 = std::move(c1);
53 assert(c2 == c3);
54 assert(c1.size() == 0);
55 assert(c3.get_allocator() == c1.get_allocator());
58 int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
59 int* an = ab + sizeof(ab)/sizeof(ab[0]);
60 typedef min_allocator<MoveOnly> A;
61 std::deque<MoveOnly, A> c1(A{});
62 for (int* p = ab; p < an; ++p)
63 c1.push_back(MoveOnly(*p));
64 std::deque<MoveOnly, A> c2(A{});
65 for (int* p = ab; p < an; ++p)
66 c2.push_back(MoveOnly(*p));
67 std::deque<MoveOnly, A> c3 = std::move(c1);
68 assert(c2 == c3);
69 assert(c1.size() == 0);
70 assert(c3.get_allocator() == c1.get_allocator());
73 return 0;