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 //===----------------------------------------------------------------------===//
8 
9 // <deque>
10 
11 // deque(size_type n, const value_type& v);
12 
13 #include <deque>
14 #include <cassert>
15 #include <cstddef>
16 
17 #include "test_macros.h"
18 #include "test_allocator.h"
19 #include "min_allocator.h"
20 
21 template <class T, class Allocator>
22 void
test(unsigned n,const T & x)23 test(unsigned n, const T& x)
24 {
25     typedef std::deque<T, Allocator> C;
26     typedef typename C::const_iterator const_iterator;
27     C d(n, x);
28     assert(d.size() == n);
29     assert(static_cast<std::size_t>(std::distance(d.begin(), d.end())) == d.size());
30     for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
31         assert(*i == x);
32 }
33 
main(int,char **)34 int main(int, char**)
35 {
36     test<int, std::allocator<int> >(0, 5);
37     test<int, std::allocator<int> >(1, 10);
38     test<int, std::allocator<int> >(10, 11);
39     test<int, std::allocator<int> >(1023, -11);
40     test<int, std::allocator<int> >(1024, 25);
41     test<int, std::allocator<int> >(1025, 0);
42     test<int, std::allocator<int> >(2047, 110);
43     test<int, std::allocator<int> >(2048, -500);
44     test<int, std::allocator<int> >(2049, 654);
45     test<int, std::allocator<int> >(4095, 78);
46     test<int, std::allocator<int> >(4096, 1165);
47     test<int, std::allocator<int> >(4097, 157);
48     LIBCPP_ONLY(test<int, limited_allocator<int, 4096> >(4095, 90));
49 #if TEST_STD_VER >= 11
50     test<int, min_allocator<int> >(4095, 90);
51 #endif
52 
53   return 0;
54 }
55