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 | // class deque |
12 | |
13 | // size_type size() const noexcept; |
14 | |
15 | #include "asan_testing.h" |
16 | #include <deque> |
17 | #include <cassert> |
18 | |
19 | #include "test_macros.h" |
20 | #include "min_allocator.h" |
21 | |
22 | int main(int, char**) { |
23 | { |
24 | typedef std::deque<int> C; |
25 | C c; |
26 | ASSERT_NOEXCEPT(c.size()); |
27 | assert(c.size() == 0); |
28 | LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c)); |
29 | c.push_back(x: C::value_type(2)); |
30 | assert(c.size() == 1); |
31 | LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c)); |
32 | c.push_back(x: C::value_type(1)); |
33 | assert(c.size() == 2); |
34 | LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c)); |
35 | c.push_back(x: C::value_type(3)); |
36 | assert(c.size() == 3); |
37 | LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c)); |
38 | c.erase(position: c.begin()); |
39 | assert(c.size() == 2); |
40 | LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c)); |
41 | c.erase(position: c.begin()); |
42 | assert(c.size() == 1); |
43 | LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c)); |
44 | c.erase(position: c.begin()); |
45 | assert(c.size() == 0); |
46 | LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c)); |
47 | } |
48 | #if TEST_STD_VER >= 11 |
49 | { |
50 | typedef std::deque<int, min_allocator<int>> C; |
51 | C c; |
52 | ASSERT_NOEXCEPT(c.size()); |
53 | assert(c.size() == 0); |
54 | LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c)); |
55 | c.push_back(C::value_type(2)); |
56 | assert(c.size() == 1); |
57 | LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c)); |
58 | c.push_back(C::value_type(1)); |
59 | assert(c.size() == 2); |
60 | LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c)); |
61 | c.push_back(C::value_type(3)); |
62 | assert(c.size() == 3); |
63 | LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c)); |
64 | c.erase(c.begin()); |
65 | assert(c.size() == 2); |
66 | LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c)); |
67 | c.erase(c.begin()); |
68 | assert(c.size() == 1); |
69 | LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c)); |
70 | c.erase(c.begin()); |
71 | assert(c.size() == 0); |
72 | LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c)); |
73 | } |
74 | #endif |
75 | |
76 | return 0; |
77 | } |
78 | |