mirror of
https://github.com/catchorg/Catch2.git
synced 2026-07-21 13:53:35 +00:00
Move all use of IResultCapture in AssertionHandler into the cpp file
This has two advantages 1) Removing the include of `catch_interfaces_capture.hpp` from the header and potentially allowing further pruning later. 2) Providing small-but-measurable 1-2% speedup for assertions.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
#include <catch2/internal/catch_assertion_handler.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_capture.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_config.hpp>
|
||||
#include <catch2/internal/catch_context.hpp>
|
||||
#include <catch2/internal/catch_debugger.hpp>
|
||||
@@ -14,6 +15,10 @@
|
||||
|
||||
namespace Catch {
|
||||
|
||||
void AssertionHandler::finishIncomplete() {
|
||||
m_resultCapture.handleIncomplete( m_assertionInfo );
|
||||
}
|
||||
|
||||
AssertionHandler::AssertionHandler
|
||||
( StringRef macroName,
|
||||
SourceLineInfo const& lineInfo,
|
||||
|
||||
@@ -10,12 +10,13 @@
|
||||
|
||||
#include <catch2/catch_assertion_info.hpp>
|
||||
#include <catch2/internal/catch_decomposer.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_capture.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
class IResultCapture;
|
||||
|
||||
struct AssertionReaction {
|
||||
bool shouldDebugBreak = false;
|
||||
bool shouldThrow = false;
|
||||
@@ -28,6 +29,8 @@ namespace Catch {
|
||||
bool m_completed = false;
|
||||
IResultCapture& m_resultCapture;
|
||||
|
||||
void finishIncomplete();
|
||||
|
||||
public:
|
||||
AssertionHandler
|
||||
( StringRef macroName,
|
||||
@@ -35,9 +38,9 @@ namespace Catch {
|
||||
StringRef capturedExpression,
|
||||
ResultDisposition::Flags resultDisposition );
|
||||
~AssertionHandler() {
|
||||
if ( !m_completed ) {
|
||||
m_resultCapture.handleIncomplete( m_assertionInfo );
|
||||
}
|
||||
// We want the common fast path inlinable, and the virtual
|
||||
// dispatch in a function in single TU.
|
||||
if ( !m_completed ) { finishIncomplete(); }
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user