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

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMartin Hořeňovský2025-07-16 21:51:58 +0200
committerMartin Hořeňovský2025-07-16 21:52:05 +0200
commitefcb76874e75c267e0b88163897d51996a9e0974 (patch)
treeb37738b1069209cb89e540766349d89588f0ac31
parent895b8af6bd70b1d56554f34ef55d6de8c306e917 (diff)
downloadcatch3-efcb76874e75c267e0b88163897d51996a9e0974.tar.gz
Store only lineinfo if m_lastAssertionInfo is going to be reset
`RunContext::resetAssertionInfo` overwrites everything in `m_lastAssertionInfo` except for the lineInfo, so if the reset is called at the end of a copying function, we can save work by copying only the lineInfo.
-rw-r--r--src/catch2/internal/catch_run_context.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/catch2/internal/catch_run_context.cpp b/src/catch2/internal/catch_run_context.cpp
index 7025b768..0beeedaa 100644
--- a/src/catch2/internal/catch_run_context.cpp
+++ b/src/catch2/internal/catch_run_context.cpp
@@ -331,7 +331,7 @@ namespace Catch {
m_activeSections.push_back(&sectionTracker);
SectionInfo sectionInfo( sectionLineInfo, static_cast<std::string>(sectionName) );
- m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo;
+ m_lastAssertionInfo.lineInfo = sectionLineInfo;
{
auto _ = scopedDeactivate( *m_outputRedirect );
@@ -638,11 +638,11 @@ namespace Catch {
std::string&& message,
AssertionReaction& reaction
) {
- m_lastAssertionInfo = info;
+ m_lastAssertionInfo.lineInfo = info.lineInfo;
AssertionResultData data( resultType, LazyExpression( false ) );
data.message = CATCH_MOVE( message );
- AssertionResult assertionResult{ m_lastAssertionInfo,
+ AssertionResult assertionResult{ info,
CATCH_MOVE( data ) };
const auto isOk = assertionResult.isOk();
@@ -669,7 +669,7 @@ namespace Catch {
std::string&& message,
AssertionReaction& reaction
) {
- m_lastAssertionInfo = info;
+ m_lastAssertionInfo.lineInfo = info.lineInfo;
AssertionResultData data( ResultWas::ThrewException, LazyExpression( false ) );
data.message = CATCH_MOVE(message);
@@ -690,7 +690,7 @@ namespace Catch {
AssertionInfo const& info
) {
using namespace std::string_literals;
- m_lastAssertionInfo = info;
+ m_lastAssertionInfo.lineInfo = info.lineInfo;
AssertionResultData data( ResultWas::ThrewException, LazyExpression( false ) );
data.message = "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE"s;
@@ -703,7 +703,7 @@ namespace Catch {
ResultWas::OfType resultType,
AssertionReaction &reaction
) {
- m_lastAssertionInfo = info;
+ m_lastAssertionInfo.lineInfo = info.lineInfo;
AssertionResultData data( resultType, LazyExpression( false ) );
AssertionResult assertionResult{ info, CATCH_MOVE( data ) };