1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 // vector(const vector& v, const allocator_type& a);
17 #include "test_macros.h"
18 #include "test_allocator.h"
19 #include "min_allocator.h"
20 #include "asan_testing.h"
24 test(const C& x, const typename C::allocator_type& a)
26 typename C::size_type s = x.size();
28 LIBCPP_ASSERT(c.__invariants());
29 assert(c.size() == s);
31 LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
37 int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
38 int* an = a + sizeof(a)/sizeof(a[0]);
39 test(std::vector<int>(a, an), std::allocator<int>());
42 std::vector<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
43 std::vector<int, test_allocator<int> > l2(l, test_allocator<int>(3));
45 assert(l2.get_allocator() == test_allocator<int>(3));
48 std::vector<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
49 std::vector<int, other_allocator<int> > l2(l, other_allocator<int>(3));
51 assert(l2.get_allocator() == other_allocator<int>(3));
53 #if TEST_STD_VER >= 11
55 int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
56 int* an = a + sizeof(a)/sizeof(a[0]);
57 test(std::vector<int, min_allocator<int>>(a, an), min_allocator<int>());
60 std::vector<int, min_allocator<int> > l(3, 2, min_allocator<int>());
61 std::vector<int, min_allocator<int> > l2(l, min_allocator<int>());
63 assert(l2.get_allocator() == min_allocator<int>());