diff options
| author | Martin Hořeňovský | 2023-03-12 00:45:31 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2023-03-12 00:45:31 +0100 |
| commit | 1dfaa8abe7ee6da548697ed8c6a704a2e7db1e41 (patch) | |
| tree | 990da5e43ecb57ae6eb89f57b5907a5f3db9864d | |
| parent | ba94278bdd0fb22e94490e5fefd65f356c37947c (diff) | |
| download | catch3-1dfaa8abe7ee6da548697ed8c6a704a2e7db1e41.tar.gz | |
Outline throwing of TestSkipException
| -rw-r--r-- | src/catch2/internal/catch_assertion_handler.cpp | 6 | ||||
| -rw-r--r-- | src/catch2/internal/catch_test_failure_exception.cpp | 8 | ||||
| -rw-r--r-- | 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 |