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

summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorMartin Hořeňovský2025-08-26 12:07:41 +0200
committerMartin Hořeňovský2025-08-26 12:07:41 +0200
commit33adb4c779feaa3a98bb45ec1ebaf2864bb110b7 (patch)
tree4ca33028e7d91ca0196b292815ad44779f0a67dd /src
parent25319fd3047c6bdcf3c0170e76fa526c77f99ca9 (diff)
downloadcatch3-33adb4c779feaa3a98bb45ec1ebaf2864bb110b7.tar.gz
Use only the ID of a message when removing it from context
Diffstat (limited to 'src')
-rw-r--r--src/catch2/catch_message.cpp6
-rw-r--r--src/catch2/interfaces/catch_interfaces_capture.hpp2
-rw-r--r--src/catch2/internal/catch_message_info.hpp1
-rw-r--r--src/catch2/internal/catch_run_context.cpp6
-rw-r--r--src/catch2/internal/catch_run_context.hpp2
5 files changed, 9 insertions, 8 deletions
diff --git a/src/catch2/catch_message.cpp b/src/catch2/catch_message.cpp
index 9cb0167f..675e85f6 100644
--- a/src/catch2/catch_message.cpp
+++ b/src/catch2/catch_message.cpp
@@ -31,7 +31,7 @@ namespace Catch {
ScopedMessage::~ScopedMessage() {
if ( !m_moved ){
- getResultCapture().popScopedMessage(m_info);
+ getResultCapture().popScopedMessage(m_info.sequence);
}
}
@@ -101,8 +101,8 @@ namespace Catch {
}
Capturer::~Capturer() {
assert( m_captured == m_messages.size() );
- for ( size_t i = 0; i < m_captured; ++i ) {
- m_resultCapture.popScopedMessage( m_messages[i] );
+ for (auto const& message : m_messages) {
+ m_resultCapture.popScopedMessage( message.sequence );
}
}
diff --git a/src/catch2/interfaces/catch_interfaces_capture.hpp b/src/catch2/interfaces/catch_interfaces_capture.hpp
index dc9500b6..64f906a5 100644
--- a/src/catch2/interfaces/catch_interfaces_capture.hpp
+++ b/src/catch2/interfaces/catch_interfaces_capture.hpp
@@ -63,7 +63,7 @@ namespace Catch {
virtual void benchmarkFailed( StringRef error ) = 0;
virtual void pushScopedMessage( MessageInfo const& message ) = 0;
- virtual void popScopedMessage( MessageInfo const& message ) = 0;
+ virtual void popScopedMessage( unsigned int messageId ) = 0;
virtual void emplaceUnscopedMessage( MessageBuilder&& builder ) = 0;
diff --git a/src/catch2/internal/catch_message_info.hpp b/src/catch2/internal/catch_message_info.hpp
index bd686d6d..8c18186b 100644
--- a/src/catch2/internal/catch_message_info.hpp
+++ b/src/catch2/internal/catch_message_info.hpp
@@ -26,6 +26,7 @@ namespace Catch {
std::string message;
SourceLineInfo lineInfo;
ResultWas::OfType type;
+ // The "ID" of the message, used to know when to remove it from reporter context.
unsigned int sequence;
DEPRECATED( "Explicitly use the 'sequence' member instead" )
diff --git a/src/catch2/internal/catch_run_context.cpp b/src/catch2/internal/catch_run_context.cpp
index d1cec82c..b6edddb3 100644
--- a/src/catch2/internal/catch_run_context.cpp
+++ b/src/catch2/internal/catch_run_context.cpp
@@ -487,7 +487,7 @@ namespace Catch {
Detail::g_messages.push_back( message );
}
- void RunContext::popScopedMessage( MessageInfo const& message ) {
+ void RunContext::popScopedMessage( unsigned int messageId ) {
// Note: On average, it would probably be better to look for the message
// backwards. However, we do not expect to have to deal with more
// messages than low single digits, so the optimization is tiny,
@@ -496,8 +496,8 @@ namespace Catch {
Detail::g_messages.erase(
std::find_if( Detail::g_messages.begin(),
Detail::g_messages.end(),
- [id = message.sequence]( MessageInfo const& msg ) {
- return msg.sequence == id;
+ [=]( MessageInfo const& msg ) {
+ return msg.sequence == messageId;
} ) );
}
diff --git a/src/catch2/internal/catch_run_context.hpp b/src/catch2/internal/catch_run_context.hpp
index 39aca522..892926a0 100644
--- a/src/catch2/internal/catch_run_context.hpp
+++ b/src/catch2/internal/catch_run_context.hpp
@@ -95,7 +95,7 @@ namespace Catch {
void benchmarkFailed( StringRef error ) override;
void pushScopedMessage( MessageInfo const& message ) override;
- void popScopedMessage( MessageInfo const& message ) override;
+ void popScopedMessage( unsigned int messageId ) override;
void emplaceUnscopedMessage( MessageBuilder&& builder ) override;