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, const allocator_type& a);
12
13#include "asan_testing.h"
14#include <deque>
15#include <cassert>
16#include <cstddef>
17
18#include "test_macros.h"
19#include "min_allocator.h"
20
21template <class T, class Allocator>
22void
23test(unsigned n, const T& x, const Allocator& a)
24{
25 typedef std::deque<T, Allocator> C;
26 typedef typename C::const_iterator const_iterator;
27 C d(n, x, a);
28 assert(d.get_allocator() == a);
29 assert(d.size() == n);
30 assert(static_cast<std::size_t>(std::distance(d.begin(), d.end())) == d.size());
31 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(d));
32 for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
33 assert(*i == x);
34}
35
36int main(int, char**)
37{
38 {
39 std::allocator<int> a;
40 test(n: 0, x: 5, a);
41 test(n: 1, x: 10, a);
42 test(n: 10, x: 11, a);
43 test(n: 1023, x: -11, a);
44 test(n: 1024, x: 25, a);
45 test(n: 1025, x: 0, a);
46 test(n: 2047, x: 110, a);
47 test(n: 2048, x: -500, a);
48 test(n: 2049, x: 654, a);
49 test(n: 4095, x: 78, a);
50 test(n: 4096, x: 1165, a);
51 test(n: 4097, x: 157, a);
52 }
53#if TEST_STD_VER >= 11
54 {
55 min_allocator<int> a;
56 test(0, 5, a);
57 test(1, 10, a);
58 test(10, 11, a);
59 test(1023, -11, a);
60 test(1024, 25, a);
61 test(1025, 0, a);
62 test(2047, 110, a);
63 test(2048, -500, a);
64 test(2049, 654, a);
65 test(4095, 78, a);
66 test(4096, 1165, a);
67 test(4097, 157, a);
68 }
69#endif
70
71 return 0;
72}
73

source code of libcxx/test/std/containers/sequences/deque/deque.cons/size_value_alloc.pass.cpp