150910bf8SBruce Mitchener //===----------------------------------------------------------------------===//
250910bf8SBruce Mitchener //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
650910bf8SBruce Mitchener //
750910bf8SBruce Mitchener //===----------------------------------------------------------------------===//
850910bf8SBruce Mitchener
950910bf8SBruce Mitchener // <vector>
1050910bf8SBruce Mitchener
11934e9a39SMarshall Clow // void clear() noexcept;
1250910bf8SBruce Mitchener
1350910bf8SBruce Mitchener #include <vector>
1450910bf8SBruce Mitchener #include <cassert>
1550910bf8SBruce Mitchener
16934e9a39SMarshall Clow #include "test_macros.h"
1750910bf8SBruce Mitchener #include "min_allocator.h"
1850910bf8SBruce Mitchener #include "asan_testing.h"
1950910bf8SBruce Mitchener
tests()20*c74059c5SNikolas Klauser TEST_CONSTEXPR_CXX20 bool tests()
2150910bf8SBruce Mitchener {
2250910bf8SBruce Mitchener {
2350910bf8SBruce Mitchener int a[] = {1, 2, 3};
2450910bf8SBruce Mitchener std::vector<int> c(a, a+3);
25934e9a39SMarshall Clow ASSERT_NOEXCEPT(c.clear());
2650910bf8SBruce Mitchener c.clear();
2750910bf8SBruce Mitchener assert(c.empty());
2850910bf8SBruce Mitchener LIBCPP_ASSERT(c.__invariants());
2950910bf8SBruce Mitchener LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
3050910bf8SBruce Mitchener }
3150910bf8SBruce Mitchener #if TEST_STD_VER >= 11
3250910bf8SBruce Mitchener {
3350910bf8SBruce Mitchener int a[] = {1, 2, 3};
3450910bf8SBruce Mitchener std::vector<int, min_allocator<int>> c(a, a+3);
35934e9a39SMarshall Clow ASSERT_NOEXCEPT(c.clear());
3650910bf8SBruce Mitchener c.clear();
3750910bf8SBruce Mitchener assert(c.empty());
3850910bf8SBruce Mitchener LIBCPP_ASSERT(c.__invariants());
3950910bf8SBruce Mitchener LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
4050910bf8SBruce Mitchener }
4150910bf8SBruce Mitchener #endif
422df59c50SJF Bastien
43*c74059c5SNikolas Klauser return true;
44*c74059c5SNikolas Klauser }
45*c74059c5SNikolas Klauser
main(int,char **)46*c74059c5SNikolas Klauser int main(int, char**)
47*c74059c5SNikolas Klauser {
48*c74059c5SNikolas Klauser tests();
49*c74059c5SNikolas Klauser #if TEST_STD_VER > 17
50*c74059c5SNikolas Klauser static_assert(tests());
51*c74059c5SNikolas Klauser #endif
522df59c50SJF Bastien return 0;
5350910bf8SBruce Mitchener }
54