mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-23 05:46:11 +01:00
More console reporter tweaks - mostly newlines
This commit is contained in:
parent
42aef1d99c
commit
bb76e47704
@ -127,16 +127,19 @@ namespace Catch {
|
|||||||
stream << result.getSourceInfo() << ":\n";
|
stream << result.getSourceInfo() << ":\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool endsWithNewLine = false;
|
||||||
if( _assertionStats.totals.assertions.total() > 0 ) {
|
if( _assertionStats.totals.assertions.total() > 0 ) {
|
||||||
printOriginalExpression( result );
|
endsWithNewLine = printOriginalExpression( result );
|
||||||
printResultType( result );
|
endsWithNewLine = printResultType( result );
|
||||||
printReconstructedExpression( result );
|
endsWithNewLine |= printReconstructedExpression( result );
|
||||||
}
|
}
|
||||||
printMessage( result );
|
endsWithNewLine |= printMessage( result );
|
||||||
|
if( !endsWithNewLine )
|
||||||
|
stream << "\n";
|
||||||
stream << std::endl;
|
stream << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printResultType( AssertionResult const& _result ) {
|
bool printResultType( AssertionResult const& _result ) {
|
||||||
if( _result.succeeded() ) {
|
if( _result.succeeded() ) {
|
||||||
TextColour successColour( TextColour::Success );
|
TextColour successColour( TextColour::Success );
|
||||||
stream << "passed";
|
stream << "passed";
|
||||||
@ -149,14 +152,43 @@ namespace Catch {
|
|||||||
TextColour errorColour( TextColour::Error );
|
TextColour errorColour( TextColour::Error );
|
||||||
stream << "failed";
|
stream << "failed";
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
bool printOriginalExpression( AssertionResult const& _result ) {
|
||||||
void printMessage( AssertionResult const& _result ) {
|
if( _result.hasExpression() ) {
|
||||||
|
TextColour colour( TextColour::OriginalExpression );
|
||||||
|
stream << " ";
|
||||||
|
if( !_result.getTestMacroName().empty() )
|
||||||
|
stream << _result.getTestMacroName() << "( ";
|
||||||
|
stream << _result.getExpression();
|
||||||
|
if( !_result.getTestMacroName().empty() )
|
||||||
|
stream << " )";
|
||||||
|
stream << "\n";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool printReconstructedExpression( AssertionResult const& _result ) {
|
||||||
|
if( _result.hasExpandedExpression() ) {
|
||||||
|
stream << " with expansion:\n";
|
||||||
|
TextColour colour( TextColour::ReconstructedExpression );
|
||||||
|
stream << wrapLongStrings( _result.getExpandedExpression() ) << "\n";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool printMessage( AssertionResult const& _result ) {
|
||||||
std::pair<std::string, std::string> message = getMessage( _result );
|
std::pair<std::string, std::string> message = getMessage( _result );
|
||||||
if( !message.first.empty() )
|
bool endsWithNewLine = false;
|
||||||
stream << " " << message.first << ":\n";
|
if( !message.first.empty() ) {
|
||||||
if( !message.second.empty() )
|
stream << " " << message.first << ":" << "\n";
|
||||||
printWrappableString( message.second );
|
endsWithNewLine = true;
|
||||||
|
}
|
||||||
|
if( !message.second.empty() ) {
|
||||||
|
stream << wrapLongStrings( message.second ) << "\n";
|
||||||
|
endsWithNewLine = true;
|
||||||
|
}
|
||||||
|
return endsWithNewLine;
|
||||||
}
|
}
|
||||||
std::pair<std::string, std::string> getMessage( AssertionResult const& _result ) {
|
std::pair<std::string, std::string> getMessage( AssertionResult const& _result ) {
|
||||||
switch( _result.getResultType() ) {
|
switch( _result.getResultType() ) {
|
||||||
@ -182,25 +214,6 @@ namespace Catch {
|
|||||||
return std::make_pair( "", "" );
|
return std::make_pair( "", "" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void printOriginalExpression( AssertionResult const& _result ) {
|
|
||||||
if( _result.hasExpression() ) {
|
|
||||||
TextColour colour( TextColour::OriginalExpression );
|
|
||||||
stream << " " << _result.getTestMacroName() << "( "
|
|
||||||
<< _result.getExpression()
|
|
||||||
<< " )\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void printReconstructedExpression( AssertionResult const& _result ) {
|
|
||||||
if( _result.hasExpandedExpression() ) {
|
|
||||||
stream << " with expansion:\n";
|
|
||||||
TextColour colour( TextColour::ReconstructedExpression );
|
|
||||||
printWrappableString( _result.getExpandedExpression() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void printWrappableString( std::string const& _string ) {
|
|
||||||
stream << wrapLongStrings( _string ) << "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string wrapLongStrings( std::string const& _string ) {
|
std::string wrapLongStrings( std::string const& _string ) {
|
||||||
return Catch::wrapLongStrings( _string, 70, 2 );
|
return Catch::wrapLongStrings( _string, 70, 2 );
|
||||||
|
Loading…
Reference in New Issue
Block a user