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 | // size_type max_size() const; |
12 | |
13 | #include "asan_testing.h" |
14 | #include <cassert> |
15 | #include <deque> |
16 | #include <limits> |
17 | #include <type_traits> |
18 | |
19 | #include "test_allocator.h" |
20 | #include "test_macros.h" |
21 | |
22 | int main(int, char**) { |
23 | { |
24 | typedef limited_allocator<int, 10> A; |
25 | typedef std::deque<int, A> C; |
26 | C c; |
27 | assert(c.max_size() <= 10); |
28 | LIBCPP_ASSERT(c.max_size() == 10); |
29 | LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c)); |
30 | } |
31 | { |
32 | typedef limited_allocator<int, (std::size_t)-1> A; |
33 | typedef std::deque<int, A> C; |
34 | const C::size_type max_dist = |
35 | static_cast<C::size_type>(std::numeric_limits<C::difference_type>::max()); |
36 | C c; |
37 | assert(c.max_size() <= max_dist); |
38 | LIBCPP_ASSERT(c.max_size() == max_dist); |
39 | LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c)); |
40 | } |
41 | { |
42 | typedef std::deque<char> C; |
43 | const C::size_type max_dist = |
44 | static_cast<C::size_type>(std::numeric_limits<C::difference_type>::max()); |
45 | C c; |
46 | assert(c.max_size() <= max_dist); |
47 | assert(c.max_size() <= alloc_max_size(c.get_allocator())); |
48 | LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c)); |
49 | } |
50 | |
51 | return 0; |
52 | } |
53 | |