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 // explicit deque(size_type n);
18 #include "test_macros.h"
19 #include "test_allocator.h"
20 #include "DefaultOnly.h"
21 #include "min_allocator.h"
23 template <class T, class Allocator>
28 typedef std::deque<T, Allocator> C;
29 typedef typename C::const_iterator const_iterator;
30 assert(DefaultOnly::count == 0);
33 assert(static_cast<unsigned>(DefaultOnly::count) == n);
34 assert(d.size() == n);
35 assert(static_cast<std::size_t>(distance(d.begin(), d.end())) == d.size());
36 for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
39 assert(DefaultOnly::count == 0);
45 template <class T, class Allocator>
49 typedef std::deque<T, Allocator> C;
50 typedef typename C::const_iterator const_iterator;
51 assert(DefaultOnly::count == 0);
54 assert(static_cast<unsigned>(DefaultOnly::count) == n);
55 assert(d.size() == n);
56 assert(static_cast<std::size_t>(distance(d.begin(), d.end())) == d.size());
57 #if TEST_STD_VER >= 11
58 for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
62 assert(DefaultOnly::count == 0);
65 template <class T, class Allocator>
67 test3(unsigned n, Allocator const &alloc = Allocator())
70 typedef std::deque<T, Allocator> C;
73 assert(d.size() == n);
74 assert(d.get_allocator() == alloc);
82 template <class T, class Allocator>
86 test1<T, Allocator> ( n );
87 test2<T, Allocator> ( n );
92 test<DefaultOnly, std::allocator<DefaultOnly> >(0);
93 test<DefaultOnly, std::allocator<DefaultOnly> >(1);
94 test<DefaultOnly, std::allocator<DefaultOnly> >(10);
95 test<DefaultOnly, std::allocator<DefaultOnly> >(1023);
96 test<DefaultOnly, std::allocator<DefaultOnly> >(1024);
97 test<DefaultOnly, std::allocator<DefaultOnly> >(1025);
98 test<DefaultOnly, std::allocator<DefaultOnly> >(2047);
99 test<DefaultOnly, std::allocator<DefaultOnly> >(2048);
100 test<DefaultOnly, std::allocator<DefaultOnly> >(2049);
101 test<DefaultOnly, std::allocator<DefaultOnly> >(4095);
102 test<DefaultOnly, std::allocator<DefaultOnly> >(4096);
103 test<DefaultOnly, std::allocator<DefaultOnly> >(4097);
105 LIBCPP_ONLY(test1<DefaultOnly, limited_allocator<DefaultOnly, 4096> >(4095));
107 #if TEST_STD_VER >= 11
108 test<DefaultOnly, min_allocator<DefaultOnly> >(4095);
111 #if TEST_STD_VER > 11
112 test3<DefaultOnly, std::allocator<DefaultOnly>> (1023);
113 test3<int, std::allocator<int>>(1);
114 test3<int, min_allocator<int>> (3);