Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2/internal
diff options
context:
space:
mode:
authorMartin Hořeňovský2023-05-06 21:45:39 +0200
committerMartin Hořeňovský2023-05-06 23:58:48 +0200
commit8ca504cbc956d566ea77a8d59928146ad4cc3844 (patch)
treea2fad8e3fcb0e9212d3f64ecc7276e0dec3adc3c /src/catch2/internal
parentc57b5cdf432b1983c6f1b1fd9fb1f7ff11397391 (diff)
downloadcatch3-8ca504cbc956d566ea77a8d59928146ad4cc3844.tar.gz
Move AssertionResult when passing it inside RunContext
Diffstat (limited to 'src/catch2/internal')
-rw-r--r--src/catch2/internal/catch_run_context.cpp27
-rw-r--r--src/catch2/internal/catch_run_context.hpp2
2 files changed, 16 insertions, 13 deletions
diff --git a/src/catch2/internal/catch_run_context.cpp b/src/catch2/internal/catch_run_context.cpp
index c6171a5c..6f15cfb1 100644
--- a/src/catch2/internal/catch_run_context.cpp
+++ b/src/catch2/internal/catch_run_context.cpp
@@ -267,7 +267,7 @@ namespace Catch {
}
- void RunContext::assertionEnded(AssertionResult const & result) {
+ void RunContext::assertionEnded(AssertionResult&& result) {
if (result.getResultType() == ResultWas::Ok) {
m_totals.assertions.passed++;
m_lastAssertionPassed = true;
@@ -289,12 +289,13 @@ namespace Catch {
m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals));
- if (result.getResultType() != ResultWas::Warning)
+ if ( result.getResultType() != ResultWas::Warning ) {
m_messageScopes.clear();
+ }
// Reset working state
resetAssertionInfo();
- m_lastResult = result;
+ m_lastResult = CATCH_MOVE( result );
}
void RunContext::resetAssertionInfo() {
m_lastAssertionInfo.macroName = StringRef();
@@ -445,7 +446,7 @@ namespace Catch {
tempResult.message = static_cast<std::string>(message);
AssertionResult result(m_lastAssertionInfo, CATCH_MOVE(tempResult));
- assertionEnded(result);
+ assertionEnded(CATCH_MOVE(result) );
handleUnfinishedSections();
@@ -595,7 +596,7 @@ namespace Catch {
AssertionResult assertionResult{ info, CATCH_MOVE( data ) };
assertionResult.m_resultData.lazyExpression.m_transientExpression = expr;
- assertionEnded( assertionResult );
+ assertionEnded( CATCH_MOVE(assertionResult) );
}
void RunContext::handleMessage(
@@ -610,8 +611,10 @@ namespace Catch {
data.message = static_cast<std::string>(message);
AssertionResult assertionResult{ m_lastAssertionInfo,
CATCH_MOVE( data ) };
- assertionEnded( assertionResult );
- if ( !assertionResult.isOk() ) {
+
+ const auto isOk = assertionResult.isOk();
+ assertionEnded( CATCH_MOVE(assertionResult) );
+ if ( !isOk ) {
populateReaction( reaction );
} else if ( resultType == ResultWas::ExplicitSkip ) {
// TODO: Need to handle this explicitly, as ExplicitSkip is
@@ -636,7 +639,7 @@ namespace Catch {
AssertionResultData data( ResultWas::ThrewException, LazyExpression( false ) );
data.message = CATCH_MOVE(message);
AssertionResult assertionResult{ info, CATCH_MOVE(data) };
- assertionEnded( assertionResult );
+ assertionEnded( CATCH_MOVE(assertionResult) );
populateReaction( reaction );
}
@@ -654,7 +657,7 @@ namespace Catch {
AssertionResultData data( ResultWas::ThrewException, LazyExpression( false ) );
data.message = "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE"s;
AssertionResult assertionResult{ info, CATCH_MOVE( data ) };
- assertionEnded( assertionResult );
+ assertionEnded( CATCH_MOVE(assertionResult) );
}
void RunContext::handleNonExpr(
AssertionInfo const &info,
@@ -665,10 +668,10 @@ namespace Catch {
AssertionResultData data( resultType, LazyExpression( false ) );
AssertionResult assertionResult{ info, CATCH_MOVE( data ) };
- assertionEnded( assertionResult );
- if( !assertionResult.isOk() )
- populateReaction( reaction );
+ const auto isOk = assertionResult.isOk();
+ assertionEnded( CATCH_MOVE(assertionResult) );
+ if ( !isOk ) { populateReaction( reaction ); }
}
diff --git a/src/catch2/internal/catch_run_context.hpp b/src/catch2/internal/catch_run_context.hpp
index 76cdd84d..c749304d 100644
--- a/src/catch2/internal/catch_run_context.hpp
+++ b/src/catch2/internal/catch_run_context.hpp
@@ -121,7 +121,7 @@ namespace Catch {
void resetAssertionInfo();
bool testForMissingAssertions( Counts& assertions );
- void assertionEnded( AssertionResult const& result );
+ void assertionEnded( AssertionResult&& result );
void reportExpr
( AssertionInfo const &info,
ResultWas::OfType resultType,