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); |
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, const typename C::value_type& x) |
22 | { |
23 | C c(n, x); |
24 | LIBCPP_ASSERT(c.__invariants()); |
25 | assert(c.size() == n); |
26 | for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i) |
27 | assert(*i == x); |
28 | } |
29 | |
30 | TEST_CONSTEXPR_CXX20 bool tests() |
31 | { |
32 | test<std::vector<bool> >(50, true); |
33 | #if TEST_STD_VER >= 11 |
34 | test<std::vector<bool, min_allocator<bool>> >(50, true); |
35 | #endif |
36 | |
37 | return true; |
38 | } |
39 | |
40 | int main(int, char**) |
41 | { |
42 | tests(); |
43 | #if TEST_STD_VER > 17 |
44 | static_assert(tests()); |
45 | #endif |
46 | return 0; |
47 | } |
48 | |