Debian Codegraph @

3rdparty/catch2/tests/ExtraTests/X03-DisabledExceptions-DefaultHandler.cpp

raw symbols SCIP
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 #include <catch2/benchmark/catch_benchmark.hpp>
11 #include <catch2/matchers/catch_matchers.hpp>
12 #include <catch2/matchers/catch_matchers_predicate.hpp>
13
14 TEST_CASE("Tests that run") {
15 // All of these should be run and be reported
16 CHECK(1 == 2);
17 CHECK(1 == 1);
18 CHECK(1 != 3);
19 CHECK(1 == 4);
20 }
21
22
23
24 TEST_CASE("Tests that abort") {
25 // Avoid abort and other exceptional exits -- there is no way
26 // to tell CMake that abort is the desired outcome of a test.
27 std::set_terminate([](){exit(1);});
28 REQUIRE(1 == 1);
29 REQUIRE(1 != 2);
30 REQUIRE(1 == 3);
31 // We should not get here, because the test above aborts
32 REQUIRE(1 != 4);
33 }
34
35 TEST_CASE( "Misc. macros to check that they compile without exceptions" ) {
36 BENCHMARK( "simple benchmark" ) { return 1 * 2 + 3; };
37 REQUIRE_THAT( 1,
38 Catch::Matchers::Predicate<int>( []( int i ) { return i == 1; } ) );
39 }