1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // <vector>
11 // vector<bool>
12
13 // vector(const vector& v);
14
15 #include <vector>
16 #include <cassert>
17
18 #include "test_macros.h"
19 #include "test_allocator.h"
20 #include "min_allocator.h"
21
22 template <class C>
23 void
test(const C & x)24 test(const C& x)
25 {
26 typename C::size_type s = x.size();
27 C c(x);
28 LIBCPP_ASSERT(c.__invariants());
29 assert(c.size() == s);
30 assert(c == x);
31 }
32
main()33 int main()
34 {
35 {
36 bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
37 bool* an = a + sizeof(a)/sizeof(a[0]);
38 test(std::vector<bool>(a, an));
39 }
40 {
41 std::vector<bool, test_allocator<bool> > v(3, true, test_allocator<bool>(5));
42 std::vector<bool, test_allocator<bool> > v2 = v;
43 assert(v2 == v);
44 assert(v2.get_allocator() == v.get_allocator());
45 }
46 #if TEST_STD_VER >= 11
47 {
48 std::vector<bool, other_allocator<bool> > v(3, true, other_allocator<bool>(5));
49 std::vector<bool, other_allocator<bool> > v2 = v;
50 assert(v2 == v);
51 assert(v2.get_allocator() == other_allocator<bool>(-2));
52 }
53 {
54 bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
55 bool* an = a + sizeof(a)/sizeof(a[0]);
56 test(std::vector<bool, min_allocator<bool>>(a, an));
57 }
58 {
59 std::vector<bool, min_allocator<bool> > v(3, true, min_allocator<bool>());
60 std::vector<bool, min_allocator<bool> > v2 = v;
61 assert(v2 == v);
62 assert(v2.get_allocator() == v.get_allocator());
63 }
64 #endif
65 }
66