• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // <deque>
11 
12 // deque(const deque&);
13 
14 #include <deque>
15 #include <cassert>
16 
17 #include "test_macros.h"
18 #include "test_allocator.h"
19 #include "min_allocator.h"
20 
21 template <class C>
22 void
test(const C & x)23 test(const C& x)
24 {
25     C c(x);
26     assert(c == x);
27 }
28 
main()29 int main()
30 {
31     {
32         int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
33         int* an = ab + sizeof(ab)/sizeof(ab[0]);
34         test(std::deque<int>(ab, an));
35     }
36     {
37         std::deque<int, test_allocator<int> > v(3, 2, test_allocator<int>(5));
38         std::deque<int, test_allocator<int> > v2 = v;
39         assert(v2 == v);
40         assert(v2.get_allocator() == v.get_allocator());
41     }
42 #if TEST_STD_VER >= 11
43     {
44         std::deque<int, other_allocator<int> > v(3, 2, other_allocator<int>(5));
45         std::deque<int, other_allocator<int> > v2 = v;
46         assert(v2 == v);
47         assert(v2.get_allocator() == other_allocator<int>(-2));
48     }
49     {
50         int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
51         int* an = ab + sizeof(ab)/sizeof(ab[0]);
52         test(std::deque<int, min_allocator<int>>(ab, an));
53     }
54     {
55         std::deque<int, min_allocator<int> > v(3, 2, min_allocator<int>());
56         std::deque<int, min_allocator<int> > v2 = v;
57         assert(v2 == v);
58         assert(v2.get_allocator() == v.get_allocator());
59     }
60 #endif
61 }
62