| 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 |
| 24 |
test(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 |
|
| 36 |
int main(int, char**) |
| 37 |
{ |
| 38 |
test<int, std::allocator<int> >(0, 5); |
| 39 |
test<int, std::allocator<int> >(1, 10); |
| 40 |
test<int, std::allocator<int> >(10, 11); |
| 41 |
test<int, std::allocator<int> >(1023, -11); |
| 42 |
test<int, std::allocator<int> >(1024, 25); |
| 43 |
test<int, std::allocator<int> >(1025, 0); |
| 44 |
test<int, std::allocator<int> >(2047, 110); |
| 45 |
test<int, std::allocator<int> >(2048, -500); |
| 46 |
test<int, std::allocator<int> >(2049, 654); |
| 47 |
test<int, std::allocator<int> >(4095, 78); |
| 48 |
test<int, std::allocator<int> >(4096, 1165); |
| 49 |
test<int, std::allocator<int> >(4097, 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 |
} |