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 push_back(const value_type& x); |
13 | |
14 | #include <vector> |
15 | #include <cassert> |
16 | #include <cstddef> |
17 | |
18 | #include "test_macros.h" |
19 | #include "min_allocator.h" |
20 | |
21 | TEST_CONSTEXPR_CXX20 bool tests() |
22 | { |
23 | { |
24 | bool a[] = {0, 1, 1, 0, 1, 0, 0}; |
25 | const unsigned N = sizeof(a)/sizeof(a[0]); |
26 | std::vector<bool> c; |
27 | for (unsigned i = 0; i < N; ++i) |
28 | { |
29 | c.push_back(x: a[i]); |
30 | assert(c.size() == i+1); |
31 | for (std::size_t j = 0; j < c.size(); ++j) |
32 | assert(c[j] == a[j]); |
33 | } |
34 | } |
35 | #if TEST_STD_VER >= 11 |
36 | { |
37 | bool a[] = {0, 1, 1, 0, 1, 0, 0}; |
38 | const unsigned N = sizeof(a)/sizeof(a[0]); |
39 | std::vector<bool, min_allocator<bool>> c; |
40 | for (unsigned i = 0; i < N; ++i) |
41 | { |
42 | c.push_back(a[i]); |
43 | assert(c.size() == i+1); |
44 | for (std::size_t j = 0; j < c.size(); ++j) |
45 | assert(c[j] == a[j]); |
46 | } |
47 | } |
48 | #endif |
49 | |
50 | return true; |
51 | } |
52 | |
53 | int main(int, char**) |
54 | { |
55 | tests(); |
56 | #if TEST_STD_VER > 17 |
57 | static_assert(tests()); |
58 | #endif |
59 | return 0; |
60 | } |
61 | |