brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · 46946bf Raw
54 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// size_type capacity() const;13 14#include <vector>15#include <cassert>16 17#include "test_macros.h"18#include "min_allocator.h"19 20TEST_CONSTEXPR_CXX20 bool tests() {21  {22    std::vector<bool> v;23    assert(v.capacity() == 0);24  }25  {26    std::vector<bool> v(100);27    assert(v.capacity() >= 100);28    v.push_back(0);29    assert(v.capacity() >= 101);30  }31#if TEST_STD_VER >= 1132  {33    std::vector<bool, min_allocator<bool>> v;34    assert(v.capacity() == 0);35  }36  {37    std::vector<bool, min_allocator<bool>> v(100);38    assert(v.capacity() >= 100);39    v.push_back(0);40    assert(v.capacity() >= 101);41  }42#endif43 44  return true;45}46 47int main(int, char**) {48  tests();49#if TEST_STD_VER > 1750  static_assert(tests());51#endif52  return 0;53}54