• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // This test ensures that assertions trigger without the user having to do anything when the extensive hardening mode
10 // has been enabled by default.
11 
12 // REQUIRES: libcpp-hardening-mode=extensive
13 // `check_assertion.h` is only available starting from C++11.
14 // UNSUPPORTED: c++03
15 // `check_assertion.h` requires Unix headers.
16 // REQUIRES: has-unix-headers
17 // XFAIL: availability-verbose_abort-missing
18 
19 #include <cassert>
20 #include "check_assertion.h"
21 
main(int,char **)22 int main(int, char**) {
23   _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(true, "Should not fire");
24   TEST_LIBCPP_ASSERT_FAILURE([] { _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "Should fire"); }(), "Should fire");
25 
26   return 0;
27 }
28