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 | // vector(size_type n, const value_type& x, const allocator_type& a); |
13 | |
14 | #include <vector> |
15 | #include <cassert> |
16 | |
17 | #include "test_macros.h" |
18 | #include "min_allocator.h" |
19 | |
20 | template <class C> |
21 | TEST_CONSTEXPR_CXX20 void test(typename C::size_type n, |
22 | const typename C::value_type& x, |
23 | const typename C::allocator_type& a) |
24 | { |
25 | C c(n, x, a); |
26 | LIBCPP_ASSERT(c.__invariants()); |
27 | assert(a == c.get_allocator()); |
28 | assert(c.size() == n); |
29 | for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i) |
30 | assert(*i == x); |
31 | } |
32 | |
33 | TEST_CONSTEXPR_CXX20 bool tests() |
34 | { |
35 | test<std::vector<bool> >(50, true, std::allocator<bool>()); |
36 | #if TEST_STD_VER >= 11 |
37 | test<std::vector<bool, min_allocator<bool>> >(50, true, min_allocator<bool>()); |
38 | #endif |
39 | |
40 | return true; |
41 | } |
42 | |
43 | int main(int, char**) |
44 | { |
45 | tests(); |
46 | #if TEST_STD_VER > 17 |
47 | static_assert(tests()); |
48 | #endif |
49 | return 0; |
50 | } |
51 | |