Debian Codegraph @

libcxx/test/std/containers/sequences/vector.bool/capacity.pass.cpp

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