1 // { dg-do compile { target c++20 } }
4 #include <testsuite_hooks.h>
7 capacity_for(std::size_t n
)
9 std::size_t N
= std::vector
<bool>(1).capacity();
26 static_assert( test_empty() );
32 VERIFY( v
.size() == 0 );
34 VERIFY( v
.size() == 1 );
36 VERIFY( v
.max_size() != 0 );
41 static_assert( test_size() );
47 VERIFY( v
.size() == 0 );
48 VERIFY( v
.capacity() == v
.size() );
49 v
= {false, false, false};
50 VERIFY( v
.size() == 3 );
51 VERIFY( v
.capacity() >= v
.size() );
56 static_assert( test_capacity() );
63 VERIFY( v
.size() == 0 );
64 VERIFY( v
.capacity() == capacity_for(9) );
66 VERIFY( v
.size() == 5 );
67 VERIFY( v
.capacity() == capacity_for(9) );
69 VERIFY( v
.size() == 900 );
70 VERIFY( v
.capacity() == capacity_for(900) );
71 VERIFY( v
[10] == true );
76 static_assert( test_resize() );
83 VERIFY( v
.size() == 0 );
84 VERIFY( v
.capacity() == capacity_for(9) );
86 VERIFY( v
.size() == 2 );
87 VERIFY( v
.capacity() == capacity_for(9) );
90 VERIFY( v
.size() == 100 );
91 VERIFY( v
.capacity() == capacity_for(300) );
96 static_assert( test_reserve() );
104 VERIFY( v
.capacity() == 0 );
108 VERIFY( v
.capacity() == capacity_for(v
.size()) );
113 static_assert( test_shrink_to_fit() );