Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / containers / sequences / deque / deque.capacity / size.pass.cpp
blob21d5ca03a10a20f7d9da46f4e0c129069d772c25
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 //===----------------------------------------------------------------------===//
9 // <deque>
11 // class deque
13 // size_type size() const noexcept;
15 #include "asan_testing.h"
16 #include <deque>
17 #include <cassert>
19 #include "test_macros.h"
20 #include "min_allocator.h"
22 int main(int, char**)
25 typedef std::deque<int> C;
26 C c;
27 ASSERT_NOEXCEPT(c.size());
28 assert(c.size() == 0);
29 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c));
30 c.push_back(C::value_type(2));
31 assert(c.size() == 1);
32 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c));
33 c.push_back(C::value_type(1));
34 assert(c.size() == 2);
35 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c));
36 c.push_back(C::value_type(3));
37 assert(c.size() == 3);
38 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c));
39 c.erase(c.begin());
40 assert(c.size() == 2);
41 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c));
42 c.erase(c.begin());
43 assert(c.size() == 1);
44 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c));
45 c.erase(c.begin());
46 assert(c.size() == 0);
47 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c));
49 #if TEST_STD_VER >= 11
51 typedef std::deque<int, min_allocator<int>> C;
52 C c;
53 ASSERT_NOEXCEPT(c.size());
54 assert(c.size() == 0);
55 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c));
56 c.push_back(C::value_type(2));
57 assert(c.size() == 1);
58 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c));
59 c.push_back(C::value_type(1));
60 assert(c.size() == 2);
61 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c));
62 c.push_back(C::value_type(3));
63 assert(c.size() == 3);
64 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c));
65 c.erase(c.begin());
66 assert(c.size() == 2);
67 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c));
68 c.erase(c.begin());
69 assert(c.size() == 1);
70 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c));
71 c.erase(c.begin());
72 assert(c.size() == 0);
73 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c));
75 #endif
77 return 0;