58 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// <vector>10 11// size_type capacity() const;12 13#include <vector>14#include <cassert>15 16#include "test_macros.h"17#include "min_allocator.h"18#include "asan_testing.h"19 20TEST_CONSTEXPR_CXX20 bool tests() {21 {22 std::vector<int> v;23 assert(v.capacity() == 0);24 assert(is_contiguous_container_asan_correct(v));25 }26 {27 std::vector<int> v(100);28 assert(v.capacity() == 100);29 v.push_back(0);30 assert(v.capacity() > 101);31 assert(is_contiguous_container_asan_correct(v));32 }33#if TEST_STD_VER >= 1134 {35 std::vector<int, min_allocator<int>> v;36 assert(v.capacity() == 0);37 assert(is_contiguous_container_asan_correct(v));38 }39 {40 std::vector<int, min_allocator<int>> v(100);41 assert(v.capacity() == 100);42 v.push_back(0);43 assert(v.capacity() > 101);44 assert(is_contiguous_container_asan_correct(v));45 }46#endif47 48 return true;49}50 51int main(int, char**) {52 tests();53#if TEST_STD_VER > 1754 static_assert(tests());55#endif56 return 0;57}58