2013-02-02 20:58:04 +01:00
|
|
|
/*
|
|
|
|
* Created by Phil Nash on 1/2/2013.
|
|
|
|
* Copyright 2013 Two Blue Cubes Ltd. All rights reserved.
|
|
|
|
*
|
|
|
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "catch_message.h"
|
2017-07-06 22:28:42 +02:00
|
|
|
#include "catch_interfaces_capture.h"
|
2018-01-26 16:59:47 +01:00
|
|
|
#include "catch_uncaught_exceptions.h"
|
2013-02-02 20:58:04 +01:00
|
|
|
|
|
|
|
namespace Catch {
|
2013-07-03 20:14:59 +02:00
|
|
|
|
2018-07-23 13:42:44 +02:00
|
|
|
MessageInfo::MessageInfo( StringRef const& _macroName,
|
2013-02-02 20:58:04 +01:00
|
|
|
SourceLineInfo const& _lineInfo,
|
|
|
|
ResultWas::OfType _type )
|
|
|
|
: macroName( _macroName ),
|
|
|
|
lineInfo( _lineInfo ),
|
|
|
|
type( _type ),
|
|
|
|
sequence( ++globalCount )
|
|
|
|
{}
|
2013-07-03 20:14:59 +02:00
|
|
|
|
2017-07-06 22:28:42 +02:00
|
|
|
bool MessageInfo::operator==( MessageInfo const& other ) const {
|
|
|
|
return sequence == other.sequence;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MessageInfo::operator<( MessageInfo const& other ) const {
|
|
|
|
return sequence < other.sequence;
|
|
|
|
}
|
|
|
|
|
2013-02-02 20:58:04 +01:00
|
|
|
// This may need protecting if threading support is added
|
|
|
|
unsigned int MessageInfo::globalCount = 0;
|
2013-07-03 20:14:59 +02:00
|
|
|
|
|
|
|
|
2013-02-02 20:58:04 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////
|
2013-07-03 20:14:59 +02:00
|
|
|
|
2018-07-23 13:42:44 +02:00
|
|
|
Catch::MessageBuilder::MessageBuilder( StringRef const& macroName,
|
2017-07-06 22:28:42 +02:00
|
|
|
SourceLineInfo const& lineInfo,
|
|
|
|
ResultWas::OfType type )
|
|
|
|
:m_info(macroName, lineInfo, type) {}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
2013-06-28 18:09:57 +02:00
|
|
|
ScopedMessage::ScopedMessage( MessageBuilder const& builder )
|
|
|
|
: m_info( builder.m_info )
|
|
|
|
{
|
|
|
|
m_info.message = builder.m_stream.str();
|
|
|
|
getResultCapture().pushScopedMessage( m_info );
|
|
|
|
}
|
2014-05-19 19:57:14 +02:00
|
|
|
|
2013-06-28 18:09:57 +02:00
|
|
|
ScopedMessage::~ScopedMessage() {
|
2018-01-26 16:59:47 +01:00
|
|
|
if ( !uncaught_exceptions() ){
|
2017-03-31 00:06:35 +02:00
|
|
|
getResultCapture().popScopedMessage(m_info);
|
|
|
|
}
|
2013-02-02 20:58:04 +01:00
|
|
|
}
|
|
|
|
} // end namespace Catch
|