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ý2025-08-26 12:07:41 +0200
committerMartin Hořeňovský2025-08-26 12:07:41 +0200
commit33adb4c779feaa3a98bb45ec1ebaf2864bb110b7 (patch)
tree4ca33028e7d91ca0196b292815ad44779f0a67dd /src/catch2/internal
parent25319fd3047c6bdcf3c0170e76fa526c77f99ca9 (diff)
downloadcatch3-33adb4c779feaa3a98bb45ec1ebaf2864bb110b7.tar.gz
Use only the ID of a message when removing it from context
Diffstat (limited to 'src/catch2/internal')
-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
3 files changed, 5 insertions, 4 deletions
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;