| 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 | #include <iostream> |
| 12 | |
| 13 | namespace Catch { |
| 14 | [[noreturn]] |
| 15 | void throw_exception(std::exception const& e) { |
| 16 | std::cerr << "====== CUSTOM HANDLER ====== run terminates because an exception was thrown.\n" |
| 17 | << "The message was: " << e.what() << '\n'; |
| 18 | // Avoid abort and other exceptional exits -- there is no way |
| 19 | // to tell CMake that abort is the desired outcome of a test. |
| 20 | exit(1); |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | TEST_CASE("Tests that run") { |
| 25 | // All of these should be run and be reported |
| 26 | CHECK(1 == 2); |
| 27 | CHECK(1 == 1); |
| 28 | CHECK(1 != 3); |
| 29 | CHECK(1 == 4); |
| 30 | } |
| 31 | |
| 32 | |
| 33 | |
| 34 | TEST_CASE("Tests that abort") { |
| 35 | REQUIRE(1 == 1); |
| 36 | REQUIRE(1 != 2); |
| 37 | REQUIRE(1 == 3); |
| 38 | // We should not get here, because the test above aborts |
| 39 | REQUIRE(1 != 4); |
| 40 | } |