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 we can override any hardening mode with the debug mode on a per-TU basis.
10
11// `check_assertion.h` is only available starting from C++11 and requires Unix headers and regex support.
12// REQUIRES: has-unix-headers
13// UNSUPPORTED: c++03, no-localization
14// The ability to set a custom abort message is required to compare the assertion message.
15// XFAIL: availability-verbose_abort-missing
16// ADDITIONAL_COMPILE_FLAGS: -U_LIBCPP_HARDENING_MODE -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG
17
18#include <cassert>
19#include "check_assertion.h"
20
21int main(int, char**) {
22 _LIBCPP_ASSERT_INTERNAL(true, "Should not fire");
23 TEST_LIBCPP_ASSERT_FAILURE([] { _LIBCPP_ASSERT_INTERNAL(false, "Debug-mode assertions should fire"); }(),
24 "Debug-mode assertions should fire");
25
26 return 0;
27}
28

source code of libcxx/test/libcxx/assertions/modes/override_with_debug_mode.pass.cpp