mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 07:16:10 +01:00
Added SCOPED_CAPTURE
This commit is contained in:
parent
36d0da0194
commit
803f6b7e4b
@ -73,6 +73,7 @@
|
||||
#define CATCH_SUCCEED( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Ok, false, "CATCH_SUCCEED" )
|
||||
#define CATCH_SCOPED_INFO( msg ) INTERNAL_CATCH_SCOPED_INFO( msg )
|
||||
#define CATCH_CAPTURE( msg ) INTERNAL_CATCH_MSG( #msg " := " << msg, Catch::ResultWas::Info, false, "CATCH_CAPTURE" )
|
||||
#define CATCH_SCOPED_CAPTURE( msg ) INTERNAL_CATCH_SCOPED_INFO( #msg " := " << msg )
|
||||
|
||||
#define CATCH_SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
|
||||
|
||||
@ -117,6 +118,7 @@
|
||||
#define SUCCEED( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Ok, false, "SUCCEED" )
|
||||
#define SCOPED_INFO( msg ) INTERNAL_CATCH_SCOPED_INFO( msg )
|
||||
#define CAPTURE( msg ) INTERNAL_CATCH_MSG( #msg " := " << msg, Catch::ResultWas::Info, false, "CAPTURE" )
|
||||
#define SCOPED_CAPTURE( msg ) INTERNAL_CATCH_SCOPED_INFO( #msg " := " << msg )
|
||||
|
||||
#define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
|
||||
|
||||
|
@ -77,6 +77,7 @@ TEST_CASE( "./mixed/message/scoped", "" )
|
||||
for( int i=0; i<100; i++ )
|
||||
{
|
||||
SCOPED_INFO( "current counter " << i );
|
||||
SCOPED_CAPTURE( i );
|
||||
REQUIRE( i < 10 );
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Generated: 2012-09-29 20:53:48.580228
|
||||
* Generated: 2012-10-04 08:14:09.958803
|
||||
* ----------------------------------------------------------
|
||||
* This file has been merged from multiple headers. Please don't edit it directly
|
||||
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
|
||||
@ -681,12 +681,6 @@ namespace Catch {
|
||||
class ResultInfo {
|
||||
public:
|
||||
ResultInfo();
|
||||
ResultInfo( const char* expr,
|
||||
ResultWas::OfType result,
|
||||
bool isNot,
|
||||
const SourceLineInfo& lineInfo,
|
||||
const char* macroName,
|
||||
const char* message );
|
||||
~ResultInfo();
|
||||
|
||||
bool ok() const;
|
||||
@ -702,6 +696,12 @@ namespace Catch {
|
||||
std::string getTestMacroName() const;
|
||||
|
||||
protected:
|
||||
ResultInfo( const char* expr,
|
||||
ResultWas::OfType result,
|
||||
bool isNot,
|
||||
const SourceLineInfo& lineInfo,
|
||||
const char* macroName,
|
||||
const char* message );
|
||||
|
||||
std::string getExpandedExpressionInternal() const;
|
||||
bool isNotExpression( const char* expr );
|
||||
@ -887,37 +887,31 @@ namespace Catch {
|
||||
struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison;
|
||||
|
||||
class ResultInfoBuilder : public ResultInfo {
|
||||
|
||||
public:
|
||||
|
||||
ResultInfoBuilder();
|
||||
|
||||
ResultInfoBuilder& setResultType( ResultWas::OfType result );
|
||||
ResultInfoBuilder& setMessage( const std::string& message );
|
||||
ResultInfoBuilder& setLineInfo( const SourceLineInfo& lineInfo );
|
||||
ResultInfoBuilder& setLhs( const std::string& lhs );
|
||||
ResultInfoBuilder& setRhs( const std::string& rhs );
|
||||
ResultInfoBuilder& setOp( const std::string& op );
|
||||
ResultInfoBuilder& setMacroName( const std::string& macroName );
|
||||
|
||||
template<typename RhsT>
|
||||
STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator || ( const RhsT& );
|
||||
|
||||
template<typename RhsT>
|
||||
STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator && ( const RhsT& );
|
||||
|
||||
private:
|
||||
|
||||
ResultInfoBuilder( const char* expr,
|
||||
bool isNot,
|
||||
const SourceLineInfo& lineInfo,
|
||||
const char* macroName,
|
||||
const char* message = "" );
|
||||
const char* macroName );
|
||||
|
||||
void setResultType( ResultWas::OfType result );
|
||||
void setMessage( const std::string& message );
|
||||
void setLineInfo( const SourceLineInfo& lineInfo );
|
||||
void setLhs( const std::string& lhs );
|
||||
void setRhs( const std::string& rhs );
|
||||
void setOp( const std::string& op );
|
||||
|
||||
template<typename RhsT>
|
||||
STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator ||
|
||||
(
|
||||
const RhsT&
|
||||
);
|
||||
|
||||
template<typename RhsT>
|
||||
STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator &&
|
||||
(
|
||||
const RhsT&
|
||||
);
|
||||
|
||||
private:
|
||||
friend class ExpressionBuilder;
|
||||
template<typename T> friend class Expression;
|
||||
|
||||
@ -1310,7 +1304,10 @@ public:
|
||||
}
|
||||
|
||||
ResultInfo getInfo () const {
|
||||
return ResultInfo( "", ResultWas::Info, false, SourceLineInfo(), "SCOPED_INFO", m_oss.str().c_str() );
|
||||
return ResultInfoBuilder()
|
||||
.setResultType( ResultWas::Info )
|
||||
.setMessage( m_oss.str() )
|
||||
.setMacroName( "SCOPED_INFO" );
|
||||
}
|
||||
|
||||
private:
|
||||
@ -1791,14 +1788,6 @@ namespace Catch {
|
||||
m_tags.insert( std::make_pair( tag.getName(), tag ) );
|
||||
}
|
||||
|
||||
// needed?
|
||||
Tag find( const std::string& name ) const {
|
||||
TagMap::const_iterator it = m_tags.find( name );
|
||||
if( it == m_tags.end() )
|
||||
return Tag();
|
||||
else
|
||||
return it->second;
|
||||
}
|
||||
bool empty() const {
|
||||
return m_tags.empty();
|
||||
}
|
||||
@ -4911,7 +4900,7 @@ namespace Catch {
|
||||
m_isNot( isNot )
|
||||
{
|
||||
if( isNot )
|
||||
m_expr = "!" + m_expr;
|
||||
m_expr = "!(" + m_expr + ")";
|
||||
}
|
||||
|
||||
ResultInfo::~ResultInfo() {}
|
||||
@ -4989,17 +4978,16 @@ namespace Catch {
|
||||
|
||||
namespace Catch {
|
||||
|
||||
ResultInfoBuilder::ResultInfoBuilder() {}
|
||||
|
||||
ResultInfoBuilder::ResultInfoBuilder( const char* expr,
|
||||
bool isNot,
|
||||
const SourceLineInfo& lineInfo,
|
||||
const char* macroName,
|
||||
const char* message )
|
||||
: ResultInfo( expr, ResultWas::Unknown, isNot, lineInfo, macroName, message )
|
||||
const char* macroName )
|
||||
: ResultInfo( expr, ResultWas::Unknown, isNot, lineInfo, macroName, "" )
|
||||
{}
|
||||
|
||||
void ResultInfoBuilder::setResultType( ResultWas::OfType result ) {
|
||||
ResultInfoBuilder::ResultInfoBuilder() {}
|
||||
|
||||
ResultInfoBuilder& ResultInfoBuilder::setResultType( ResultWas::OfType result ) {
|
||||
// Flip bool results if isNot is set
|
||||
if( m_isNot && result == ResultWas::Ok )
|
||||
m_result = ResultWas::ExpressionFailed;
|
||||
@ -5007,26 +4995,37 @@ namespace Catch {
|
||||
m_result = ResultWas::Ok;
|
||||
else
|
||||
m_result = result;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void ResultInfoBuilder::setMessage( const std::string& message ) {
|
||||
ResultInfoBuilder& ResultInfoBuilder::setMessage( const std::string& message ) {
|
||||
m_message = message;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void ResultInfoBuilder::setLineInfo( const SourceLineInfo& lineInfo ) {
|
||||
ResultInfoBuilder& ResultInfoBuilder::setLineInfo( const SourceLineInfo& lineInfo ) {
|
||||
m_lineInfo = lineInfo;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void ResultInfoBuilder::setLhs( const std::string& lhs ) {
|
||||
ResultInfoBuilder& ResultInfoBuilder::setLhs( const std::string& lhs ) {
|
||||
m_lhs = lhs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void ResultInfoBuilder::setRhs( const std::string& rhs ) {
|
||||
ResultInfoBuilder& ResultInfoBuilder::setRhs( const std::string& rhs ) {
|
||||
m_rhs = rhs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void ResultInfoBuilder::setOp( const std::string& op ) {
|
||||
ResultInfoBuilder& ResultInfoBuilder::setOp( const std::string& op ) {
|
||||
m_op = op;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ResultInfoBuilder& ResultInfoBuilder::setMacroName( const std::string& macroName ) {
|
||||
m_macroName = macroName;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ResultInfoBuilder& ResultInfoBuilder::captureBoolExpression( bool result ) {
|
||||
@ -6139,6 +6138,7 @@ int main (int argc, char * const argv[]) {
|
||||
#define CATCH_SUCCEED( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Ok, false, "CATCH_SUCCEED" )
|
||||
#define CATCH_SCOPED_INFO( msg ) INTERNAL_CATCH_SCOPED_INFO( msg )
|
||||
#define CATCH_CAPTURE( msg ) INTERNAL_CATCH_MSG( #msg " := " << msg, Catch::ResultWas::Info, false, "CATCH_CAPTURE" )
|
||||
#define CATCH_SCOPED_CAPTURE( msg ) INTERNAL_CATCH_SCOPED_INFO( #msg " := " << msg )
|
||||
|
||||
#define CATCH_SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
|
||||
|
||||
@ -6183,6 +6183,7 @@ int main (int argc, char * const argv[]) {
|
||||
#define SUCCEED( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Ok, false, "SUCCEED" )
|
||||
#define SCOPED_INFO( msg ) INTERNAL_CATCH_SCOPED_INFO( msg )
|
||||
#define CAPTURE( msg ) INTERNAL_CATCH_MSG( #msg " := " << msg, Catch::ResultWas::Info, false, "CAPTURE" )
|
||||
#define SCOPED_CAPTURE( msg ) INTERNAL_CATCH_SCOPED_INFO( #msg " := " << msg )
|
||||
|
||||
#define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user