Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Outline throwing of TestSkipException

Commit
1dfaa8abe7ee6da548697ed8c6a704a2e7db1e41
Author
Martin Hořeňovský ·
Parents
ba94278bdd0f

Files · Download .tar.gz

Changes

 src/catch2/internal/catch_assertion_handler.cpp      |  6 +-----
 src/catch2/internal/catch_test_failure_exception.cpp |  8 ++++++++
 src/catch2/internal/catch_test_failure_exception.hpp | 10 ++++++++--
 3 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/catch2/internal/catch_assertion_handler.cpp b/src/catch2/internal/catch_assertion_handler.cpp
index b2accef3..c28b6190 100644
--- a/src/catch2/internal/catch_assertion_handler.cpp
+++ b/src/catch2/internal/catch_assertion_handler.cpp
@@ -51,11 +51,7 @@ namespace Catch {
             throw_test_failure_exception();
         }
         if ( m_reaction.shouldSkip ) {
-#if !defined( CATCH_CONFIG_DISABLE_EXCEPTIONS )
-            throw Catch::TestSkipException();
-#else
-            CATCH_ERROR( "Explicitly skipping tests during runtime requires exceptions" );
-#endif
+            throw_test_skip_exception();
         }
     }
 
diff --git a/src/catch2/internal/catch_test_failure_exception.cpp b/src/catch2/internal/catch_test_failure_exception.cpp
index c1edff3c..8ea31313 100644
--- a/src/catch2/internal/catch_test_failure_exception.cpp
+++ b/src/catch2/internal/catch_test_failure_exception.cpp
@@ -20,4 +20,12 @@ namespace Catch {
 #endif
     }
 
+    void throw_test_skip_exception() {
+#if !defined( CATCH_CONFIG_DISABLE_EXCEPTIONS )
+        throw Catch::TestSkipException();
+#else
+        CATCH_ERROR( "Explicitly skipping tests during runtime requires exceptions" );
+#endif
+    }
+
 } // namespace Catch
diff --git a/src/catch2/internal/catch_test_failure_exception.hpp b/src/catch2/internal/catch_test_failure_exception.hpp
index 13c5fc08..1ef88364 100644
--- a/src/catch2/internal/catch_test_failure_exception.hpp
+++ b/src/catch2/internal/catch_test_failure_exception.hpp
@@ -12,6 +12,8 @@ namespace Catch {
 
     //! Used to signal that an assertion macro failed
     struct TestFailureException{};
+    //! Used to signal that the remainder of a test should be skipped
+    struct TestSkipException {};
 
     /**
      * Outlines throwing of `TestFailureException` into a single TU
@@ -20,8 +22,12 @@ namespace Catch {
      */
     [[noreturn]] void throw_test_failure_exception();
 
-    //! Used to signal that the remainder of a test should be skipped
-    struct TestSkipException{};
+    /**
+     * Outlines throwing of `TestSkipException` into a single TU
+     *
+     * Also handles `CATCH_CONFIG_DISABLE_EXCEPTIONS` for callers.
+     */
+    [[noreturn]] void throw_test_skip_exception();
 
 } // namespace Catch