mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-10 15:35:39 +02:00
Use only the ID of a message when removing it from context
This commit is contained in:
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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" )
|
||||
|
@@ -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;
|
||||
} ) );
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user