mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-27 14:55:40 +02:00
Compare commits
5 Commits
devel-cont
...
devel
Author | SHA1 | Date | |
---|---|---|---|
![]() |
756ae05d30 | ||
![]() |
a2e41916f2 | ||
![]() |
0e772cc0d2 | ||
![]() |
3bcd0a4e74 | ||
![]() |
f7e7fa0983 |
@@ -78,5 +78,5 @@ WarningsAsErrors: >-
|
|||||||
readability-duplicate-include,
|
readability-duplicate-include,
|
||||||
HeaderFilterRegex: '.*\.(c|cxx|cpp)$'
|
HeaderFilterRegex: '.*\.(c|cxx|cpp)$'
|
||||||
FormatStyle: none
|
FormatStyle: none
|
||||||
CheckOptions: {}
|
CheckOptions: []
|
||||||
...
|
...
|
||||||
|
@@ -7,7 +7,14 @@
|
|||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
|
||||||
#include <catch2/interfaces/catch_interfaces_capture.hpp>
|
#include <catch2/interfaces/catch_interfaces_capture.hpp>
|
||||||
|
#include <catch2/internal/catch_enforce.hpp>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
IResultCapture::~IResultCapture() = default;
|
namespace Detail {
|
||||||
|
void missingCaptureInstance() {
|
||||||
|
CATCH_INTERNAL_ERROR( "No result capture instance" );
|
||||||
}
|
}
|
||||||
|
} // namespace Detail
|
||||||
|
|
||||||
|
IResultCapture::~IResultCapture() = default;
|
||||||
|
} // namespace Catch
|
||||||
|
@@ -111,8 +111,6 @@ namespace Catch {
|
|||||||
} else {
|
} else {
|
||||||
Detail::missingCaptureInstance();
|
Detail::missingCaptureInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -32,7 +32,6 @@ namespace Catch {
|
|||||||
m_resultCapture = resultCapture;
|
m_resultCapture = resultCapture;
|
||||||
}
|
}
|
||||||
constexpr void setConfig( IConfig const* config ) { m_config = config; }
|
constexpr void setConfig( IConfig const* config ) { m_config = config; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Context& getCurrentMutableContext();
|
Context& getCurrentMutableContext();
|
||||||
|
@@ -86,23 +86,27 @@ namespace Catch {
|
|||||||
{ EXCEPTION_INT_DIVIDE_BY_ZERO, "Divide by zero error" },
|
{ EXCEPTION_INT_DIVIDE_BY_ZERO, "Divide by zero error" },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Since we do not support multiple instantiations, we put these
|
||||||
|
// into global variables and rely on cleaning them up in outlined
|
||||||
|
// constructors/destructors
|
||||||
|
static LPTOP_LEVEL_EXCEPTION_FILTER previousTopLevelExceptionFilter = nullptr;
|
||||||
|
|
||||||
|
|
||||||
static LONG CALLBACK topLevelExceptionFilter(PEXCEPTION_POINTERS ExceptionInfo) {
|
static LONG CALLBACK topLevelExceptionFilter(PEXCEPTION_POINTERS ExceptionInfo) {
|
||||||
for (auto const& def : signalDefs) {
|
for (auto const& def : signalDefs) {
|
||||||
if (ExceptionInfo->ExceptionRecord->ExceptionCode == def.id) {
|
if (ExceptionInfo->ExceptionRecord->ExceptionCode == def.id) {
|
||||||
reportFatal(def.name);
|
reportFatal(def.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If its not an exception we care about, pass it along.
|
// If a filter was previously registered, invoke it
|
||||||
|
if (previousTopLevelExceptionFilter) {
|
||||||
|
return previousTopLevelExceptionFilter(ExceptionInfo);
|
||||||
|
}
|
||||||
|
// Otherwise, pass along all exceptions.
|
||||||
// This stops us from eating debugger breaks etc.
|
// This stops us from eating debugger breaks etc.
|
||||||
return EXCEPTION_CONTINUE_SEARCH;
|
return EXCEPTION_CONTINUE_SEARCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Since we do not support multiple instantiations, we put these
|
|
||||||
// into global variables and rely on cleaning them up in outlined
|
|
||||||
// constructors/destructors
|
|
||||||
static LPTOP_LEVEL_EXCEPTION_FILTER previousTopLevelExceptionFilter = nullptr;
|
|
||||||
|
|
||||||
|
|
||||||
// For MSVC, we reserve part of the stack memory for handling
|
// For MSVC, we reserve part of the stack memory for handling
|
||||||
// memory overflow structured exception.
|
// memory overflow structured exception.
|
||||||
FatalConditionHandler::FatalConditionHandler() {
|
FatalConditionHandler::FatalConditionHandler() {
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
@@ -23,16 +24,16 @@ namespace Catch {
|
|||||||
std::ostringstream m_referenceStream; // Used for copy state/ flags from
|
std::ostringstream m_referenceStream; // Used for copy state/ flags from
|
||||||
Detail::Mutex m_mutex;
|
Detail::Mutex m_mutex;
|
||||||
|
|
||||||
auto add() -> std::size_t {
|
auto add() -> std::pair<std::size_t, std::ostringstream*> {
|
||||||
Detail::LockGuard _( m_mutex );
|
Detail::LockGuard _( m_mutex );
|
||||||
if( m_unused.empty() ) {
|
if( m_unused.empty() ) {
|
||||||
m_streams.push_back( Detail::make_unique<std::ostringstream>() );
|
m_streams.push_back( Detail::make_unique<std::ostringstream>() );
|
||||||
return m_streams.size()-1;
|
return { m_streams.size()-1, m_streams.back().get() };
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
auto index = m_unused.back();
|
auto index = m_unused.back();
|
||||||
m_unused.pop_back();
|
m_unused.pop_back();
|
||||||
return index;
|
return { index, m_streams[index].get() };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,10 +47,10 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ReusableStringStream::ReusableStringStream()
|
ReusableStringStream::ReusableStringStream() {
|
||||||
: m_index( Singleton<StringStreams>::getMutable().add() ),
|
std::tie( m_index, m_oss ) =
|
||||||
m_oss( Singleton<StringStreams>::getMutable().m_streams[m_index].get() )
|
Singleton<StringStreams>::getMutable().add();
|
||||||
{}
|
}
|
||||||
|
|
||||||
ReusableStringStream::~ReusableStringStream() {
|
ReusableStringStream::~ReusableStringStream() {
|
||||||
static_cast<std::ostringstream*>( m_oss )->str("");
|
static_cast<std::ostringstream*>( m_oss )->str("");
|
||||||
|
@@ -21,7 +21,6 @@
|
|||||||
#include <catch2/internal/catch_assertion_handler.hpp>
|
#include <catch2/internal/catch_assertion_handler.hpp>
|
||||||
#include <catch2/internal/catch_test_failure_exception.hpp>
|
#include <catch2/internal/catch_test_failure_exception.hpp>
|
||||||
#include <catch2/internal/catch_result_type.hpp>
|
#include <catch2/internal/catch_result_type.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_capture.hpp>
|
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -840,10 +839,4 @@ namespace Catch {
|
|||||||
return getCurrentContext().getConfig()->rngSeed();
|
return getCurrentContext().getConfig()->rngSeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace Detail {
|
|
||||||
void missingCaptureInstance() {
|
|
||||||
CATCH_INTERNAL_ERROR( "No result capture instance" );
|
|
||||||
}
|
|
||||||
} // namespace Detail
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user