brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 3c8ed17 Raw
61 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// void clear() noexcept;12 13#include <vector>14#include <cassert>15 16#include "test_macros.h"17#include "min_allocator.h"18#include "asan_testing.h"19 20TEST_CONSTEXPR_CXX20 bool tests() {21  {22    int a[] = {1, 2, 3};23    std::vector<int> c(a, a + 3);24    ASSERT_NOEXCEPT(c.clear());25    c.clear();26    assert(c.empty());27    LIBCPP_ASSERT(c.__invariants());28    LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));29  }30#if TEST_STD_VER >= 1131  {32    int a[] = {1, 2, 3};33    std::vector<int, min_allocator<int>> c(a, a + 3);34    ASSERT_NOEXCEPT(c.clear());35    c.clear();36    assert(c.empty());37    LIBCPP_ASSERT(c.__invariants());38    LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));39  }40  {41    int a[] = {1, 2, 3};42    std::vector<int, safe_allocator<int>> c(a, a + 3);43    ASSERT_NOEXCEPT(c.clear());44    c.clear();45    assert(c.empty());46    LIBCPP_ASSERT(c.__invariants());47    LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));48  }49#endif50 51  return true;52}53 54int main(int, char**) {55  tests();56#if TEST_STD_VER > 1757  static_assert(tests());58#endif59  return 0;60}61