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 "asan_testing.h"
14#include <deque>
15#include <cassert>
16#include <cstddef>
17
18#include "test_macros.h"
19#include "test_allocator.h"
20#include "min_allocator.h"
21
22template <class T, class Allocator>
23void
24test(unsigned n, const T& x)
25{
26 typedef std::deque<T, Allocator> C;
27 typedef typename C::const_iterator const_iterator;
28 C d(n, x);
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 test<int, std::allocator<int> >(n: 0, x: 5);
39 test<int, std::allocator<int> >(n: 1, x: 10);
40 test<int, std::allocator<int> >(n: 10, x: 11);
41 test<int, std::allocator<int> >(n: 1023, x: -11);
42 test<int, std::allocator<int> >(n: 1024, x: 25);
43 test<int, std::allocator<int> >(n: 1025, x: 0);
44 test<int, std::allocator<int> >(n: 2047, x: 110);
45 test<int, std::allocator<int> >(n: 2048, x: -500);
46 test<int, std::allocator<int> >(n: 2049, x: 654);
47 test<int, std::allocator<int> >(n: 4095, x: 78);
48 test<int, std::allocator<int> >(n: 4096, x: 1165);
49 test<int, std::allocator<int> >(n: 4097, x: 157);
50 LIBCPP_ONLY(test<int, limited_allocator<int, 4096> >(4095, 90));
51#if TEST_STD_VER >= 11
52 test<int, min_allocator<int> >(4095, 90);
53#endif
54
55 return 0;
56}
57

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