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

source code of libcxx/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp