Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/tests/ExtraTests/X04-DisabledExceptions-CustomHandler.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2019-12-05 16:00:20 +0100
committerMartin Hořeňovský2019-12-05 16:00:20 +0100
commit0fea081ad1a678b379182930a3ec22a3e275dbf0 (patch)
tree3afa04ce6805d7a86e9c59f87ac68cb1d21eb8b2 /tests/ExtraTests/X04-DisabledExceptions-CustomHandler.cpp
parent90e2549cecc2e886d563b7a88e752c9b4104f798 (diff)
downloadcatch3-0fea081ad1a678b379182930a3ec22a3e275dbf0.tar.gz
Move tests from projects/ to tests/
Diffstat (limited to 'tests/ExtraTests/X04-DisabledExceptions-CustomHandler.cpp')
-rw-r--r--tests/ExtraTests/X04-DisabledExceptions-CustomHandler.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/ExtraTests/X04-DisabledExceptions-CustomHandler.cpp b/tests/ExtraTests/X04-DisabledExceptions-CustomHandler.cpp
new file mode 100644
index 00000000..96f3ceb8
--- /dev/null
+++ b/tests/ExtraTests/X04-DisabledExceptions-CustomHandler.cpp
@@ -0,0 +1,33 @@
+#define CATCH_CONFIG_DISABLE_EXCEPTIONS_CUSTOM_HANDLER
+
+#define CATCH_CONFIG_MAIN
+#include <catch2/catch.hpp>
+
+namespace Catch {
+ [[noreturn]]
+ void throw_exception(std::exception const& e) {
+ Catch::cerr() << "====== CUSTOM HANDLER ====== run terminates because an exception was thrown.\n"
+ << "The message was: " << e.what() << '\n';
+ // Avoid abort and other exceptional exits -- there is no way
+ // to tell CMake that abort is the desired outcome of a test.
+ exit(1);
+ }
+}
+
+TEST_CASE("Tests that run") {
+ // All of these should be run and be reported
+ CHECK(1 == 2);
+ CHECK(1 == 1);
+ CHECK(1 != 3);
+ CHECK(1 == 4);
+}
+
+
+
+TEST_CASE("Tests that abort") {
+ REQUIRE(1 == 1);
+ REQUIRE(1 != 2);
+ REQUIRE(1 == 3);
+ // We should not get here, because the test above aborts
+ REQUIRE(1 != 4);
+}