1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 // explicit deque(size_type n);
17 #include "test_macros.h"
18 #include "test_allocator.h"
19 #include "DefaultOnly.h"
20 #include "min_allocator.h"
22 template <class T
, class Allocator
>
27 typedef std::deque
<T
, Allocator
> C
;
28 typedef typename
C::const_iterator const_iterator
;
29 assert(DefaultOnly::count
== 0);
32 assert(static_cast<unsigned>(DefaultOnly::count
) == n
);
33 assert(d
.size() == n
);
34 assert(static_cast<std::size_t>(distance(d
.begin(), d
.end())) == d
.size());
35 for (const_iterator i
= d
.begin(), e
= d
.end(); i
!= e
; ++i
)
38 assert(DefaultOnly::count
== 0);
44 template <class T
, class Allocator
>
48 typedef std::deque
<T
, Allocator
> C
;
49 typedef typename
C::const_iterator const_iterator
;
50 assert(DefaultOnly::count
== 0);
53 assert(static_cast<unsigned>(DefaultOnly::count
) == n
);
54 assert(d
.size() == n
);
55 assert(static_cast<std::size_t>(distance(d
.begin(), d
.end())) == d
.size());
56 #if TEST_STD_VER >= 11
57 for (const_iterator i
= d
.begin(), e
= d
.end(); i
!= e
; ++i
)
61 assert(DefaultOnly::count
== 0);
64 template <class T
, class Allocator
>
66 test3(unsigned n
, Allocator
const &alloc
= Allocator())
69 typedef std::deque
<T
, Allocator
> C
;
72 assert(d
.size() == n
);
73 assert(d
.get_allocator() == alloc
);
81 template <class T
, class Allocator
>
85 test1
<T
, Allocator
> ( n
);
86 test2
<T
, Allocator
> ( n
);
91 test
<DefaultOnly
, std::allocator
<DefaultOnly
> >(0);
92 test
<DefaultOnly
, std::allocator
<DefaultOnly
> >(1);
93 test
<DefaultOnly
, std::allocator
<DefaultOnly
> >(10);
94 test
<DefaultOnly
, std::allocator
<DefaultOnly
> >(1023);
95 test
<DefaultOnly
, std::allocator
<DefaultOnly
> >(1024);
96 test
<DefaultOnly
, std::allocator
<DefaultOnly
> >(1025);
97 test
<DefaultOnly
, std::allocator
<DefaultOnly
> >(2047);
98 test
<DefaultOnly
, std::allocator
<DefaultOnly
> >(2048);
99 test
<DefaultOnly
, std::allocator
<DefaultOnly
> >(2049);
100 test
<DefaultOnly
, std::allocator
<DefaultOnly
> >(4095);
101 test
<DefaultOnly
, std::allocator
<DefaultOnly
> >(4096);
102 test
<DefaultOnly
, std::allocator
<DefaultOnly
> >(4097);
104 LIBCPP_ONLY(test1
<DefaultOnly
, limited_allocator
<DefaultOnly
, 4096> >(4095));
106 #if TEST_STD_VER >= 11
107 test
<DefaultOnly
, min_allocator
<DefaultOnly
> >(4095);
110 #if TEST_STD_VER > 11
111 test3
<DefaultOnly
, std::allocator
<DefaultOnly
>> (1023);
112 test3
<int, std::allocator
<int>>(1);
113 test3
<int, min_allocator
<int>> (3);