X03-DisabledExceptions-DefaultHandler.cpp 567 B

1234567891011121314151617181920212223
  1. #define CATCH_CONFIG_MAIN
  2. #include <catch2/catch.hpp>
  3. TEST_CASE("Tests that run") {
  4. // All of these should be run and be reported
  5. CHECK(1 == 2);
  6. CHECK(1 == 1);
  7. CHECK(1 != 3);
  8. CHECK(1 == 4);
  9. }
  10. TEST_CASE("Tests that abort") {
  11. // Avoid abort and other exceptional exits -- there is no way
  12. // to tell CMake that abort is the desired outcome of a test.
  13. std::set_terminate([](){exit(1);});
  14. REQUIRE(1 == 1);
  15. REQUIRE(1 != 2);
  16. REQUIRE(1 == 3);
  17. // We should not get here, because the test above aborts
  18. REQUIRE(1 != 4);
  19. }