[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / libcxx / test / std / containers / sequences / vector.bool / construct_size.pass.cpp
blob2763df7e11d5c7710d6285f3ebc5a16662579be8
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>
10 // vector<bool>
12 // explicit vector(size_type n);
14 #include <vector>
15 #include <cassert>
17 #include "test_macros.h"
18 #include "min_allocator.h"
19 #include "test_allocator.h"
21 template <class C>
22 void
23 test2(typename C::size_type n,
24 typename C::allocator_type const& a = typename C::allocator_type ())
26 #if TEST_STD_VER >= 14
27 C c(n, a);
28 LIBCPP_ASSERT(c.__invariants());
29 assert(c.size() == n);
30 assert(c.get_allocator() == a);
31 for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
32 assert(*i == typename C::value_type());
33 #else
34 ((void)n);
35 ((void)a);
36 #endif
39 template <class C>
40 void
41 test1(typename C::size_type n)
43 C c(n);
44 LIBCPP_ASSERT(c.__invariants());
45 assert(c.size() == n);
46 assert(c.get_allocator() == typename C::allocator_type());
47 for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
48 assert(*i == typename C::value_type());
51 template <class C>
52 void
53 test(typename C::size_type n)
55 test1<C> ( n );
56 test2<C> ( n );
59 int main(int, char**)
61 test<std::vector<bool> >(50);
62 #if TEST_STD_VER >= 11
63 test<std::vector<bool, min_allocator<bool>> >(50);
64 test2<std::vector<bool, test_allocator<bool>> >( 100, test_allocator<bool>(23));
65 #endif
67 return 0;