brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · ca89215 Raw
57 lines · cpp
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-exception6//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 21TEST_CONSTEXPR_CXX20 bool tests() {22  {23    bool a[]         = {0, 1, 1, 0, 1, 0, 0};24    const unsigned N = sizeof(a) / sizeof(a[0]);25    std::vector<bool> c;26    for (unsigned i = 0; i < N; ++i) {27      c.push_back(a[i]);28      assert(c.size() == i + 1);29      for (std::size_t j = 0; j < c.size(); ++j)30        assert(c[j] == a[j]);31    }32  }33#if TEST_STD_VER >= 1134  {35    bool a[]         = {0, 1, 1, 0, 1, 0, 0};36    const unsigned N = sizeof(a) / sizeof(a[0]);37    std::vector<bool, min_allocator<bool>> c;38    for (unsigned i = 0; i < N; ++i) {39      c.push_back(a[i]);40      assert(c.size() == i + 1);41      for (std::size_t j = 0; j < c.size(); ++j)42        assert(c[j] == a[j]);43    }44  }45#endif46 47  return true;48}49 50int main(int, char**) {51  tests();52#if TEST_STD_VER > 1753  static_assert(tests());54#endif55  return 0;56}57