71 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 11// class vector12 13// size_type size() const noexcept;14 15#include <vector>16#include <cassert>17 18#include "test_macros.h"19#include "min_allocator.h"20 21TEST_CONSTEXPR_CXX20 bool tests() {22 {23 typedef std::vector<bool> C;24 C c;25 ASSERT_NOEXCEPT(c.size());26 assert(c.size() == 0);27 c.push_back(false);28 assert(c.size() == 1);29 c.push_back(true);30 assert(c.size() == 2);31 c.push_back(false);32 assert(c.size() == 3);33 c.erase(c.begin());34 assert(c.size() == 2);35 c.erase(c.begin());36 assert(c.size() == 1);37 c.erase(c.begin());38 assert(c.size() == 0);39 }40#if TEST_STD_VER >= 1141 {42 typedef std::vector<bool, min_allocator<bool>> C;43 C c;44 ASSERT_NOEXCEPT(c.size());45 assert(c.size() == 0);46 c.push_back(false);47 assert(c.size() == 1);48 c.push_back(true);49 assert(c.size() == 2);50 c.push_back(false);51 assert(c.size() == 3);52 c.erase(c.begin());53 assert(c.size() == 2);54 c.erase(c.begin());55 assert(c.size() == 1);56 c.erase(c.begin());57 assert(c.size() == 0);58 }59#endif60 61 return true;62}63 64int main(int, char**) {65 tests();66#if TEST_STD_VER > 1767 static_assert(tests());68#endif69 return 0;70}71