INFO and CAPTURE are now scoped

- SCOPED_INFO and SCOPED_CAPTURE are now just aliases
This commit is contained in:
Phil Nash 2013-06-28 17:09:57 +01:00
parent 881c61b67f
commit b5fd5a6496
9 changed files with 190 additions and 241 deletions

View File

@ -74,9 +74,9 @@
#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_INFO( msg, "CATCH_INFO" )
#define CATCH_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "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_INFO( #msg " := " << msg, "CATCH_CAPTURE" )
#ifdef CATCH_CONFIG_VARIADIC_MACROS #ifdef CATCH_CONFIG_VARIADIC_MACROS
#define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) #define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
@ -135,9 +135,9 @@
#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_INFO( msg, "INFO" )
#define CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "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_INFO( #msg " := " << msg, "CAPTURE" )
#ifdef CATCH_CONFIG_VARIADIC_MACROS #ifdef CATCH_CONFIG_VARIADIC_MACROS
#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) #define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )

View File

@ -145,11 +145,6 @@ struct TestFailureException{};
} \ } \
} while( Catch::isTrue( false ) ) } while( Catch::isTrue( false ) )
///////////////////////////////////////////////////////////////////////////////
#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 ) \ #define INTERNAL_CATCH_MSG( log, messageType, resultDisposition, macroName ) \
@ -159,10 +154,8 @@ struct TestFailureException{};
} while( Catch::isTrue( false ) ) } while( Catch::isTrue( false ) )
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_SCOPED_INFO( log, macroName ) \ #define INTERNAL_CATCH_INFO( log, macroName ) \
Catch::ScopedMessageBuilder INTERNAL_CATCH_UNIQUE_NAME( scopedMessage )( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ); \ Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage ) = Catch::MessageBuilder( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log;
INTERNAL_CATCH_UNIQUE_NAME( scopedMessage ) << log; \
Catch::getResultCapture().pushScopedMessage( INTERNAL_CATCH_UNIQUE_NAME( scopedMessage ) )
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -20,7 +20,7 @@ namespace Catch {
class AssertionResult; class AssertionResult;
struct AssertionInfo; struct AssertionInfo;
struct SectionInfo; struct SectionInfo;
class MessageBuilder; struct MessageInfo;
class ScopedMessageBuilder; class ScopedMessageBuilder;
struct IResultCapture { struct IResultCapture {
@ -31,12 +31,11 @@ namespace Catch {
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 pushScopedMessage( ScopedMessageBuilder const& _builder ) = 0; virtual void pushScopedMessage( MessageInfo const& message ) = 0;
virtual void popScopedMessage( ScopedMessageBuilder const& _builder ) = 0; virtual void popScopedMessage( MessageInfo const& message ) = 0;
virtual bool shouldDebugBreak() const = 0; virtual bool shouldDebugBreak() const = 0;
virtual void acceptMessage( MessageBuilder const& 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;

View File

@ -102,7 +102,9 @@ namespace Catch
// !TBD This should have been done earlier, somewhere // !TBD This should have been done earlier, somewhere
MessageBuilder builder( assertionResult.getTestMacroName(), assertionResult.getSourceInfo(), assertionResult.getResultType() ); MessageBuilder builder( assertionResult.getTestMacroName(), assertionResult.getSourceInfo(), assertionResult.getResultType() );
builder << assertionResult.getMessage(); builder << assertionResult.getMessage();
infoMessages.push_back( builder.build() ); builder.m_info.message = builder.m_stream.str();
infoMessages.push_back( builder.m_info );
} }
} }
virtual ~AssertionStats(); virtual ~AssertionStats();

View File

@ -35,30 +35,29 @@ namespace Catch {
static unsigned int globalCount; static unsigned int globalCount;
}; };
struct MessageBuilder {
class MessageBuilder : public MessageInfo { MessageBuilder( std::string const& macroName,
public: SourceLineInfo const& lineInfo,
MessageBuilder( std::string const& _macroName, ResultWas::OfType type )
SourceLineInfo const& _lineInfo, : m_info( macroName, lineInfo, type )
ResultWas::OfType _type ); {}
MessageInfo build() const;
template<typename T> template<typename T>
MessageBuilder& operator << ( T const& _value ) { MessageBuilder& operator << ( T const& value ) {
stream << _value; m_stream << value;
return *this; return *this;
} }
private:
std::ostringstream stream; MessageInfo m_info;
std::ostringstream m_stream;
}; };
class ScopedMessageBuilder : public MessageBuilder { class ScopedMessage {
public: public:
ScopedMessageBuilder( std::string const& _macroName, ScopedMessage( MessageBuilder const& builder );
SourceLineInfo const& _lineInfo, ~ScopedMessage();
ResultWas::OfType _type );
~ScopedMessageBuilder(); MessageInfo m_info;
}; };
} // end namespace Catch } // end namespace Catch

View File

@ -24,31 +24,17 @@ namespace Catch {
// This may need protecting if threading support is added // This may need protecting if threading support is added
unsigned int MessageInfo::globalCount = 0; unsigned int MessageInfo::globalCount = 0;
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
MessageBuilder::MessageBuilder( std::string const& _macroName, ScopedMessage::ScopedMessage( MessageBuilder const& builder )
SourceLineInfo const& _lineInfo, : m_info( builder.m_info )
ResultWas::OfType _type ) {
: MessageInfo( _macroName, _lineInfo, _type ) m_info.message = builder.m_stream.str();
{} getResultCapture().pushScopedMessage( m_info );
MessageInfo MessageBuilder::build() const {
MessageInfo message = *this;
message.message = stream.str();
return message;
} }
ScopedMessage::~ScopedMessage() {
//////////////////////////////////////////////////////////////////////////// getResultCapture().popScopedMessage( m_info );
ScopedMessageBuilder::ScopedMessageBuilder
( std::string const& _macroName,
SourceLineInfo const& _lineInfo,
ResultWas::OfType _type )
: MessageBuilder( _macroName, _lineInfo, _type )
{}
ScopedMessageBuilder::~ScopedMessageBuilder() {
getResultCapture().popScopedMessage( *this );
} }

View File

@ -154,10 +154,6 @@ namespace Catch {
private: // IResultCapture private: // IResultCapture
virtual void acceptMessage( MessageBuilder const& messageBuilder ) {
m_messages.push_back( messageBuilder.build() );
}
virtual ResultAction::Value acceptExpression( ExpressionResultBuilder const& assertionResult, AssertionInfo const& assertionInfo ) { virtual ResultAction::Value acceptExpression( ExpressionResultBuilder const& assertionResult, AssertionInfo const& assertionInfo ) {
m_lastAssertionInfo = assertionInfo; m_lastAssertionInfo = assertionInfo;
return actOnCurrentResult( assertionResult.buildResult( assertionInfo ) ); return actOnCurrentResult( assertionResult.buildResult( assertionInfo ) );
@ -221,12 +217,12 @@ namespace Catch {
m_messages.clear(); m_messages.clear();
} }
virtual void pushScopedMessage( ScopedMessageBuilder const& _builder ) { virtual void pushScopedMessage( MessageInfo const& message ) {
m_messages.push_back( _builder.build() ); m_messages.push_back( message );
} }
virtual void popScopedMessage( ScopedMessageBuilder const& _builder ) { virtual void popScopedMessage( MessageInfo const& message ) {
m_messages.erase( std::remove( m_messages.begin(), m_messages.end(), _builder ), m_messages.end() ); m_messages.erase( std::remove( m_messages.begin(), m_messages.end(), message ), m_messages.end() );
} }
virtual bool shouldDebugBreak() const { virtual bool shouldDebugBreak() const {

View File

@ -390,10 +390,10 @@ with messages:
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
./mixed/message/info/2 ./mixed/message/info/2
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
MessageTests.cpp:29 MessageTests.cpp:30
............................................................................... ...............................................................................
MessageTests.cpp:37: FAILED: MessageTests.cpp:39: FAILED:
CHECK( a == 1 ) CHECK( a == 1 )
with expansion: with expansion:
2 == 1 2 == 1
@ -401,7 +401,7 @@ with messages:
this message may be logged later this message may be logged later
this message should be logged this message should be logged
MessageTests.cpp:41: FAILED: MessageTests.cpp:43: FAILED:
CHECK( a == 0 ) CHECK( a == 0 )
with expansion: with expansion:
2 == 0 2 == 0
@ -411,10 +411,10 @@ with message:
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
./failing/message/fail ./failing/message/fail
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
MessageTests.cpp:48 MessageTests.cpp:50
............................................................................... ...............................................................................
MessageTests.cpp:51: FAILED: MessageTests.cpp:53: FAILED:
explicitly with message: explicitly with message:
This is a failure This is a failure
@ -422,10 +422,10 @@ explicitly with message:
./failing/message/sections ./failing/message/sections
one one
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
MessageTests.cpp:56 MessageTests.cpp:58
............................................................................... ...............................................................................
MessageTests.cpp:58: FAILED: MessageTests.cpp:60: FAILED:
explicitly with message: explicitly with message:
Message from section one Message from section one
@ -433,10 +433,10 @@ explicitly with message:
./failing/message/sections ./failing/message/sections
two two
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
MessageTests.cpp:61 MessageTests.cpp:63
............................................................................... ...............................................................................
MessageTests.cpp:63: FAILED: MessageTests.cpp:65: FAILED:
explicitly with message: explicitly with message:
Message from section two Message from section two
@ -445,10 +445,10 @@ Message from section two
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
./mixed/message/scoped ./mixed/message/scoped
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
MessageTests.cpp:80 MessageTests.cpp:82
............................................................................... ...............................................................................
MessageTests.cpp:86: FAILED: MessageTests.cpp:88: FAILED:
REQUIRE( i < 10 ) REQUIRE( i < 10 )
with expansion: with expansion:
10 < 10 10 < 10
@ -459,10 +459,10 @@ with messages:
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
just failure just failure
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
MessageTests.cpp:99 MessageTests.cpp:101
............................................................................... ...............................................................................
MessageTests.cpp:101: FAILED: MessageTests.cpp:103: FAILED:
explicitly with message: explicitly with message:
Previous info should not be seen Previous info should not be seen
@ -515,8 +515,7 @@ MiscTests.cpp:111: FAILED:
CHECK( ( fib[i] % 2 ) == 0 ) CHECK( ( fib[i] % 2 ) == 0 )
with expansion: with expansion:
1 == 0 1 == 0
with messages: with message:
Testing if fib[2] (2) is even
Testing if fib[3] (3) is even Testing if fib[3] (3) is even
MiscTests.cpp:111: FAILED: MiscTests.cpp:111: FAILED:
@ -530,8 +529,7 @@ MiscTests.cpp:111: FAILED:
CHECK( ( fib[i] % 2 ) == 0 ) CHECK( ( fib[i] % 2 ) == 0 )
with expansion: with expansion:
1 == 0 1 == 0
with messages: with message:
Testing if fib[5] (8) is even
Testing if fib[6] (13) is even Testing if fib[6] (13) is even
MiscTests.cpp:111: FAILED: MiscTests.cpp:111: FAILED:
@ -2780,10 +2778,10 @@ with messages:
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
./mixed/message/info/2 ./mixed/message/info/2
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
MessageTests.cpp:29 MessageTests.cpp:30
............................................................................... ...............................................................................
MessageTests.cpp:33: MessageTests.cpp:35:
PASSED: PASSED:
CHECK( a == 2 ) CHECK( a == 2 )
with expansion: with expansion:
@ -2791,21 +2789,21 @@ with expansion:
with message: with message:
this message may be logged later this message may be logged later
MessageTests.cpp:37: FAILED: MessageTests.cpp:39: FAILED:
CHECK( a == 1 ) CHECK( a == 1 )
with expansion: with expansion:
2 == 1 2 == 1
with message: with message:
this message should be logged this message should be logged
MessageTests.cpp:41: FAILED: MessageTests.cpp:43: FAILED:
CHECK( a == 0 ) CHECK( a == 0 )
with expansion: with expansion:
2 == 0 2 == 0
with message: with message:
and this, but later and this, but later
MessageTests.cpp:45: MessageTests.cpp:47:
PASSED: PASSED:
CHECK( a == 2 ) CHECK( a == 2 )
with expansion: with expansion:
@ -2816,10 +2814,10 @@ with message:
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
./failing/message/fail ./failing/message/fail
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
MessageTests.cpp:48 MessageTests.cpp:50
............................................................................... ...............................................................................
MessageTests.cpp:51: FAILED: MessageTests.cpp:53: FAILED:
explicitly with message: explicitly with message:
This is a failure This is a failure
@ -2827,10 +2825,10 @@ explicitly with message:
./failing/message/sections ./failing/message/sections
one one
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
MessageTests.cpp:56 MessageTests.cpp:58
............................................................................... ...............................................................................
MessageTests.cpp:58: FAILED: MessageTests.cpp:60: FAILED:
explicitly with message: explicitly with message:
Message from section one Message from section one
@ -2838,10 +2836,10 @@ explicitly with message:
./failing/message/sections ./failing/message/sections
two two
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
MessageTests.cpp:61 MessageTests.cpp:63
............................................................................... ...............................................................................
MessageTests.cpp:63: FAILED: MessageTests.cpp:65: FAILED:
explicitly with message: explicitly with message:
Message from section two Message from section two
@ -2850,7 +2848,7 @@ Message from section one
./succeeding/message/sections/stdout ./succeeding/message/sections/stdout
one one
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
MessageTests.cpp:69 MessageTests.cpp:71
............................................................................... ...............................................................................
@ -2861,7 +2859,7 @@ Message from section two
./succeeding/message/sections/stdout ./succeeding/message/sections/stdout
two two
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
MessageTests.cpp:74 MessageTests.cpp:76
............................................................................... ...............................................................................
@ -2870,10 +2868,10 @@ No assertions in section, 'two'
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
./mixed/message/scoped ./mixed/message/scoped
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
MessageTests.cpp:80 MessageTests.cpp:82
............................................................................... ...............................................................................
MessageTests.cpp:86: MessageTests.cpp:88:
PASSED: PASSED:
REQUIRE( i < 10 ) REQUIRE( i < 10 )
with expansion: with expansion:
@ -2882,7 +2880,7 @@ with messages:
current counter 0 current counter 0
i := 0 i := 0
MessageTests.cpp:86: MessageTests.cpp:88:
PASSED: PASSED:
REQUIRE( i < 10 ) REQUIRE( i < 10 )
with expansion: with expansion:
@ -2891,7 +2889,7 @@ with messages:
current counter 1 current counter 1
i := 1 i := 1
MessageTests.cpp:86: MessageTests.cpp:88:
PASSED: PASSED:
REQUIRE( i < 10 ) REQUIRE( i < 10 )
with expansion: with expansion:
@ -2900,7 +2898,7 @@ with messages:
current counter 2 current counter 2
i := 2 i := 2
MessageTests.cpp:86: MessageTests.cpp:88:
PASSED: PASSED:
REQUIRE( i < 10 ) REQUIRE( i < 10 )
with expansion: with expansion:
@ -2909,7 +2907,7 @@ with messages:
current counter 3 current counter 3
i := 3 i := 3
MessageTests.cpp:86: MessageTests.cpp:88:
PASSED: PASSED:
REQUIRE( i < 10 ) REQUIRE( i < 10 )
with expansion: with expansion:
@ -2918,7 +2916,7 @@ with messages:
current counter 4 current counter 4
i := 4 i := 4
MessageTests.cpp:86: MessageTests.cpp:88:
PASSED: PASSED:
REQUIRE( i < 10 ) REQUIRE( i < 10 )
with expansion: with expansion:
@ -2927,7 +2925,7 @@ with messages:
current counter 5 current counter 5
i := 5 i := 5
MessageTests.cpp:86: MessageTests.cpp:88:
PASSED: PASSED:
REQUIRE( i < 10 ) REQUIRE( i < 10 )
with expansion: with expansion:
@ -2936,7 +2934,7 @@ with messages:
current counter 6 current counter 6
i := 6 i := 6
MessageTests.cpp:86: MessageTests.cpp:88:
PASSED: PASSED:
REQUIRE( i < 10 ) REQUIRE( i < 10 )
with expansion: with expansion:
@ -2945,7 +2943,7 @@ with messages:
current counter 7 current counter 7
i := 7 i := 7
MessageTests.cpp:86: MessageTests.cpp:88:
PASSED: PASSED:
REQUIRE( i < 10 ) REQUIRE( i < 10 )
with expansion: with expansion:
@ -2954,7 +2952,7 @@ with messages:
current counter 8 current counter 8
i := 8 i := 8
MessageTests.cpp:86: MessageTests.cpp:88:
PASSED: PASSED:
REQUIRE( i < 10 ) REQUIRE( i < 10 )
with expansion: with expansion:
@ -2963,7 +2961,7 @@ with messages:
current counter 9 current counter 9
i := 9 i := 9
MessageTests.cpp:86: FAILED: MessageTests.cpp:88: FAILED:
REQUIRE( i < 10 ) REQUIRE( i < 10 )
with expansion: with expansion:
10 < 10 10 < 10
@ -2974,10 +2972,10 @@ with messages:
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
./succeeding/nofail ./succeeding/nofail
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
MessageTests.cpp:90 MessageTests.cpp:92
............................................................................... ...............................................................................
MessageTests.cpp:92: MessageTests.cpp:94:
FAILED - but was ok: FAILED - but was ok:
CHECK_NOFAIL( 1 == 2 ) CHECK_NOFAIL( 1 == 2 )
@ -2987,7 +2985,7 @@ No assertions in test case, './succeeding/nofail'
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
just info just info
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
MessageTests.cpp:95 MessageTests.cpp:97
............................................................................... ...............................................................................
@ -2996,10 +2994,10 @@ No assertions in test case, 'just info'
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
just failure just failure
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
MessageTests.cpp:99 MessageTests.cpp:101
............................................................................... ...............................................................................
MessageTests.cpp:101: FAILED: MessageTests.cpp:103: FAILED:
explicitly with message: explicitly with message:
Previous info should not be seen Previous info should not be seen
@ -6505,29 +6503,29 @@ MessageTests.cpp:26
</testcase> </testcase>
<testcase classname="global" name="./mixed/message/info/2" time="tbd"> <testcase classname="global" name="./mixed/message/info/2" time="tbd">
<info type="INFO"> <info type="INFO">
MessageTests.cpp:35 MessageTests.cpp:37
</info> </info>
<failure message="2 == 1" type="CHECK"> <failure message="2 == 1" type="CHECK">
MessageTests.cpp:37 MessageTests.cpp:39
</failure> </failure>
<info type="INFO"> <info type="INFO">
MessageTests.cpp:39 MessageTests.cpp:41
</info> </info>
<failure message="2 == 0" type="CHECK"> <failure message="2 == 0" type="CHECK">
MessageTests.cpp:41 MessageTests.cpp:43
</failure> </failure>
</testcase> </testcase>
<testcase classname="global" name="./failing/message/fail" time="tbd"> <testcase classname="global" name="./failing/message/fail" time="tbd">
<failure type="FAIL"> <failure type="FAIL">
MessageTests.cpp:51 MessageTests.cpp:53
</failure> </failure>
</testcase> </testcase>
<testcase classname="global" name="./failing/message/sections" time="tbd"> <testcase classname="global" name="./failing/message/sections" time="tbd">
<failure type="FAIL"> <failure type="FAIL">
MessageTests.cpp:58 MessageTests.cpp:60
</failure> </failure>
<failure type="FAIL"> <failure type="FAIL">
MessageTests.cpp:63 MessageTests.cpp:65
</failure> </failure>
</testcase> </testcase>
<testcase classname="global" name="./succeeding/message/sections/stdout" time="tbd"> <testcase classname="global" name="./succeeding/message/sections/stdout" time="tbd">
@ -6537,25 +6535,25 @@ Message from section two
</system-out> </system-out>
</testcase> </testcase>
<testcase classname="global" name="./mixed/message/scoped" time="tbd"> <testcase classname="global" name="./mixed/message/scoped" time="tbd">
<info type="SCOPED_INFO"> <info type="INFO">
MessageTests.cpp:84 MessageTests.cpp:86
</info> </info>
<info type="SCOPED_CAPTURE"> <info type="CAPTURE">
MessageTests.cpp:85 MessageTests.cpp:87
</info> </info>
<failure message="10 &lt; 10" type="REQUIRE"> <failure message="10 &lt; 10" type="REQUIRE">
MessageTests.cpp:86 MessageTests.cpp:88
</failure> </failure>
</testcase> </testcase>
<testcase classname="global" name="./succeeding/nofail" time="tbd"> <testcase classname="global" name="./succeeding/nofail" time="tbd">
<failure message="1 == 2" type="CHECK_NOFAIL"> <failure message="1 == 2" type="CHECK_NOFAIL">
MessageTests.cpp:92 MessageTests.cpp:94
</failure> </failure>
</testcase> </testcase>
<testcase classname="global" name="just info" time="tbd"/> <testcase classname="global" name="just info" time="tbd"/>
<testcase classname="global" name="just failure" time="tbd"> <testcase classname="global" name="just failure" time="tbd">
<failure type="FAIL"> <failure type="FAIL">
MessageTests.cpp:101 MessageTests.cpp:103
</failure> </failure>
</testcase> </testcase>
<testcase classname="global" name="./succeeding/Misc/Sections" time="tbd"/> <testcase classname="global" name="./succeeding/Misc/Sections" time="tbd"/>
@ -9471,7 +9469,7 @@ MessageTests.cpp" line="26">
<OverallResult success="false"/> <OverallResult success="false"/>
</TestCase> </TestCase>
<TestCase name="./mixed/message/info/2"> <TestCase name="./mixed/message/info/2">
MessageTests.cpp" line="33"> MessageTests.cpp" line="35">
<Original> <Original>
a == 2 a == 2
</Original> </Original>
@ -9482,7 +9480,7 @@ MessageTests.cpp" line="33">
<Info> <Info>
this message should be logged this message should be logged
</Info> </Info>
MessageTests.cpp" line="37"> MessageTests.cpp" line="39">
<Original> <Original>
a == 1 a == 1
</Original> </Original>
@ -9493,7 +9491,7 @@ MessageTests.cpp" line="37">
<Info> <Info>
and this, but later and this, but later
</Info> </Info>
MessageTests.cpp" line="41"> MessageTests.cpp" line="43">
<Original> <Original>
a == 0 a == 0
</Original> </Original>
@ -9501,7 +9499,7 @@ MessageTests.cpp" line="41">
2 == 0 2 == 0
</Expanded> </Expanded>
</Expression> </Expression>
MessageTests.cpp" line="45"> MessageTests.cpp" line="47">
<Original> <Original>
a == 2 a == 2
</Original> </Original>
@ -9542,7 +9540,7 @@ MessageTests.cpp" line="45">
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<TestCase name="./mixed/message/scoped"> <TestCase name="./mixed/message/scoped">
MessageTests.cpp" line="86"> MessageTests.cpp" line="88">
<Original> <Original>
i &lt; 10 i &lt; 10
</Original> </Original>
@ -9550,7 +9548,7 @@ MessageTests.cpp" line="86">
0 &lt; 10 0 &lt; 10
</Expanded> </Expanded>
</Expression> </Expression>
MessageTests.cpp" line="86"> MessageTests.cpp" line="88">
<Original> <Original>
i &lt; 10 i &lt; 10
</Original> </Original>
@ -9558,7 +9556,7 @@ MessageTests.cpp" line="86">
1 &lt; 10 1 &lt; 10
</Expanded> </Expanded>
</Expression> </Expression>
MessageTests.cpp" line="86"> MessageTests.cpp" line="88">
<Original> <Original>
i &lt; 10 i &lt; 10
</Original> </Original>
@ -9566,7 +9564,7 @@ MessageTests.cpp" line="86">
2 &lt; 10 2 &lt; 10
</Expanded> </Expanded>
</Expression> </Expression>
MessageTests.cpp" line="86"> MessageTests.cpp" line="88">
<Original> <Original>
i &lt; 10 i &lt; 10
</Original> </Original>
@ -9574,7 +9572,7 @@ MessageTests.cpp" line="86">
3 &lt; 10 3 &lt; 10
</Expanded> </Expanded>
</Expression> </Expression>
MessageTests.cpp" line="86"> MessageTests.cpp" line="88">
<Original> <Original>
i &lt; 10 i &lt; 10
</Original> </Original>
@ -9582,7 +9580,7 @@ MessageTests.cpp" line="86">
4 &lt; 10 4 &lt; 10
</Expanded> </Expanded>
</Expression> </Expression>
MessageTests.cpp" line="86"> MessageTests.cpp" line="88">
<Original> <Original>
i &lt; 10 i &lt; 10
</Original> </Original>
@ -9590,7 +9588,7 @@ MessageTests.cpp" line="86">
5 &lt; 10 5 &lt; 10
</Expanded> </Expanded>
</Expression> </Expression>
MessageTests.cpp" line="86"> MessageTests.cpp" line="88">
<Original> <Original>
i &lt; 10 i &lt; 10
</Original> </Original>
@ -9598,7 +9596,7 @@ MessageTests.cpp" line="86">
6 &lt; 10 6 &lt; 10
</Expanded> </Expanded>
</Expression> </Expression>
MessageTests.cpp" line="86"> MessageTests.cpp" line="88">
<Original> <Original>
i &lt; 10 i &lt; 10
</Original> </Original>
@ -9606,7 +9604,7 @@ MessageTests.cpp" line="86">
7 &lt; 10 7 &lt; 10
</Expanded> </Expanded>
</Expression> </Expression>
MessageTests.cpp" line="86"> MessageTests.cpp" line="88">
<Original> <Original>
i &lt; 10 i &lt; 10
</Original> </Original>
@ -9614,7 +9612,7 @@ MessageTests.cpp" line="86">
8 &lt; 10 8 &lt; 10
</Expanded> </Expanded>
</Expression> </Expression>
MessageTests.cpp" line="86"> MessageTests.cpp" line="88">
<Original> <Original>
i &lt; 10 i &lt; 10
</Original> </Original>
@ -9628,7 +9626,7 @@ MessageTests.cpp" line="86">
<Info> <Info>
i := 10 i := 10
</Info> </Info>
MessageTests.cpp" line="86"> MessageTests.cpp" line="88">
<Original> <Original>
i &lt; 10 i &lt; 10
</Original> </Original>
@ -9639,7 +9637,7 @@ MessageTests.cpp" line="86">
<OverallResult success="false"/> <OverallResult success="false"/>
</TestCase> </TestCase>
<TestCase name="./succeeding/nofail"> <TestCase name="./succeeding/nofail">
MessageTests.cpp" line="92"> MessageTests.cpp" line="94">
<Original> <Original>
1 == 2 1 == 2
</Original> </Original>
@ -13157,25 +13155,25 @@ MessageTests.cpp:26: a == 1 failed for: 2 == 1
[Finished: './failing/message/info/1' 1 test case failed (1 assertion failed)] [Finished: './failing/message/info/1' 1 test case failed (1 assertion failed)]
[Running: ./mixed/message/info/2] [Running: ./mixed/message/info/2]
MessageTests.cpp:33: a == 2 succeeded for: 2 == 2 MessageTests.cpp:35: a == 2 succeeded for: 2 == 2
MessageTests.cpp:35: [info: this message should be logged] MessageTests.cpp:37: [info: this message should be logged]
MessageTests.cpp:37: a == 1 failed for: 2 == 1 MessageTests.cpp:39: a == 1 failed for: 2 == 1
MessageTests.cpp:39: [info: and this, but later] MessageTests.cpp:41: [info: and this, but later]
MessageTests.cpp:41: a == 0 failed for: 2 == 0 MessageTests.cpp:43: a == 0 failed for: 2 == 0
MessageTests.cpp:45: a == 2 succeeded for: 2 == 2 MessageTests.cpp:47: a == 2 succeeded for: 2 == 2
[Finished: './mixed/message/info/2' 1 test case failed (2 of 4 assertions failed)] [Finished: './mixed/message/info/2' 1 test case failed (2 of 4 assertions failed)]
[Running: ./failing/message/fail] [Running: ./failing/message/fail]
MessageTests.cpp:51: failed with message: 'This is a failure' MessageTests.cpp:53: failed with message: 'This is a failure'
[Finished: './failing/message/fail' 1 test case failed (1 assertion failed)] [Finished: './failing/message/fail' 1 test case failed (1 assertion failed)]
[Running: ./failing/message/sections] [Running: ./failing/message/sections]
[Started section: 'one'] [Started section: 'one']
MessageTests.cpp:58: failed with message: 'Message from section one' MessageTests.cpp:60: failed with message: 'Message from section one'
[End of section: 'one' 1 assertion failed] [End of section: 'one' 1 assertion failed]
[Started section: 'two'] [Started section: 'two']
MessageTests.cpp:63: failed with message: 'Message from section two' MessageTests.cpp:65: failed with message: 'Message from section two'
[End of section: 'two' 1 assertion failed] [End of section: 'two' 1 assertion failed]
[Finished: './failing/message/sections' 1 test case failed (All 2 assertions failed)] [Finished: './failing/message/sections' 1 test case failed (All 2 assertions failed)]
@ -13198,23 +13196,23 @@ No assertions in section, 'two'
[Finished: './succeeding/message/sections/stdout' 1 test case failed (All 2 assertions failed)] [Finished: './succeeding/message/sections/stdout' 1 test case failed (All 2 assertions failed)]
[Running: ./mixed/message/scoped] [Running: ./mixed/message/scoped]
MessageTests.cpp:86: i < 10 succeeded for: 0 < 10 MessageTests.cpp:88: i < 10 succeeded for: 0 < 10
MessageTests.cpp:86: i < 10 succeeded for: 1 < 10 MessageTests.cpp:88: i < 10 succeeded for: 1 < 10
MessageTests.cpp:86: i < 10 succeeded for: 2 < 10 MessageTests.cpp:88: i < 10 succeeded for: 2 < 10
MessageTests.cpp:86: i < 10 succeeded for: 3 < 10 MessageTests.cpp:88: i < 10 succeeded for: 3 < 10
MessageTests.cpp:86: i < 10 succeeded for: 4 < 10 MessageTests.cpp:88: i < 10 succeeded for: 4 < 10
MessageTests.cpp:86: i < 10 succeeded for: 5 < 10 MessageTests.cpp:88: i < 10 succeeded for: 5 < 10
MessageTests.cpp:86: i < 10 succeeded for: 6 < 10 MessageTests.cpp:88: i < 10 succeeded for: 6 < 10
MessageTests.cpp:86: i < 10 succeeded for: 7 < 10 MessageTests.cpp:88: i < 10 succeeded for: 7 < 10
MessageTests.cpp:86: i < 10 succeeded for: 8 < 10 MessageTests.cpp:88: i < 10 succeeded for: 8 < 10
MessageTests.cpp:86: i < 10 succeeded for: 9 < 10 MessageTests.cpp:88: i < 10 succeeded for: 9 < 10
MessageTests.cpp:84: [info: current counter 10] MessageTests.cpp:86: [info: current counter 10]
MessageTests.cpp:85: [info: i := 10] MessageTests.cpp:87: [info: i := 10]
MessageTests.cpp:86: i < 10 failed for: 10 < 10 MessageTests.cpp:88: i < 10 failed for: 10 < 10
[Finished: './mixed/message/scoped' 1 test case failed (1 of 11 assertions failed)] [Finished: './mixed/message/scoped' 1 test case failed (1 of 11 assertions failed)]
[Running: ./succeeding/nofail] [Running: ./succeeding/nofail]
MessageTests.cpp:92: 1 == 2 failed - but was ok MessageTests.cpp:94: 1 == 2 failed - but was ok
No assertions in test case, './succeeding/nofail' No assertions in test case, './succeeding/nofail'
@ -13227,7 +13225,7 @@ No assertions in test case, 'just info'
[Finished: 'just info' 1 test case failed (1 assertion failed)] [Finished: 'just info' 1 test case failed (1 assertion failed)]
[Running: just failure] [Running: just failure]
MessageTests.cpp:101: failed with message: 'Previous info should not be seen' MessageTests.cpp:103: failed with message: 'Previous info should not be seen'
[Finished: 'just failure' 1 test case failed (1 assertion failed)] [Finished: 'just failure' 1 test case failed (1 assertion failed)]
[Running: ./succeeding/Misc/Sections] [Running: ./succeeding/Misc/Sections]

View File

@ -1,6 +1,6 @@
/* /*
* CATCH v1.0 build 1 (master branch) * CATCH v1.0 build 1 (master branch)
* Generated: 2013-06-28 14:07:23.869597 * Generated: 2013-06-28 17:08:06.313616
* ---------------------------------------------------------- * ----------------------------------------------------------
* 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.
@ -1294,29 +1294,29 @@ namespace Catch {
static unsigned int globalCount; static unsigned int globalCount;
}; };
class MessageBuilder : public MessageInfo { struct MessageBuilder {
public: MessageBuilder( std::string const& macroName,
MessageBuilder( std::string const& _macroName, SourceLineInfo const& lineInfo,
SourceLineInfo const& _lineInfo, ResultWas::OfType type )
ResultWas::OfType _type ); : m_info( macroName, lineInfo, type )
{}
MessageInfo build() const;
template<typename T> template<typename T>
MessageBuilder& operator << ( T const& _value ) { MessageBuilder& operator << ( T const& value ) {
stream << _value; m_stream << value;
return *this; return *this;
} }
private:
std::ostringstream stream; MessageInfo m_info;
std::ostringstream m_stream;
}; };
class ScopedMessageBuilder : public MessageBuilder { class ScopedMessage {
public: public:
ScopedMessageBuilder( std::string const& _macroName, ScopedMessage( MessageBuilder const& builder );
SourceLineInfo const& _lineInfo, ~ScopedMessage();
ResultWas::OfType _type );
~ScopedMessageBuilder(); MessageInfo m_info;
}; };
} // end namespace Catch } // end namespace Catch
@ -1392,7 +1392,7 @@ namespace Catch {
class AssertionResult; class AssertionResult;
struct AssertionInfo; struct AssertionInfo;
struct SectionInfo; struct SectionInfo;
class MessageBuilder; struct MessageInfo;
class ScopedMessageBuilder; class ScopedMessageBuilder;
struct IResultCapture { struct IResultCapture {
@ -1403,12 +1403,11 @@ namespace Catch {
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 pushScopedMessage( ScopedMessageBuilder const& _builder ) = 0; virtual void pushScopedMessage( MessageInfo const& message ) = 0;
virtual void popScopedMessage( ScopedMessageBuilder const& _builder ) = 0; virtual void popScopedMessage( MessageInfo const& message ) = 0;
virtual bool shouldDebugBreak() const = 0; virtual bool shouldDebugBreak() const = 0;
virtual void acceptMessage( MessageBuilder const& 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;
@ -2358,7 +2357,9 @@ namespace Catch
// !TBD This should have been done earlier, somewhere // !TBD This should have been done earlier, somewhere
MessageBuilder builder( assertionResult.getTestMacroName(), assertionResult.getSourceInfo(), assertionResult.getResultType() ); MessageBuilder builder( assertionResult.getTestMacroName(), assertionResult.getSourceInfo(), assertionResult.getResultType() );
builder << assertionResult.getMessage(); builder << assertionResult.getMessage();
infoMessages.push_back( builder.build() ); builder.m_info.message = builder.m_stream.str();
infoMessages.push_back( builder.m_info );
} }
} }
virtual ~AssertionStats(); virtual ~AssertionStats();
@ -2464,7 +2465,7 @@ namespace Catch
virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0; virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0;
virtual void assertionEnded( AssertionStats const& assertionStats ) = 0; virtual bool assertionEnded( AssertionStats const& assertionStats ) = 0;
virtual void sectionEnded( SectionStats const& sectionStats ) = 0; virtual void sectionEnded( SectionStats const& sectionStats ) = 0;
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0; virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0;
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) = 0; virtual void testGroupEnded( TestGroupStats const& testGroupStats ) = 0;
@ -2747,12 +2748,6 @@ struct TestFailureException{};
} \ } \
} while( Catch::isTrue( false ) ) } while( Catch::isTrue( false ) )
///////////////////////////////////////////////////////////////////////////////
#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 ) \ #define INTERNAL_CATCH_MSG( log, messageType, resultDisposition, macroName ) \
do { \ do { \
@ -2761,10 +2756,8 @@ struct TestFailureException{};
} while( Catch::isTrue( false ) ) } while( Catch::isTrue( false ) )
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_SCOPED_INFO( log, macroName ) \ #define INTERNAL_CATCH_INFO( log, macroName ) \
Catch::ScopedMessageBuilder INTERNAL_CATCH_UNIQUE_NAME( scopedMessage )( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ); \ Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage ) = Catch::MessageBuilder( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log;
INTERNAL_CATCH_UNIQUE_NAME( scopedMessage ) << 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 ) \
@ -4889,10 +4882,6 @@ namespace Catch {
private: // IResultCapture private: // IResultCapture
virtual void acceptMessage( MessageBuilder const& messageBuilder ) {
m_messages.push_back( messageBuilder.build() );
}
virtual ResultAction::Value acceptExpression( ExpressionResultBuilder const& assertionResult, AssertionInfo const& assertionInfo ) { virtual ResultAction::Value acceptExpression( ExpressionResultBuilder const& assertionResult, AssertionInfo const& assertionInfo ) {
m_lastAssertionInfo = assertionInfo; m_lastAssertionInfo = assertionInfo;
return actOnCurrentResult( assertionResult.buildResult( assertionInfo ) ); return actOnCurrentResult( assertionResult.buildResult( assertionInfo ) );
@ -4906,11 +4895,11 @@ namespace Catch {
m_totals.assertions.failed++; m_totals.assertions.failed++;
} }
m_reporter->assertionEnded( AssertionStats( result, m_messages, m_totals ) ); if( m_reporter->assertionEnded( AssertionStats( result, m_messages, m_totals ) ) )
m_messages.clear();
// Reset working state // Reset working state
m_lastAssertionInfo = AssertionInfo( "", m_lastAssertionInfo.lineInfo, "{Unknown expression after the reported 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 (
@ -4955,12 +4944,12 @@ namespace Catch {
m_messages.clear(); m_messages.clear();
} }
virtual void pushScopedMessage( ScopedMessageBuilder const& _builder ) { virtual void pushScopedMessage( MessageInfo const& message ) {
m_messages.push_back( _builder.build() ); m_messages.push_back( message );
} }
virtual void popScopedMessage( ScopedMessageBuilder const& _builder ) { virtual void popScopedMessage( MessageInfo const& message ) {
m_messages.erase( std::remove( m_messages.begin(), m_messages.end(), _builder ), m_messages.end() ); m_messages.erase( std::remove( m_messages.begin(), m_messages.end(), message ), m_messages.end() );
} }
virtual bool shouldDebugBreak() const { virtual bool shouldDebugBreak() const {
@ -6125,7 +6114,7 @@ namespace Catch {
bool isHidden( startsWith( _name, "./" ) ); bool isHidden( startsWith( _name, "./" ) );
std::set<std::string> tags; std::set<std::string> tags;
TagExtracter( tags ).parse( desc ); TagExtracter( tags ).parse( desc );
if( tags.find( "hide" ) != tags.end() ) if( tags.find( "hide" ) != tags.end() || tags.find( "." ) != tags.end() )
isHidden = true; isHidden = true;
TestCaseInfo info( _name, _className, desc, tags, isHidden, _lineInfo ); TestCaseInfo info( _name, _className, desc, tags, isHidden, _lineInfo );
@ -6336,29 +6325,14 @@ namespace Catch {
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
MessageBuilder::MessageBuilder( std::string const& _macroName, ScopedMessage::ScopedMessage( MessageBuilder const& builder )
SourceLineInfo const& _lineInfo, : m_info( builder.m_info )
ResultWas::OfType _type ) {
: MessageInfo( _macroName, _lineInfo, _type ) m_info.message = builder.m_stream.str();
{} getResultCapture().pushScopedMessage( m_info );
MessageInfo MessageBuilder::build() const {
MessageInfo message = *this;
message.message = stream.str();
return message;
} }
ScopedMessage::~ScopedMessage() {
//////////////////////////////////////////////////////////////////////////// getResultCapture().popScopedMessage( m_info );
ScopedMessageBuilder::ScopedMessageBuilder
( std::string const& _macroName,
SourceLineInfo const& _lineInfo,
ResultWas::OfType _type )
: MessageBuilder( _macroName, _lineInfo, _type )
{}
ScopedMessageBuilder::~ScopedMessageBuilder() {
getResultCapture().popScopedMessage( *this );
} }
} // end namespace Catch } // end namespace Catch
@ -6384,7 +6358,7 @@ namespace Catch
virtual void testCaseStarting( TestCaseInfo const& testInfo ); virtual void testCaseStarting( TestCaseInfo const& testInfo );
virtual void sectionStarting( SectionInfo const& sectionInfo ); virtual void sectionStarting( SectionInfo const& sectionInfo );
virtual void assertionStarting( AssertionInfo const& ); virtual void assertionStarting( AssertionInfo const& );
virtual void assertionEnded( AssertionStats const& assertionStats ); virtual bool assertionEnded( AssertionStats const& assertionStats );
virtual void sectionEnded( SectionStats const& sectionStats ); virtual void sectionEnded( SectionStats const& sectionStats );
virtual void testCaseEnded( TestCaseStats const& testCaseStats ); virtual void testCaseEnded( TestCaseStats const& testCaseStats );
virtual void testGroupEnded( TestGroupStats const& testGroupStats ); virtual void testGroupEnded( TestGroupStats const& testGroupStats );
@ -6425,7 +6399,7 @@ namespace Catch
// Not on legacy interface // Not on legacy interface
} }
void LegacyReporterAdapter::assertionEnded( AssertionStats const& assertionStats ) { bool LegacyReporterAdapter::assertionEnded( AssertionStats const& assertionStats ) {
if( assertionStats.assertionResult.getResultType() != ResultWas::Ok ) { if( assertionStats.assertionResult.getResultType() != ResultWas::Ok ) {
for( std::vector<MessageInfo>::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end(); for( std::vector<MessageInfo>::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end();
it != itEnd; it != itEnd;
@ -6440,6 +6414,7 @@ namespace Catch
} }
} }
m_legacyReporter->Result( assertionStats.assertionResult ); m_legacyReporter->Result( assertionStats.assertionResult );
return true;
} }
void LegacyReporterAdapter::sectionEnded( SectionStats const& sectionStats ) { void LegacyReporterAdapter::sectionEnded( SectionStats const& sectionStats ) {
if( sectionStats.missingAssertions ) if( sectionStats.missingAssertions )
@ -7472,18 +7447,19 @@ namespace Catch {
virtual void assertionStarting( AssertionInfo const& ) { virtual void assertionStarting( AssertionInfo const& ) {
} }
virtual void assertionEnded( AssertionStats const& _assertionStats ) { virtual bool assertionEnded( AssertionStats const& _assertionStats ) {
AssertionResult const& result = _assertionStats.assertionResult; AssertionResult const& result = _assertionStats.assertionResult;
// Drop out if result was successful and we're not printing those // Drop out if result was successful and we're not printing those
if( !m_config->includeSuccessfulResults() && result.isOk() ) if( !m_config->includeSuccessfulResults() && result.isOk() )
return; return false;
lazyPrint(); lazyPrint();
AssertionPrinter printer( stream, _assertionStats ); AssertionPrinter printer( stream, _assertionStats );
printer.print(); printer.print();
stream << std::endl; stream << std::endl;
return true;
} }
virtual void sectionStarting( SectionInfo const& _sectionInfo ) { virtual void sectionStarting( SectionInfo const& _sectionInfo ) {
@ -7948,9 +7924,9 @@ int main (int argc, char * const argv[]) {
#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_INFO( msg, "CATCH_INFO" )
#define CATCH_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "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_INFO( #msg " := " << msg, "CATCH_CAPTURE" )
#ifdef CATCH_CONFIG_VARIADIC_MACROS #ifdef CATCH_CONFIG_VARIADIC_MACROS
#define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) #define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
@ -8009,9 +7985,9 @@ int main (int argc, char * const argv[]) {
#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_INFO( msg, "INFO" )
#define CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "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_INFO( #msg " := " << msg, "CAPTURE" )
#ifdef CATCH_CONFIG_VARIADIC_MACROS #ifdef CATCH_CONFIG_VARIADIC_MACROS
#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) #define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )