Debian Codegraph @

src/external/catch2/tests/SelfTest/IntrospectiveTests/AssertionHandler.tests.cpp

raw
1
2 // Copyright Catch2 Authors
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE.txt or copy at
5 // https://www.boost.org/LICENSE_1_0.txt)
6
7 // SPDX-License-Identifier: BSL-1.0
8
9 #include <catch2/catch_test_macros.hpp>
10
11 TEST_CASE( "Incomplete AssertionHandler", "[assertion-handler][!shouldfail]" ) {
12 Catch::AssertionHandler catchAssertionHandler(
13 "REQUIRE"_catch_sr,
14 CATCH_INTERNAL_LINEINFO,
15 "Dummy",
16 Catch::ResultDisposition::Normal );
17 }
18
19
20 static int foo( int i ) {
21 REQUIRE( i > 10 );
22 return 42;
23 }
24
25 TEST_CASE( "Assertions can be nested - CHECK", "[assertions][!shouldfail]" ) {
26 CHECK( foo( 2 ) == 2 );
27 // We should hit this, because CHECK continues on failure
28 CHECK( true );
29 }
30
31 TEST_CASE( "Assertions can be nested - REQUIRE", "[assertions][!shouldfail]" ) {
32 REQUIRE( foo( 2 ) == 2 );
33 // We should not hit this, because REQUIRE does not continue on failure
34 CHECK( true );
35 }
36
37 static void do_fail() { FAIL( "Throw a Catch::TestFailureException" ); }
38
39 TEST_CASE( "FAIL can be nested in assertion", "[assertions][!shouldfail]" ) {
40 // Fails, but the error message makes sense.
41 CHECK_NOTHROW( do_fail() );
42 }