[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / libcxx / test / std / containers / sequences / vector.bool / copy.pass.cpp
blob618a37faf70afda7fa5f1c7e1169d3cdaa0e5dbf
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 // vector(const vector& v);
14 #include <vector>
15 #include <cassert>
17 #include "test_macros.h"
18 #include "test_allocator.h"
19 #include "min_allocator.h"
21 template <class C>
22 void
23 test(const C& x)
25 typename C::size_type s = x.size();
26 C c(x);
27 LIBCPP_ASSERT(c.__invariants());
28 assert(c.size() == s);
29 assert(c == x);
32 int main(int, char**)
35 bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
36 bool* an = a + sizeof(a)/sizeof(a[0]);
37 test(std::vector<bool>(a, an));
40 std::vector<bool, test_allocator<bool> > v(3, true, test_allocator<bool>(5));
41 std::vector<bool, test_allocator<bool> > v2 = v;
42 assert(v2 == v);
43 assert(v2.get_allocator() == v.get_allocator());
45 #if TEST_STD_VER >= 11
47 std::vector<bool, other_allocator<bool> > v(3, true, other_allocator<bool>(5));
48 std::vector<bool, other_allocator<bool> > v2 = v;
49 assert(v2 == v);
50 assert(v2.get_allocator() == other_allocator<bool>(-2));
53 bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
54 bool* an = a + sizeof(a)/sizeof(a[0]);
55 test(std::vector<bool, min_allocator<bool>>(a, an));
58 std::vector<bool, min_allocator<bool> > v(3, true, min_allocator<bool>());
59 std::vector<bool, min_allocator<bool> > v2 = v;
60 assert(v2 == v);
61 assert(v2.get_allocator() == v.get_allocator());
63 #endif
65 return 0;