Outline throwing of TestSkipException

This commit is contained in:
Martin Hořeňovský 2023-03-12 00:45:31 +01:00
parent ba94278bdd
commit 1dfaa8abe7
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
3 changed files with 17 additions and 7 deletions

View File

@ -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();
}
}

View File

@ -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

View File

@ -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