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 main(int,char **)22int main(int, char**) 23 { 24 { 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)); 48 } 49 #if TEST_STD_VER >= 11 50 { 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)); 74 } 75 #endif 76 77 return 0; 78 } 79