mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 12:55:40 +02:00
Switched TextColour out for Colour
- Removed TextColour
This commit is contained in:
@@ -73,7 +73,7 @@ namespace Catch {
|
||||
}
|
||||
}
|
||||
else {
|
||||
TextColour colour( TextColour::ResultSuccess );
|
||||
Colour colour( Colour::ResultSuccess );
|
||||
m_config.stream() << allPrefix << "tests passed ("
|
||||
<< pluralise( totals.assertions.passed, "assertion" ) << " in "
|
||||
<< pluralise( totals.testCases.passed, "test case" ) << ")";
|
||||
@@ -130,12 +130,12 @@ namespace Catch {
|
||||
|
||||
virtual void NoAssertionsInSection( const std::string& sectionName ) {
|
||||
startSpansLazily();
|
||||
TextColour colour( TextColour::ResultError );
|
||||
Colour colour( Colour::ResultError );
|
||||
m_config.stream() << "\nNo assertions in section, '" << sectionName << "'\n" << std::endl;
|
||||
}
|
||||
virtual void NoAssertionsInTestCase( const std::string& testName ) {
|
||||
startSpansLazily();
|
||||
TextColour colour( TextColour::ResultError );
|
||||
Colour colour( Colour::ResultError );
|
||||
m_config.stream() << "\nNo assertions in test case, '" << testName << "'\n" << std::endl;
|
||||
}
|
||||
|
||||
@@ -146,11 +146,11 @@ namespace Catch {
|
||||
m_config.stream() << "[End of section: '" << sectionName << "' ";
|
||||
|
||||
if( assertions.failed ) {
|
||||
TextColour colour( TextColour::ResultError );
|
||||
Colour colour( Colour::ResultError );
|
||||
ReportCounts( "assertion", assertions);
|
||||
}
|
||||
else {
|
||||
TextColour colour( TextColour::ResultSuccess );
|
||||
Colour colour( Colour::ResultSuccess );
|
||||
m_config.stream() << ( assertions.passed > 1 ? "All " : "" )
|
||||
<< pluralise( assertions.passed, "assertion" ) << " passed" ;
|
||||
}
|
||||
@@ -166,22 +166,22 @@ namespace Catch {
|
||||
startSpansLazily();
|
||||
|
||||
if( !assertionResult.getSourceInfo().empty() ) {
|
||||
TextColour colour( TextColour::FileName );
|
||||
Colour colour( Colour::FileName );
|
||||
m_config.stream() << assertionResult.getSourceInfo() << ": ";
|
||||
}
|
||||
|
||||
if( assertionResult.hasExpression() ) {
|
||||
TextColour colour( TextColour::OriginalExpression );
|
||||
Colour colour( Colour::OriginalExpression );
|
||||
m_config.stream() << assertionResult.getExpression();
|
||||
if( assertionResult.succeeded() ) {
|
||||
TextColour successColour( TextColour::Success );
|
||||
Colour successColour( Colour::Success );
|
||||
m_config.stream() << " succeeded";
|
||||
}
|
||||
else {
|
||||
TextColour errorColour( TextColour::Error );
|
||||
Colour errorColour( Colour::Error );
|
||||
m_config.stream() << " failed";
|
||||
if( assertionResult.isOk() ) {
|
||||
TextColour okAnywayColour( TextColour::Success );
|
||||
Colour okAnywayColour( Colour::Success );
|
||||
m_config.stream() << " - but was ok";
|
||||
}
|
||||
}
|
||||
@@ -189,7 +189,7 @@ namespace Catch {
|
||||
switch( assertionResult.getResultType() ) {
|
||||
case ResultWas::ThrewException:
|
||||
{
|
||||
TextColour colour( TextColour::Error );
|
||||
Colour colour( Colour::Error );
|
||||
if( assertionResult.hasExpression() )
|
||||
m_config.stream() << " with unexpected";
|
||||
else
|
||||
@@ -199,7 +199,7 @@ namespace Catch {
|
||||
break;
|
||||
case ResultWas::DidntThrowException:
|
||||
{
|
||||
TextColour colour( TextColour::Error );
|
||||
Colour colour( Colour::Error );
|
||||
if( assertionResult.hasExpression() )
|
||||
m_config.stream() << " because no exception was thrown where one was expected";
|
||||
else
|
||||
@@ -208,19 +208,19 @@ namespace Catch {
|
||||
break;
|
||||
case ResultWas::Info:
|
||||
{
|
||||
TextColour colour( TextColour::ReconstructedExpression );
|
||||
Colour colour( Colour::ReconstructedExpression );
|
||||
streamVariableLengthText( "info", assertionResult.getMessage() );
|
||||
}
|
||||
break;
|
||||
case ResultWas::Warning:
|
||||
{
|
||||
TextColour colour( TextColour::ReconstructedExpression );
|
||||
Colour colour( Colour::ReconstructedExpression );
|
||||
streamVariableLengthText( "warning", assertionResult.getMessage() );
|
||||
}
|
||||
break;
|
||||
case ResultWas::ExplicitFailure:
|
||||
{
|
||||
TextColour colour( TextColour::Error );
|
||||
Colour colour( Colour::Error );
|
||||
m_config.stream() << "failed with message: '" << assertionResult.getMessage() << "'";
|
||||
}
|
||||
break;
|
||||
@@ -231,21 +231,21 @@ namespace Catch {
|
||||
case ResultWas::Exception:
|
||||
if( !assertionResult.hasExpression() ) {
|
||||
if( assertionResult.succeeded() ) {
|
||||
TextColour colour( TextColour::Success );
|
||||
Colour colour( Colour::Success );
|
||||
m_config.stream() << " succeeded";
|
||||
}
|
||||
else {
|
||||
TextColour colour( TextColour::Error );
|
||||
Colour colour( Colour::Error );
|
||||
m_config.stream() << " failed";
|
||||
if( assertionResult.isOk() ) {
|
||||
TextColour okAnywayColour( TextColour::Success );
|
||||
Colour okAnywayColour( Colour::Success );
|
||||
m_config.stream() << " - but was ok";
|
||||
}
|
||||
}
|
||||
}
|
||||
if( assertionResult.hasMessage() ) {
|
||||
m_config.stream() << "\n";
|
||||
TextColour colour( TextColour::ReconstructedExpression );
|
||||
Colour colour( Colour::ReconstructedExpression );
|
||||
streamVariableLengthText( "with message", assertionResult.getMessage() );
|
||||
}
|
||||
break;
|
||||
@@ -258,7 +258,7 @@ namespace Catch {
|
||||
if( assertionResult.getExpandedExpression().size() < 70 )
|
||||
m_config.stream() << "\t";
|
||||
}
|
||||
TextColour colour( TextColour::ReconstructedExpression );
|
||||
Colour colour( Colour::ReconstructedExpression );
|
||||
m_config.stream() << assertionResult.getExpandedExpression();
|
||||
}
|
||||
m_config.stream() << std::endl;
|
||||
|
@@ -60,7 +60,7 @@ namespace Catch {
|
||||
virtual void sectionEnded( SectionStats const& _sectionStats ) {
|
||||
if( _sectionStats.missingAssertions ) {
|
||||
lazyPrint();
|
||||
TextColour colour( TextColour::ResultError );
|
||||
Colour colour( Colour::ResultError );
|
||||
stream << "\nNo assertions in section, '" << _sectionStats.sectionInfo.name << "'\n" << std::endl;
|
||||
}
|
||||
m_headerPrinted = false;
|
||||
@@ -71,7 +71,7 @@ namespace Catch {
|
||||
|
||||
if( _testCaseStats.missingAssertions ) {
|
||||
lazyPrint();
|
||||
TextColour colour( TextColour::ResultError );
|
||||
Colour colour( Colour::ResultError );
|
||||
stream << "\nNo assertions in test case, '" << _testCaseStats.testInfo.name << "'\n" << std::endl;
|
||||
}
|
||||
StreamingReporterBase::testCaseEnded( _testCaseStats );
|
||||
@@ -103,13 +103,13 @@ namespace Catch {
|
||||
: stream( _stream ),
|
||||
stats( _stats ),
|
||||
result( _stats.assertionResult ),
|
||||
colour( TextColour::None ),
|
||||
colour( Colour::None ),
|
||||
message( result.getMessage() ),
|
||||
messages( _stats.infoMessages )
|
||||
{
|
||||
switch( result.getResultType() ) {
|
||||
case ResultWas::Ok:
|
||||
colour = TextColour::Success;
|
||||
colour = Colour::Success;
|
||||
passOrFail = "PASSED";
|
||||
//if( result.hasMessage() )
|
||||
if( _stats.infoMessages.size() == 1 )
|
||||
@@ -119,11 +119,11 @@ namespace Catch {
|
||||
break;
|
||||
case ResultWas::ExpressionFailed:
|
||||
if( result.isOk() ) {
|
||||
colour = TextColour::Success;
|
||||
colour = Colour::Success;
|
||||
passOrFail = "FAILED - but was ok";
|
||||
}
|
||||
else {
|
||||
colour = TextColour::Error;
|
||||
colour = Colour::Error;
|
||||
passOrFail = "FAILED";
|
||||
}
|
||||
if( _stats.infoMessages.size() == 1 )
|
||||
@@ -132,12 +132,12 @@ namespace Catch {
|
||||
messageLabel = "with messages";
|
||||
break;
|
||||
case ResultWas::ThrewException:
|
||||
colour = TextColour::Error;
|
||||
colour = Colour::Error;
|
||||
passOrFail = "FAILED";
|
||||
messageLabel = "due to unexpected exception with message";
|
||||
break;
|
||||
case ResultWas::DidntThrowException:
|
||||
colour = TextColour::Error;
|
||||
colour = Colour::Error;
|
||||
passOrFail = "FAILED";
|
||||
messageLabel = "because no exception was thrown where one was expected";
|
||||
break;
|
||||
@@ -149,7 +149,7 @@ namespace Catch {
|
||||
break;
|
||||
case ResultWas::ExplicitFailure:
|
||||
passOrFail = "FAILED";
|
||||
colour = TextColour::Error;
|
||||
colour = Colour::Error;
|
||||
if( _stats.infoMessages.size() == 1 )
|
||||
messageLabel = "explicitly with message";
|
||||
if( _stats.infoMessages.size() > 1 )
|
||||
@@ -157,7 +157,7 @@ namespace Catch {
|
||||
break;
|
||||
case ResultWas::Exception:
|
||||
passOrFail = "FAILED";
|
||||
colour = TextColour::Error;
|
||||
colour = Colour::Error;
|
||||
if( _stats.infoMessages.size() == 1 )
|
||||
messageLabel = "with message";
|
||||
if( _stats.infoMessages.size() > 1 )
|
||||
@@ -168,7 +168,7 @@ namespace Catch {
|
||||
case ResultWas::Unknown:
|
||||
case ResultWas::FailureBit:
|
||||
passOrFail = "** internal error **";
|
||||
colour = TextColour::Error;
|
||||
colour = Colour::Error;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -191,13 +191,13 @@ namespace Catch {
|
||||
private:
|
||||
void printResultType() const {
|
||||
if( !passOrFail.empty() ) {
|
||||
TextColour colourGuard( colour );
|
||||
Colour colourGuard( colour );
|
||||
stream << passOrFail << ":\n";
|
||||
}
|
||||
}
|
||||
void printOriginalExpression() const {
|
||||
if( result.hasExpression() ) {
|
||||
TextColour colourGuard( TextColour::OriginalExpression );
|
||||
Colour colourGuard( Colour::OriginalExpression );
|
||||
stream << " ";
|
||||
if( !result.getTestMacroName().empty() )
|
||||
stream << result.getTestMacroName() << "( ";
|
||||
@@ -210,7 +210,7 @@ namespace Catch {
|
||||
void printReconstructedExpression() const {
|
||||
if( result.hasExpandedExpression() ) {
|
||||
stream << "with expansion:\n";
|
||||
TextColour colourGuard( TextColour::ReconstructedExpression );
|
||||
Colour colourGuard( Colour::ReconstructedExpression );
|
||||
stream << LineWrapper().setIndent(2).wrap( result.getExpandedExpression() ) << "\n";
|
||||
}
|
||||
}
|
||||
@@ -224,14 +224,14 @@ namespace Catch {
|
||||
}
|
||||
}
|
||||
void printSourceInfo() const {
|
||||
TextColour colourGuard( TextColour::FileName );
|
||||
Colour colourGuard( Colour::FileName );
|
||||
stream << result.getSourceInfo() << ": ";
|
||||
}
|
||||
|
||||
std::ostream& stream;
|
||||
AssertionStats const& stats;
|
||||
AssertionResult const& result;
|
||||
TextColour::Colours colour;
|
||||
Colour::Code colour;
|
||||
std::string passOrFail;
|
||||
std::string messageLabel;
|
||||
std::string message;
|
||||
@@ -253,7 +253,7 @@ namespace Catch {
|
||||
}
|
||||
void lazyPrintRunInfo() {
|
||||
stream << "\n" << getTildes() << "\n";
|
||||
TextColour colour( TextColour::SecondaryText );
|
||||
Colour colour( Colour::SecondaryText );
|
||||
stream << testRunInfo->name
|
||||
<< " is a CATCH v" << libraryVersion.majorVersion << "."
|
||||
<< libraryVersion.minorVersion << " b"
|
||||
@@ -277,7 +277,7 @@ namespace Catch {
|
||||
? currentSectionInfo->lineInfo
|
||||
: unusedTestCaseInfo->lineInfo );
|
||||
if( currentSectionInfo ) {
|
||||
TextColour colourGuard( TextColour::Headers );
|
||||
Colour colourGuard( Colour::Headers );
|
||||
std::vector<ThreadedSectionInfo*> sections;
|
||||
for( ThreadedSectionInfo* section = currentSectionInfo.get();
|
||||
section;
|
||||
@@ -301,11 +301,11 @@ namespace Catch {
|
||||
void printOpenHeader( std::string const& _name, SourceLineInfo const& _lineInfo = SourceLineInfo() ) {
|
||||
stream << getDashes() << "\n";
|
||||
if( !_lineInfo.empty() ){
|
||||
TextColour colourGuard( TextColour::FileName );
|
||||
Colour colourGuard( Colour::FileName );
|
||||
stream << _lineInfo << "\n\n";
|
||||
}
|
||||
{
|
||||
TextColour colourGuard( TextColour::Headers );
|
||||
Colour colourGuard( Colour::Headers );
|
||||
stream << _name << "\n";
|
||||
}
|
||||
}
|
||||
@@ -315,7 +315,7 @@ namespace Catch {
|
||||
stream << "No tests ran";
|
||||
}
|
||||
else if( totals.assertions.failed ) {
|
||||
TextColour colour( TextColour::ResultError );
|
||||
Colour colour( Colour::ResultError );
|
||||
printCounts( "test case", totals.testCases );
|
||||
if( totals.testCases.failed > 0 ) {
|
||||
stream << " (";
|
||||
@@ -324,7 +324,7 @@ namespace Catch {
|
||||
}
|
||||
}
|
||||
else {
|
||||
TextColour colour( TextColour::ResultSuccess );
|
||||
Colour colour( Colour::ResultSuccess );
|
||||
stream << "All tests passed ("
|
||||
<< pluralise( totals.assertions.passed, "assertion" ) << " in "
|
||||
<< pluralise( totals.testCases.passed, "test case" ) << ")";
|
||||
|
Reference in New Issue
Block a user