[libc++] Add test_demangle.pass.cpp clang-format to .git-blame-ignore-revs
[llvm-project.git] / libcxx / test / std / containers / sequences / vector / vector.capacity / capacity.pass.cpp
blobb2eb33c6c5f53e4b02542b1c6c88ce4f6fad517b
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 // <vector>
11 // size_type capacity() const;
13 #include <vector>
14 #include <cassert>
16 #include "test_macros.h"
17 #include "min_allocator.h"
18 #include "asan_testing.h"
20 TEST_CONSTEXPR_CXX20 bool tests()
23 std::vector<int> v;
24 assert(v.capacity() == 0);
25 assert(is_contiguous_container_asan_correct(v));
28 std::vector<int> v(100);
29 assert(v.capacity() == 100);
30 v.push_back(0);
31 assert(v.capacity() > 101);
32 assert(is_contiguous_container_asan_correct(v));
34 #if TEST_STD_VER >= 11
36 std::vector<int, min_allocator<int>> v;
37 assert(v.capacity() == 0);
38 assert(is_contiguous_container_asan_correct(v));
41 std::vector<int, min_allocator<int>> v(100);
42 assert(v.capacity() == 100);
43 v.push_back(0);
44 assert(v.capacity() > 101);
45 assert(is_contiguous_container_asan_correct(v));
47 #endif
49 return true;
52 int main(int, char**)
54 tests();
55 #if TEST_STD_VER > 17
56 static_assert(tests());
57 #endif
58 return 0;