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