mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 13:26:10 +01:00
Move throwing test failure exceptions into a helper
This commit is contained in:
parent
ec59cd8736
commit
5f9d4ef331
@ -176,6 +176,7 @@ set(IMPL_SOURCES
|
||||
${SOURCES_DIR}/internal/catch_commandline.cpp
|
||||
${SOURCES_DIR}/internal/catch_source_line_info.cpp
|
||||
${SOURCES_DIR}/catch_config.cpp
|
||||
${SOURCES_DIR}/internal/catch_test_failure_exception.cpp
|
||||
${SOURCES_DIR}/internal/catch_case_insensitive_comparisons.cpp
|
||||
${SOURCES_DIR}/internal/catch_console_colour.cpp
|
||||
${SOURCES_DIR}/internal/catch_context.cpp
|
||||
|
@ -48,11 +48,7 @@ namespace Catch {
|
||||
CATCH_BREAK_INTO_DEBUGGER();
|
||||
}
|
||||
if (m_reaction.shouldThrow) {
|
||||
#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
|
||||
throw Catch::TestFailureException();
|
||||
#else
|
||||
CATCH_ERROR( "Test failure requires aborting test!" );
|
||||
#endif
|
||||
throw_test_failure_exception();
|
||||
}
|
||||
}
|
||||
void AssertionHandler::setCompleted() {
|
||||
|
23
src/catch2/internal/catch_test_failure_exception.cpp
Normal file
23
src/catch2/internal/catch_test_failure_exception.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
||||
#include <catch2/internal/catch_test_failure_exception.hpp>
|
||||
#include <catch2/internal/catch_enforce.hpp>
|
||||
#include <catch2/catch_user_config.hpp>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
void throw_test_failure_exception() {
|
||||
#if !defined( CATCH_CONFIG_DISABLE_EXCEPTIONS )
|
||||
throw TestFailureException{};
|
||||
#else
|
||||
CATCH_ERROR( "Test failure requires aborting test!" );
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace Catch
|
@ -13,6 +13,13 @@ namespace Catch {
|
||||
//! Used to signal that an assertion macro failed
|
||||
struct TestFailureException{};
|
||||
|
||||
/**
|
||||
* Outlines throwing of `TestFailureException` into a single TU
|
||||
*
|
||||
* Also handles `CATCH_CONFIG_DISABLE_EXCEPTIONS` for callers.
|
||||
*/
|
||||
[[noreturn]] void throw_test_failure_exception();
|
||||
|
||||
} // namespace Catch
|
||||
|
||||
#endif // CATCH_TEST_FAILURE_EXCEPTION_HPP_INCLUDED
|
||||
|
@ -231,6 +231,7 @@ internal_sources = files(
|
||||
'internal/catch_test_case_info_hasher.cpp',
|
||||
'internal/catch_test_case_registry_impl.cpp',
|
||||
'internal/catch_test_case_tracker.cpp',
|
||||
'internal/catch_test_failure_exception.cpp',
|
||||
'internal/catch_test_registry.cpp',
|
||||
'internal/catch_test_spec_parser.cpp',
|
||||
'internal/catch_textflow.cpp',
|
||||
|
Loading…
Reference in New Issue
Block a user