mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 15:26:11 +01:00
Build 17 - includes reworking of message/ info handling
This commit is contained in:
parent
ad654867f1
commit
a2773810db
2
README
2
README
@ -1,4 +1,4 @@
|
|||||||
CATCH v0.9 build 16 (integration branch)
|
CATCH v0.9 build 17 (integration branch)
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
|
|
||||||
CATCH is an automated test framework for C, C++ and Objective-C.
|
CATCH is an automated test framework for C, C++ and Objective-C.
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
// These numbers are maintained by a script
|
// These numbers are maintained by a script
|
||||||
Version libraryVersion( 0, 9, 16, "integration" );
|
Version libraryVersion( 0, 9, 17, "integration" );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* CATCH v0.9 build 16 (integration branch)
|
* CATCH v0.9 build 17 (integration branch)
|
||||||
* Generated: 2013-01-26 20:18:07.076275
|
* Generated: 2013-02-02 20:37:06.007152
|
||||||
* ----------------------------------------------------------
|
* ----------------------------------------------------------
|
||||||
* This file has been merged from multiple headers. Please don't edit it directly
|
* This file has been merged from multiple headers. Please don't edit it directly
|
||||||
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
|
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
|
||||||
@ -656,6 +656,9 @@ namespace Catch {
|
|||||||
inline bool isOk( ResultWas::OfType resultType ) {
|
inline bool isOk( ResultWas::OfType resultType ) {
|
||||||
return ( resultType & ResultWas::FailureBit ) == 0;
|
return ( resultType & ResultWas::FailureBit ) == 0;
|
||||||
}
|
}
|
||||||
|
inline bool isJustInfo( int flags ) {
|
||||||
|
return flags == ResultWas::Info;
|
||||||
|
}
|
||||||
|
|
||||||
// ResultAction::Value enum
|
// ResultAction::Value enum
|
||||||
struct ResultAction { enum Value {
|
struct ResultAction { enum Value {
|
||||||
@ -1019,6 +1022,61 @@ public:
|
|||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
|
// #included from: catch_message.h
|
||||||
|
#define TWOBLUECUBES_CATCH_MESSAGE_H_INCLUDED
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace Catch {
|
||||||
|
|
||||||
|
struct MessageInfo {
|
||||||
|
MessageInfo( std::string const& _macroName,
|
||||||
|
SourceLineInfo const& _lineInfo,
|
||||||
|
ResultWas::OfType _type );
|
||||||
|
|
||||||
|
std::string macroName;
|
||||||
|
SourceLineInfo lineInfo;
|
||||||
|
ResultWas::OfType type;
|
||||||
|
std::string message;
|
||||||
|
unsigned int sequence;
|
||||||
|
|
||||||
|
bool operator == ( MessageInfo const& other ) const {
|
||||||
|
return sequence == other.sequence;
|
||||||
|
}
|
||||||
|
bool operator < ( MessageInfo const& other ) const {
|
||||||
|
return sequence < other.sequence;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
static unsigned int globalCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
class MessageBuilder : public MessageInfo {
|
||||||
|
public:
|
||||||
|
MessageBuilder( std::string const& _macroName,
|
||||||
|
SourceLineInfo const& _lineInfo,
|
||||||
|
ResultWas::OfType _type );
|
||||||
|
|
||||||
|
MessageInfo build() const;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
MessageBuilder& operator << ( T const& _value ) {
|
||||||
|
stream << _value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
std::ostringstream stream;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ScopedMessageBuilder : public MessageBuilder {
|
||||||
|
public:
|
||||||
|
ScopedMessageBuilder( std::string const& _macroName,
|
||||||
|
SourceLineInfo const& _lineInfo,
|
||||||
|
ResultWas::OfType _type );
|
||||||
|
~ScopedMessageBuilder();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // end namespace Catch
|
||||||
|
|
||||||
// #included from: catch_interfaces_capture.h
|
// #included from: catch_interfaces_capture.h
|
||||||
#define TWOBLUECUBES_CATCH_INTERFACES_CAPTURE_H_INCLUDED
|
#define TWOBLUECUBES_CATCH_INTERFACES_CAPTURE_H_INCLUDED
|
||||||
|
|
||||||
@ -1031,19 +1089,17 @@ public:
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
struct Counts {
|
struct Counts {
|
||||||
Counts() : passed( 0 ), failed( 0 ), info( 0 ) {}
|
Counts() : passed( 0 ), failed( 0 ) {}
|
||||||
|
|
||||||
Counts operator - ( const Counts& other ) const {
|
Counts operator - ( const Counts& other ) const {
|
||||||
Counts diff;
|
Counts diff;
|
||||||
diff.passed = passed - other.passed;
|
diff.passed = passed - other.passed;
|
||||||
diff.failed = failed - other.failed;
|
diff.failed = failed - other.failed;
|
||||||
diff.info = info - other.info;
|
|
||||||
return diff;
|
return diff;
|
||||||
}
|
}
|
||||||
Counts& operator += ( const Counts& other ) {
|
Counts& operator += ( const Counts& other ) {
|
||||||
passed += other.passed;
|
passed += other.passed;
|
||||||
failed += other.failed;
|
failed += other.failed;
|
||||||
info += other.info;
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1053,7 +1109,6 @@ namespace Catch {
|
|||||||
|
|
||||||
std::size_t passed;
|
std::size_t passed;
|
||||||
std::size_t failed;
|
std::size_t failed;
|
||||||
std::size_t info;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Totals {
|
struct Totals {
|
||||||
@ -1089,24 +1144,27 @@ namespace Catch {
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
class TestCase;
|
class TestCase;
|
||||||
class ScopedInfo;
|
|
||||||
class ExpressionResultBuilder;
|
class ExpressionResultBuilder;
|
||||||
class AssertionResult;
|
class AssertionResult;
|
||||||
struct AssertionInfo;
|
struct AssertionInfo;
|
||||||
struct SectionInfo;
|
struct SectionInfo;
|
||||||
|
class MessageBuilder;
|
||||||
|
class ScopedMessageBuilder;
|
||||||
|
|
||||||
struct IResultCapture {
|
struct IResultCapture {
|
||||||
|
|
||||||
virtual ~IResultCapture();
|
virtual ~IResultCapture();
|
||||||
|
|
||||||
virtual void testEnded( AssertionResult const& result ) = 0;
|
virtual void assertionEnded( AssertionResult const& result ) = 0;
|
||||||
virtual bool sectionStarted( SectionInfo const& sectionInfo,
|
virtual bool sectionStarted( SectionInfo const& sectionInfo,
|
||||||
Counts& assertions ) = 0;
|
Counts& assertions ) = 0;
|
||||||
virtual void sectionEnded( SectionInfo const& name, Counts const& assertions ) = 0;
|
virtual void sectionEnded( SectionInfo const& name, Counts const& assertions ) = 0;
|
||||||
virtual void pushScopedInfo( ScopedInfo* scopedInfo ) = 0;
|
virtual void pushScopedMessage( ScopedMessageBuilder const& _builder ) = 0;
|
||||||
virtual void popScopedInfo( ScopedInfo* scopedInfo ) = 0;
|
virtual void popScopedMessage( ScopedMessageBuilder const& _builder ) = 0;
|
||||||
|
|
||||||
virtual bool shouldDebugBreak() const = 0;
|
virtual bool shouldDebugBreak() const = 0;
|
||||||
|
|
||||||
|
virtual void acceptMessage( const MessageBuilder& messageBuilder ) = 0;
|
||||||
virtual ResultAction::Value acceptExpression( ExpressionResultBuilder const& assertionResult, AssertionInfo const& assertionInfo ) = 0;
|
virtual ResultAction::Value acceptExpression( ExpressionResultBuilder const& assertionResult, AssertionInfo const& assertionInfo ) = 0;
|
||||||
|
|
||||||
virtual std::string getCurrentTestName() const = 0;
|
virtual std::string getCurrentTestName() const = 0;
|
||||||
@ -2017,13 +2075,24 @@ namespace Catch
|
|||||||
|
|
||||||
struct AssertionStats {
|
struct AssertionStats {
|
||||||
AssertionStats( AssertionResult const& _assertionResult,
|
AssertionStats( AssertionResult const& _assertionResult,
|
||||||
|
std::vector<MessageInfo> const& _infoMessages,
|
||||||
Totals const& _totals )
|
Totals const& _totals )
|
||||||
: assertionResult( _assertionResult ),
|
: assertionResult( _assertionResult ),
|
||||||
|
infoMessages( _infoMessages ),
|
||||||
totals( _totals )
|
totals( _totals )
|
||||||
{}
|
{
|
||||||
|
if( assertionResult.hasMessage() ) {
|
||||||
|
// Copy message into messages list.
|
||||||
|
// !TBD This should have been done earlier, somewhere
|
||||||
|
MessageBuilder builder( assertionResult.getTestMacroName(), assertionResult.getSourceInfo(), assertionResult.getResultType() );
|
||||||
|
builder << assertionResult.getMessage();
|
||||||
|
infoMessages.push_back( builder.build() );
|
||||||
|
}
|
||||||
|
}
|
||||||
virtual ~AssertionStats();
|
virtual ~AssertionStats();
|
||||||
|
|
||||||
AssertionResult assertionResult;
|
AssertionResult assertionResult;
|
||||||
|
std::vector<MessageInfo> infoMessages;
|
||||||
Totals totals;
|
Totals totals;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2441,27 +2510,6 @@ namespace Catch {
|
|||||||
|
|
||||||
struct TestFailureException{};
|
struct TestFailureException{};
|
||||||
|
|
||||||
class ScopedInfo {
|
|
||||||
public:
|
|
||||||
ScopedInfo() : m_resultBuilder( ResultWas::Info ) {
|
|
||||||
getResultCapture().pushScopedInfo( this );
|
|
||||||
}
|
|
||||||
~ScopedInfo() {
|
|
||||||
getResultCapture().popScopedInfo( this );
|
|
||||||
}
|
|
||||||
template<typename T>
|
|
||||||
ScopedInfo& operator << ( const T& value ) {
|
|
||||||
m_resultBuilder << value;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
AssertionResult buildResult( const AssertionInfo& assertionInfo ) const {
|
|
||||||
return m_resultBuilder.buildResult( assertionInfo );
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
ExpressionResultBuilder m_resultBuilder;
|
|
||||||
};
|
|
||||||
|
|
||||||
// This is just here to avoid compiler warnings with macro constants and boolean literals
|
// This is just here to avoid compiler warnings with macro constants and boolean literals
|
||||||
inline bool isTrue( bool value ){ return value; }
|
inline bool isTrue( bool value ){ return value; }
|
||||||
|
|
||||||
@ -2555,17 +2603,23 @@ inline bool isTrue( bool value ){ return value; }
|
|||||||
} while( Catch::isTrue( false ) )
|
} while( Catch::isTrue( false ) )
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_MSG( reason, resultType, resultDisposition, macroName ) \
|
#define INTERNAL_CATCH_INFO( log, macroName ) \
|
||||||
|
do { \
|
||||||
|
Catch::getResultCapture().acceptMessage( Catch::MessageBuilder( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log ); \
|
||||||
|
} while( Catch::isTrue( false ) )
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
#define INTERNAL_CATCH_MSG( log, messageType, resultDisposition, macroName ) \
|
||||||
do { \
|
do { \
|
||||||
INTERNAL_CATCH_ACCEPT_INFO( "", macroName, resultDisposition ); \
|
INTERNAL_CATCH_ACCEPT_INFO( "", macroName, resultDisposition ); \
|
||||||
INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( resultType ) << reason, resultDisposition, true ) \
|
INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( messageType ) << log, resultDisposition, true ) \
|
||||||
} while( Catch::isTrue( false ) )
|
} while( Catch::isTrue( false ) )
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_SCOPED_INFO( log, macroName ) \
|
#define INTERNAL_CATCH_SCOPED_INFO( log, macroName ) \
|
||||||
INTERNAL_CATCH_ACCEPT_INFO( "", macroName, Catch::ResultDisposition::Normal ); \
|
Catch::ScopedMessageBuilder INTERNAL_CATCH_UNIQUE_NAME( scopedMessage )( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ); \
|
||||||
Catch::ScopedInfo INTERNAL_CATCH_UNIQUE_NAME( info ); \
|
INTERNAL_CATCH_UNIQUE_NAME( scopedMessage ) << log; \
|
||||||
INTERNAL_CATCH_UNIQUE_NAME( info ) << log
|
Catch::getResultCapture().pushScopedMessage( INTERNAL_CATCH_UNIQUE_NAME( scopedMessage ) )
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CHECK_THAT( arg, matcher, resultDisposition, macroName ) \
|
#define INTERNAL_CHECK_THAT( arg, matcher, resultDisposition, macroName ) \
|
||||||
@ -3505,7 +3559,7 @@ namespace Catch {
|
|||||||
virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) = 0;
|
virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) = 0;
|
||||||
virtual std::string argsSynopsis() const = 0;
|
virtual std::string argsSynopsis() const = 0;
|
||||||
virtual std::string optionSummary() const = 0;
|
virtual std::string optionSummary() const = 0;
|
||||||
virtual std::string optionDescription() const { return ""; };
|
virtual std::string optionDescription() const { return ""; }
|
||||||
|
|
||||||
std::string optionNames() const {
|
std::string optionNames() const {
|
||||||
std::string names;
|
std::string names;
|
||||||
@ -4429,43 +4483,28 @@ namespace Catch {
|
|||||||
|
|
||||||
private: // IResultCapture
|
private: // IResultCapture
|
||||||
|
|
||||||
|
virtual void acceptMessage( const MessageBuilder& messageBuilder ) {
|
||||||
|
m_messages.push_back( messageBuilder.build() );
|
||||||
|
}
|
||||||
|
|
||||||
virtual ResultAction::Value acceptExpression( const ExpressionResultBuilder& assertionResult, const AssertionInfo& assertionInfo ) {
|
virtual ResultAction::Value acceptExpression( const ExpressionResultBuilder& assertionResult, const AssertionInfo& assertionInfo ) {
|
||||||
m_lastAssertionInfo = assertionInfo;
|
m_lastAssertionInfo = assertionInfo;
|
||||||
return actOnCurrentResult( assertionResult.buildResult( assertionInfo ) );
|
return actOnCurrentResult( assertionResult.buildResult( assertionInfo ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testEnded( const AssertionResult& result ) {
|
virtual void assertionEnded( const AssertionResult& result ) {
|
||||||
if( result.getResultType() == ResultWas::Ok ) {
|
if( result.getResultType() == ResultWas::Ok ) {
|
||||||
m_totals.assertions.passed++;
|
m_totals.assertions.passed++;
|
||||||
}
|
}
|
||||||
else if( !result.isOk() ) {
|
else if( !result.isOk() ) {
|
||||||
m_totals.assertions.failed++;
|
m_totals.assertions.failed++;
|
||||||
|
|
||||||
{
|
|
||||||
std::vector<ScopedInfo*>::const_iterator it = m_scopedInfos.begin();
|
|
||||||
std::vector<ScopedInfo*>::const_iterator itEnd = m_scopedInfos.end();
|
|
||||||
for(; it != itEnd; ++it )
|
|
||||||
m_reporter->assertionEnded( AssertionStats( (*it)->buildResult( m_lastAssertionInfo ), m_totals ) );
|
|
||||||
}
|
|
||||||
{
|
|
||||||
std::vector<AssertionResult>::const_iterator it = m_assertionResults.begin();
|
|
||||||
std::vector<AssertionResult>::const_iterator itEnd = m_assertionResults.end();
|
|
||||||
for(; it != itEnd; ++it )
|
|
||||||
m_reporter->assertionEnded( AssertionStats( *it, m_totals ) );
|
|
||||||
}
|
|
||||||
m_assertionResults.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( result.getResultType() == ResultWas::Info )
|
m_reporter->assertionEnded( AssertionStats( result, m_messages, m_totals ) );
|
||||||
{
|
|
||||||
m_assertionResults.push_back( result );
|
|
||||||
m_totals.assertions.info++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
m_reporter->assertionEnded( AssertionStats( result, m_totals ) );
|
|
||||||
|
|
||||||
// Reset AssertionInfo
|
// Reset working state
|
||||||
m_lastAssertionInfo = AssertionInfo( "", m_lastAssertionInfo.lineInfo, "{Unknown expression after this line}" , m_lastAssertionInfo.resultDisposition );
|
m_lastAssertionInfo = AssertionInfo( "", m_lastAssertionInfo.lineInfo, "{Unknown expression after the reported line}" , m_lastAssertionInfo.resultDisposition );
|
||||||
|
m_messages.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool sectionStarted (
|
virtual bool sectionStarted (
|
||||||
@ -4502,15 +4541,15 @@ namespace Catch {
|
|||||||
m_runningTest->endSection( info.name );
|
m_runningTest->endSection( info.name );
|
||||||
|
|
||||||
m_reporter->sectionEnded( SectionStats( info, assertions, missingAssertions ) );
|
m_reporter->sectionEnded( SectionStats( info, assertions, missingAssertions ) );
|
||||||
|
m_messages.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void pushScopedInfo( ScopedInfo* scopedInfo ) {
|
virtual void pushScopedMessage( ScopedMessageBuilder const& _builder ) {
|
||||||
m_scopedInfos.push_back( scopedInfo );
|
m_messages.push_back( _builder.build() );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void popScopedInfo( ScopedInfo* scopedInfo ) {
|
virtual void popScopedMessage( ScopedMessageBuilder const& _builder ) {
|
||||||
if( m_scopedInfos.back() == scopedInfo )
|
m_messages.erase( std::remove( m_messages.begin(), m_messages.end(), _builder ), m_messages.end() );
|
||||||
m_scopedInfos.pop_back();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool shouldDebugBreak() const {
|
virtual bool shouldDebugBreak() const {
|
||||||
@ -4537,7 +4576,7 @@ namespace Catch {
|
|||||||
|
|
||||||
ResultAction::Value actOnCurrentResult( const AssertionResult& result ) {
|
ResultAction::Value actOnCurrentResult( const AssertionResult& result ) {
|
||||||
m_lastResult = result;
|
m_lastResult = result;
|
||||||
testEnded( m_lastResult );
|
assertionEnded( m_lastResult );
|
||||||
|
|
||||||
ResultAction::Value action = ResultAction::None;
|
ResultAction::Value action = ResultAction::None;
|
||||||
|
|
||||||
@ -4573,7 +4612,6 @@ namespace Catch {
|
|||||||
exResult << translateActiveException();
|
exResult << translateActiveException();
|
||||||
actOnCurrentResult( exResult.buildResult( m_lastAssertionInfo ) );
|
actOnCurrentResult( exResult.buildResult( m_lastAssertionInfo ) );
|
||||||
}
|
}
|
||||||
m_assertionResults.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -4585,8 +4623,7 @@ namespace Catch {
|
|||||||
const Config& m_config;
|
const Config& m_config;
|
||||||
Totals m_totals;
|
Totals m_totals;
|
||||||
Ptr<IStreamingReporter> m_reporter;
|
Ptr<IStreamingReporter> m_reporter;
|
||||||
std::vector<ScopedInfo*> m_scopedInfos;
|
std::vector<MessageInfo> m_messages;
|
||||||
std::vector<AssertionResult> m_assertionResults;
|
|
||||||
IRunner* m_prevRunner;
|
IRunner* m_prevRunner;
|
||||||
IResultCapture* m_prevResultCapture;
|
IResultCapture* m_prevResultCapture;
|
||||||
const IConfig* m_prevConfig;
|
const IConfig* m_prevConfig;
|
||||||
@ -5777,7 +5814,7 @@ namespace Catch {
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
// These numbers are maintained by a script
|
// These numbers are maintained by a script
|
||||||
Version libraryVersion( 0, 9, 16, "integration" );
|
Version libraryVersion( 0, 9, 17, "integration" );
|
||||||
}
|
}
|
||||||
|
|
||||||
// #included from: catch_line_wrap.hpp
|
// #included from: catch_line_wrap.hpp
|
||||||
@ -5837,6 +5874,52 @@ namespace Catch {
|
|||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
|
// #included from: catch_message.hpp
|
||||||
|
#define TWOBLUECUBES_CATCH_MESSAGE_HPP_INCLUDED
|
||||||
|
|
||||||
|
namespace Catch {
|
||||||
|
|
||||||
|
MessageInfo::MessageInfo( std::string const& _macroName,
|
||||||
|
SourceLineInfo const& _lineInfo,
|
||||||
|
ResultWas::OfType _type )
|
||||||
|
: macroName( _macroName ),
|
||||||
|
lineInfo( _lineInfo ),
|
||||||
|
type( _type ),
|
||||||
|
sequence( ++globalCount )
|
||||||
|
{}
|
||||||
|
|
||||||
|
// This may need protecting if threading support is added
|
||||||
|
unsigned int MessageInfo::globalCount = 0;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
MessageBuilder::MessageBuilder( std::string const& _macroName,
|
||||||
|
SourceLineInfo const& _lineInfo,
|
||||||
|
ResultWas::OfType _type )
|
||||||
|
: MessageInfo( _macroName, _lineInfo, _type )
|
||||||
|
{}
|
||||||
|
|
||||||
|
MessageInfo MessageBuilder::build() const {
|
||||||
|
MessageInfo message = *this;
|
||||||
|
message.message = stream.str();
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
ScopedMessageBuilder::ScopedMessageBuilder
|
||||||
|
( std::string const& _macroName,
|
||||||
|
SourceLineInfo const& _lineInfo,
|
||||||
|
ResultWas::OfType _type )
|
||||||
|
: MessageBuilder( _macroName, _lineInfo, _type )
|
||||||
|
{}
|
||||||
|
|
||||||
|
ScopedMessageBuilder::~ScopedMessageBuilder() {
|
||||||
|
getResultCapture().popScopedMessage( *this );
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end namespace Catch
|
||||||
|
|
||||||
// #included from: ../reporters/catch_reporter_basic.hpp
|
// #included from: ../reporters/catch_reporter_basic.hpp
|
||||||
#define TWOBLUECUBES_CATCH_REPORTER_BASIC_HPP_INCLUDED
|
#define TWOBLUECUBES_CATCH_REPORTER_BASIC_HPP_INCLUDED
|
||||||
|
|
||||||
@ -6900,14 +6983,18 @@ namespace Catch {
|
|||||||
stats( _stats ),
|
stats( _stats ),
|
||||||
result( _stats.assertionResult ),
|
result( _stats.assertionResult ),
|
||||||
colour( TextColour::None ),
|
colour( TextColour::None ),
|
||||||
message( result.getMessage() )
|
message( result.getMessage() ),
|
||||||
|
messages( _stats.infoMessages )
|
||||||
{
|
{
|
||||||
switch( result.getResultType() ) {
|
switch( result.getResultType() ) {
|
||||||
case ResultWas::Ok:
|
case ResultWas::Ok:
|
||||||
colour = TextColour::Success;
|
colour = TextColour::Success;
|
||||||
passOrFail = "PASSED";
|
passOrFail = "PASSED";
|
||||||
if( result.hasMessage() )
|
//if( result.hasMessage() )
|
||||||
|
if( _stats.infoMessages.size() == 1 )
|
||||||
messageLabel = "with message";
|
messageLabel = "with message";
|
||||||
|
if( _stats.infoMessages.size() > 1 )
|
||||||
|
messageLabel = "with messages";
|
||||||
break;
|
break;
|
||||||
case ResultWas::ExpressionFailed:
|
case ResultWas::ExpressionFailed:
|
||||||
if( result.isOk() ) {
|
if( result.isOk() ) {
|
||||||
@ -6918,9 +7005,13 @@ namespace Catch {
|
|||||||
colour = TextColour::Error;
|
colour = TextColour::Error;
|
||||||
passOrFail = "FAILED";
|
passOrFail = "FAILED";
|
||||||
}
|
}
|
||||||
if( result.hasMessage() ){
|
if( _stats.infoMessages.size() == 1 )
|
||||||
messageLabel = "with message";
|
messageLabel = "with message";
|
||||||
}
|
if( _stats.infoMessages.size() > 1 )
|
||||||
|
messageLabel = "with messages";
|
||||||
|
// if( result.hasMessage() ){
|
||||||
|
// messageLabel = "with message";
|
||||||
|
// }
|
||||||
break;
|
break;
|
||||||
case ResultWas::ThrewException:
|
case ResultWas::ThrewException:
|
||||||
colour = TextColour::Error;
|
colour = TextColour::Error;
|
||||||
@ -6941,13 +7032,21 @@ namespace Catch {
|
|||||||
case ResultWas::ExplicitFailure:
|
case ResultWas::ExplicitFailure:
|
||||||
passOrFail = "FAILED";
|
passOrFail = "FAILED";
|
||||||
colour = TextColour::Error;
|
colour = TextColour::Error;
|
||||||
|
// messageLabel = "explicitly with message";
|
||||||
|
if( _stats.infoMessages.size() == 1 )
|
||||||
messageLabel = "explicitly with message";
|
messageLabel = "explicitly with message";
|
||||||
|
if( _stats.infoMessages.size() > 1 )
|
||||||
|
messageLabel = "explicitly with messages";
|
||||||
break;
|
break;
|
||||||
case ResultWas::Exception:
|
case ResultWas::Exception:
|
||||||
passOrFail = "FAILED";
|
passOrFail = "FAILED";
|
||||||
colour = TextColour::Error;
|
colour = TextColour::Error;
|
||||||
if( result.hasMessage() )
|
if( _stats.infoMessages.size() == 1 )
|
||||||
messageLabel = "with message";
|
messageLabel = "with message";
|
||||||
|
if( _stats.infoMessages.size() > 1 )
|
||||||
|
messageLabel = "with messages";
|
||||||
|
// if( result.hasMessage() )
|
||||||
|
// messageLabel = "with message";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// These cases are here to prevent compiler warnings
|
// These cases are here to prevent compiler warnings
|
||||||
@ -6998,8 +7097,13 @@ namespace Catch {
|
|||||||
void printMessage() const {
|
void printMessage() const {
|
||||||
if( !messageLabel.empty() )
|
if( !messageLabel.empty() )
|
||||||
stream << messageLabel << ":" << "\n";
|
stream << messageLabel << ":" << "\n";
|
||||||
if( !message.empty() )
|
for( std::vector<MessageInfo>::const_iterator it = messages.begin(), itEnd = messages.end();
|
||||||
stream << wrapLongStrings( message ) << "\n";
|
it != itEnd;
|
||||||
|
++it ) {
|
||||||
|
stream << wrapLongStrings( it->message ) << "\n";
|
||||||
|
}
|
||||||
|
// if( !message.empty() )
|
||||||
|
// stream << wrapLongStrings( message ) << "\n";
|
||||||
}
|
}
|
||||||
void printSourceInfo() const {
|
void printSourceInfo() const {
|
||||||
TextColour colourGuard( TextColour::FileName );
|
TextColour colourGuard( TextColour::FileName );
|
||||||
@ -7017,6 +7121,7 @@ namespace Catch {
|
|||||||
std::string passOrFail;
|
std::string passOrFail;
|
||||||
std::string messageLabel;
|
std::string messageLabel;
|
||||||
std::string message;
|
std::string message;
|
||||||
|
std::vector<MessageInfo> messages;
|
||||||
};
|
};
|
||||||
|
|
||||||
void lazyPrint() {
|
void lazyPrint() {
|
||||||
@ -7279,12 +7384,12 @@ int main (int argc, char * const argv[]) {
|
|||||||
#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THAT" )
|
#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THAT" )
|
||||||
#define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THAT" )
|
#define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THAT" )
|
||||||
|
|
||||||
#define CATCH_INFO( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Info, Catch::ResultDisposition::ContinueOnFailure, "CATCH_INFO" )
|
#define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( msg, "CATCH_INFO" )
|
||||||
#define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, "CATCH_WARN" )
|
#define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, "CATCH_WARN" )
|
||||||
#define CATCH_FAIL( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL" )
|
#define CATCH_FAIL( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL" )
|
||||||
#define CATCH_SUCCEED( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED" )
|
#define CATCH_SUCCEED( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED" )
|
||||||
#define CATCH_SCOPED_INFO( msg ) INTERNAL_CATCH_SCOPED_INFO( msg, "CATCH_SCOPED_INFO" )
|
#define CATCH_SCOPED_INFO( msg ) INTERNAL_CATCH_SCOPED_INFO( msg, "CATCH_SCOPED_INFO" )
|
||||||
#define CATCH_CAPTURE( msg ) INTERNAL_CATCH_MSG( #msg " := " << msg, Catch::ResultWas::Info, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CAPTURE" )
|
#define CATCH_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CATCH_CAPTURE" )
|
||||||
#define CATCH_SCOPED_CAPTURE( msg ) INTERNAL_CATCH_SCOPED_INFO( #msg " := " << msg, "CATCH_SCOPED_CAPTURE" )
|
#define CATCH_SCOPED_CAPTURE( msg ) INTERNAL_CATCH_SCOPED_INFO( #msg " := " << msg, "CATCH_SCOPED_CAPTURE" )
|
||||||
|
|
||||||
#define CATCH_SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
|
#define CATCH_SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
|
||||||
@ -7322,12 +7427,12 @@ int main (int argc, char * const argv[]) {
|
|||||||
#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THAT" )
|
#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THAT" )
|
||||||
#define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::Normal, "REQUIRE_THAT" )
|
#define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::Normal, "REQUIRE_THAT" )
|
||||||
|
|
||||||
#define INFO( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Info, Catch::ResultDisposition::ContinueOnFailure, "INFO" )
|
#define INFO( msg ) INTERNAL_CATCH_INFO( msg, "INFO" )
|
||||||
#define WARN( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, "WARN" )
|
#define WARN( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, "WARN" )
|
||||||
#define FAIL( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL" )
|
#define FAIL( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL" )
|
||||||
#define SUCCEED( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED" )
|
#define SUCCEED( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED" )
|
||||||
#define SCOPED_INFO( msg ) INTERNAL_CATCH_SCOPED_INFO( msg, "SCOPED_INFO" )
|
#define SCOPED_INFO( msg ) INTERNAL_CATCH_SCOPED_INFO( msg, "SCOPED_INFO" )
|
||||||
#define CAPTURE( msg ) INTERNAL_CATCH_MSG( #msg " := " << msg, Catch::ResultWas::Info, Catch::ResultDisposition::ContinueOnFailure, "CAPTURE" )
|
#define CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CAPTURE" )
|
||||||
#define SCOPED_CAPTURE( msg ) INTERNAL_CATCH_SCOPED_INFO( #msg " := " << msg, "SCOPED_CAPTURE" )
|
#define SCOPED_CAPTURE( msg ) INTERNAL_CATCH_SCOPED_INFO( #msg " := " << msg, "SCOPED_CAPTURE" )
|
||||||
|
|
||||||
#define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
|
#define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
|
||||||
|
Loading…
Reference in New Issue
Block a user