Switched TextColour out for Colour

- Removed TextColour
This commit is contained in:
Phil Nash 2013-04-05 07:59:28 +01:00
parent a3703faa0a
commit f186a912d4
5 changed files with 57 additions and 198 deletions

View File

@ -36,7 +36,7 @@ namespace Catch {
BrightWhite = Bright | White, BrightWhite = Bright | White,
// By intention // By intention
FileName = Grey, FileName = LightGrey,
ResultError = BrightRed, ResultError = BrightRed,
ResultSuccess = BrightGreen, ResultSuccess = BrightGreen,
@ -46,49 +46,21 @@ namespace Catch {
OriginalExpression = Cyan, OriginalExpression = Cyan,
ReconstructedExpression = Yellow, ReconstructedExpression = Yellow,
SecondaryText = Grey, SecondaryText = LightGrey,
Headers = White Headers = White
}; };
// Use constructed object for RAII guard
Colour( Code _colourCode ); Colour( Code _colourCode );
~Colour(); ~Colour();
// Use static method for one-shot changes
static void use( Code _colourCode ); static void use( Code _colourCode );
private: private:
static Detail::IColourImpl* impl; static Detail::IColourImpl* impl;
}; };
struct IConsoleColourCodes : NonCopyable {
enum Colours {
None,
FileName,
ResultError,
ResultSuccess,
Error,
Success,
OriginalExpression,
ReconstructedExpression,
SecondaryText,
Headers
};
virtual void set( Colours colour ) = 0;
};
class TextColour : public IConsoleColourCodes {
public:
TextColour( Colours colour = None );
void set( Colours colour );
~TextColour();
private:
IConsoleColourCodes* m_impl;
};
} // end namespace Catch } // end namespace Catch
#endif // TWOBLUECUBES_CATCH_CONSOLE_COLOUR_HPP_INCLUDED #endif // TWOBLUECUBES_CATCH_CONSOLE_COLOUR_HPP_INCLUDED

View File

@ -64,60 +64,10 @@ namespace {
WORD originalAttributes; WORD originalAttributes;
}; };
WORD mapConsoleColour( IConsoleColourCodes::Colours colour ) {
enum Win32Colours {
Grey = FOREGROUND_INTENSITY,
BrightRed = FOREGROUND_RED | FOREGROUND_INTENSITY,
BrightGreen = FOREGROUND_GREEN | FOREGROUND_INTENSITY,
BrightWhite = FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY,
DarkGreen = FOREGROUND_GREEN,
Cyan = FOREGROUND_BLUE | FOREGROUND_GREEN,
Yellow = FOREGROUND_RED | FOREGROUND_GREEN
};
switch( colour ) {
case IConsoleColourCodes::FileName: return Grey;
case IConsoleColourCodes::ResultError: return BrightRed;
case IConsoleColourCodes::ResultSuccess: return BrightGreen;
case IConsoleColourCodes::Error: return BrightRed;
case IConsoleColourCodes::Success: return DarkGreen;
case IConsoleColourCodes::OriginalExpression: return Cyan;
case IConsoleColourCodes::ReconstructedExpression: return Yellow;
case IConsoleColourCodes::SecondaryText: return Grey;
case IConsoleColourCodes::Headers: return 0;
default: return 0;
}
}
struct WindowsConsoleColourCodes : IConsoleColourCodes {
WindowsConsoleColourCodes()
: hStdout( GetStdHandle(STD_OUTPUT_HANDLE) ),
wOldColorAttrs( 0 )
{
GetConsoleScreenBufferInfo( hStdout, &csbiInfo );
wOldColorAttrs = csbiInfo.wAttributes;
}
~WindowsConsoleColourCodes() {
SetConsoleTextAttribute( hStdout, wOldColorAttrs );
}
void set( Colours colour ) {
WORD consoleColour = mapConsoleColour( colour );
if( consoleColour > 0 )
SetConsoleTextAttribute( hStdout, consoleColour );
}
HANDLE hStdout;
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
WORD wOldColorAttrs;
};
inline bool shouldUseColourForPlatform() { inline bool shouldUseColourForPlatform() {
return true; return true;
} }
typedef WindowsConsoleColourCodes PlatformConsoleColourCodes;
Win32ColourImpl platformColourImpl; Win32ColourImpl platformColourImpl;
} // end anon namespace } // end anon namespace
@ -130,6 +80,10 @@ namespace {
namespace Catch { namespace Catch {
namespace { namespace {
// use POSIX/ ANSI console terminal codes
// Thanks to Adam Strzelecki for original contribution
// (http://github.com/nanoant)
// https://github.com/philsquared/Catch/pull/131
class PosixColourImpl : public Detail::IColourImpl { class PosixColourImpl : public Detail::IColourImpl {
public: public:
PosixColourImpl() { PosixColourImpl() {
@ -161,51 +115,10 @@ namespace {
} }
}; };
// use POSIX/ ANSI console terminal codes
// Implementation contributed by Adam Strzelecki (http://github.com/nanoant)
// https://github.com/philsquared/Catch/pull/131
const char* WhiteOrNormal = "[0m";
const char* BrightRed = "[1;31m";
const char* BrightGreen = "[1;32m";
// const char* BrightWhite = "[1;37m";
const char* Green = "[0;32m";
const char* Cyan = "[0;36m";
const char* Yellow = "[0;33m";
const char* LightGrey = "[0;37m";
// const char* DarkGrey = "[1;30m";
struct AnsiConsoleColourCodes : IConsoleColourCodes {
~AnsiConsoleColourCodes() {
set( None );
}
const char* escapeCodeForColour( Colours colour ) {
switch( colour ) {
case FileName: return WhiteOrNormal;
case ResultError: return BrightRed;
case ResultSuccess: return BrightGreen;
case Error: return BrightRed;
case Success: return Green;
case OriginalExpression: return Cyan;
case ReconstructedExpression: return Yellow;
case SecondaryText: return LightGrey;
case Headers: return WhiteOrNormal;
case None: return WhiteOrNormal;
}
}
void set( Colours colour ) {
std::cout << '\033' << escapeCodeForColour( colour );
}
};
inline bool shouldUseColourForPlatform() { inline bool shouldUseColourForPlatform() {
return isatty( fileno(stdout) ); return isatty( fileno(stdout) );
} }
typedef AnsiConsoleColourCodes PlatformConsoleColourCodes;
PosixColourImpl platformColourImpl; PosixColourImpl platformColourImpl;
} // end anon namespace } // end anon namespace
@ -213,12 +126,6 @@ namespace {
#endif // not Windows #endif // not Windows
namespace {
struct NoConsoleColourCodes : Catch::IConsoleColourCodes {
void set( Colours ) {}
};
}
namespace Catch { namespace Catch {
namespace { namespace {
@ -240,26 +147,6 @@ namespace Catch {
? static_cast<Detail::IColourImpl*>( &platformColourImpl ) ? static_cast<Detail::IColourImpl*>( &platformColourImpl )
: static_cast<Detail::IColourImpl*>( &noColourImpl ); : static_cast<Detail::IColourImpl*>( &noColourImpl );
TextColour::TextColour( Colours colour ) : m_impl( NULL ) {
static bool s_shouldUseColour = shouldUseColourForPlatform() &&
!isDebuggerActive();
if( s_shouldUseColour )
m_impl = new PlatformConsoleColourCodes();
else
m_impl = new NoConsoleColourCodes();
if( colour )
set( colour );
}
TextColour::~TextColour() {
delete m_impl;
}
void TextColour::set( Colours colour ) {
m_impl->set( colour );
}
} // end namespace Catch } // end namespace Catch
#endif // TWOBLUECUBES_CATCH_CONSOLE_COLOUR_IMPL_HPP_INCLUDED #endif // TWOBLUECUBES_CATCH_CONSOLE_COLOUR_IMPL_HPP_INCLUDED

View File

@ -64,25 +64,25 @@ namespace Catch {
tagsWrapper.setRight( maxTagLen ).wrap( it->getTestCaseInfo().tagsAsString ); tagsWrapper.setRight( maxTagLen ).wrap( it->getTestCaseInfo().tagsAsString );
for( std::size_t i = 0; i < std::max( nameWrapper.size(), tagsWrapper.size() ); ++i ) { for( std::size_t i = 0; i < std::max( nameWrapper.size(), tagsWrapper.size() ); ++i ) {
TextColour::Colours colour = TextColour::None; Colour::Code colour = Colour::None;
if( it->getTestCaseInfo().isHidden ) if( it->getTestCaseInfo().isHidden )
colour = TextColour::SecondaryText; colour = Colour::SecondaryText;
std::string nameCol; std::string nameCol;
if( i < nameWrapper.size() ) { if( i < nameWrapper.size() ) {
nameCol = nameWrapper[i]; nameCol = nameWrapper[i];
} }
else { else {
nameCol = " ..."; nameCol = " ...";
colour = TextColour::SecondaryText; colour = Colour::SecondaryText;
} }
{ {
TextColour colourGuard( colour ); Colour colourGuard( colour );
std::cout << nameCol; std::cout << nameCol;
} }
if( i < tagsWrapper.size() && !tagsWrapper[i].empty() ) { if( i < tagsWrapper.size() && !tagsWrapper[i].empty() ) {
if( i == 0 ) { if( i == 0 ) {
TextColour colourGuard( TextColour::SecondaryText ); Colour colourGuard( Colour::SecondaryText );
std::cout << " " << std::string( maxNameLen - nameCol.size(), '.' ) << " "; std::cout << " " << std::string( maxNameLen - nameCol.size(), '.' ) << " ";
} }
else { else {
@ -143,7 +143,7 @@ namespace Catch {
if( maxTagLen > wrapper.last().size() ) if( maxTagLen > wrapper.last().size() )
dots += maxTagLen - wrapper.last().size(); dots += maxTagLen - wrapper.last().size();
{ {
TextColour colourGuard( TextColour::SecondaryText ); Colour colourGuard( Colour::SecondaryText );
std::cout << std::string( dots, '.' ); std::cout << std::string( dots, '.' );
} }
std::cout << countIt->second std::cout << countIt->second

View File

@ -73,7 +73,7 @@ namespace Catch {
} }
} }
else { else {
TextColour colour( TextColour::ResultSuccess ); Colour colour( Colour::ResultSuccess );
m_config.stream() << allPrefix << "tests passed (" m_config.stream() << allPrefix << "tests passed ("
<< pluralise( totals.assertions.passed, "assertion" ) << " in " << pluralise( totals.assertions.passed, "assertion" ) << " in "
<< pluralise( totals.testCases.passed, "test case" ) << ")"; << pluralise( totals.testCases.passed, "test case" ) << ")";
@ -130,12 +130,12 @@ namespace Catch {
virtual void NoAssertionsInSection( const std::string& sectionName ) { virtual void NoAssertionsInSection( const std::string& sectionName ) {
startSpansLazily(); startSpansLazily();
TextColour colour( TextColour::ResultError ); Colour colour( Colour::ResultError );
m_config.stream() << "\nNo assertions in section, '" << sectionName << "'\n" << std::endl; m_config.stream() << "\nNo assertions in section, '" << sectionName << "'\n" << std::endl;
} }
virtual void NoAssertionsInTestCase( const std::string& testName ) { virtual void NoAssertionsInTestCase( const std::string& testName ) {
startSpansLazily(); startSpansLazily();
TextColour colour( TextColour::ResultError ); Colour colour( Colour::ResultError );
m_config.stream() << "\nNo assertions in test case, '" << testName << "'\n" << std::endl; 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 << "' "; m_config.stream() << "[End of section: '" << sectionName << "' ";
if( assertions.failed ) { if( assertions.failed ) {
TextColour colour( TextColour::ResultError ); Colour colour( Colour::ResultError );
ReportCounts( "assertion", assertions); ReportCounts( "assertion", assertions);
} }
else { else {
TextColour colour( TextColour::ResultSuccess ); Colour colour( Colour::ResultSuccess );
m_config.stream() << ( assertions.passed > 1 ? "All " : "" ) m_config.stream() << ( assertions.passed > 1 ? "All " : "" )
<< pluralise( assertions.passed, "assertion" ) << " passed" ; << pluralise( assertions.passed, "assertion" ) << " passed" ;
} }
@ -166,22 +166,22 @@ namespace Catch {
startSpansLazily(); startSpansLazily();
if( !assertionResult.getSourceInfo().empty() ) { if( !assertionResult.getSourceInfo().empty() ) {
TextColour colour( TextColour::FileName ); Colour colour( Colour::FileName );
m_config.stream() << assertionResult.getSourceInfo() << ": "; m_config.stream() << assertionResult.getSourceInfo() << ": ";
} }
if( assertionResult.hasExpression() ) { if( assertionResult.hasExpression() ) {
TextColour colour( TextColour::OriginalExpression ); Colour colour( Colour::OriginalExpression );
m_config.stream() << assertionResult.getExpression(); m_config.stream() << assertionResult.getExpression();
if( assertionResult.succeeded() ) { if( assertionResult.succeeded() ) {
TextColour successColour( TextColour::Success ); Colour successColour( Colour::Success );
m_config.stream() << " succeeded"; m_config.stream() << " succeeded";
} }
else { else {
TextColour errorColour( TextColour::Error ); Colour errorColour( Colour::Error );
m_config.stream() << " failed"; m_config.stream() << " failed";
if( assertionResult.isOk() ) { if( assertionResult.isOk() ) {
TextColour okAnywayColour( TextColour::Success ); Colour okAnywayColour( Colour::Success );
m_config.stream() << " - but was ok"; m_config.stream() << " - but was ok";
} }
} }
@ -189,7 +189,7 @@ namespace Catch {
switch( assertionResult.getResultType() ) { switch( assertionResult.getResultType() ) {
case ResultWas::ThrewException: case ResultWas::ThrewException:
{ {
TextColour colour( TextColour::Error ); Colour colour( Colour::Error );
if( assertionResult.hasExpression() ) if( assertionResult.hasExpression() )
m_config.stream() << " with unexpected"; m_config.stream() << " with unexpected";
else else
@ -199,7 +199,7 @@ namespace Catch {
break; break;
case ResultWas::DidntThrowException: case ResultWas::DidntThrowException:
{ {
TextColour colour( TextColour::Error ); Colour colour( Colour::Error );
if( assertionResult.hasExpression() ) if( assertionResult.hasExpression() )
m_config.stream() << " because no exception was thrown where one was expected"; m_config.stream() << " because no exception was thrown where one was expected";
else else
@ -208,19 +208,19 @@ namespace Catch {
break; break;
case ResultWas::Info: case ResultWas::Info:
{ {
TextColour colour( TextColour::ReconstructedExpression ); Colour colour( Colour::ReconstructedExpression );
streamVariableLengthText( "info", assertionResult.getMessage() ); streamVariableLengthText( "info", assertionResult.getMessage() );
} }
break; break;
case ResultWas::Warning: case ResultWas::Warning:
{ {
TextColour colour( TextColour::ReconstructedExpression ); Colour colour( Colour::ReconstructedExpression );
streamVariableLengthText( "warning", assertionResult.getMessage() ); streamVariableLengthText( "warning", assertionResult.getMessage() );
} }
break; break;
case ResultWas::ExplicitFailure: case ResultWas::ExplicitFailure:
{ {
TextColour colour( TextColour::Error ); Colour colour( Colour::Error );
m_config.stream() << "failed with message: '" << assertionResult.getMessage() << "'"; m_config.stream() << "failed with message: '" << assertionResult.getMessage() << "'";
} }
break; break;
@ -231,21 +231,21 @@ namespace Catch {
case ResultWas::Exception: case ResultWas::Exception:
if( !assertionResult.hasExpression() ) { if( !assertionResult.hasExpression() ) {
if( assertionResult.succeeded() ) { if( assertionResult.succeeded() ) {
TextColour colour( TextColour::Success ); Colour colour( Colour::Success );
m_config.stream() << " succeeded"; m_config.stream() << " succeeded";
} }
else { else {
TextColour colour( TextColour::Error ); Colour colour( Colour::Error );
m_config.stream() << " failed"; m_config.stream() << " failed";
if( assertionResult.isOk() ) { if( assertionResult.isOk() ) {
TextColour okAnywayColour( TextColour::Success ); Colour okAnywayColour( Colour::Success );
m_config.stream() << " - but was ok"; m_config.stream() << " - but was ok";
} }
} }
} }
if( assertionResult.hasMessage() ) { if( assertionResult.hasMessage() ) {
m_config.stream() << "\n"; m_config.stream() << "\n";
TextColour colour( TextColour::ReconstructedExpression ); Colour colour( Colour::ReconstructedExpression );
streamVariableLengthText( "with message", assertionResult.getMessage() ); streamVariableLengthText( "with message", assertionResult.getMessage() );
} }
break; break;
@ -258,7 +258,7 @@ namespace Catch {
if( assertionResult.getExpandedExpression().size() < 70 ) if( assertionResult.getExpandedExpression().size() < 70 )
m_config.stream() << "\t"; m_config.stream() << "\t";
} }
TextColour colour( TextColour::ReconstructedExpression ); Colour colour( Colour::ReconstructedExpression );
m_config.stream() << assertionResult.getExpandedExpression(); m_config.stream() << assertionResult.getExpandedExpression();
} }
m_config.stream() << std::endl; m_config.stream() << std::endl;

View File

@ -60,7 +60,7 @@ namespace Catch {
virtual void sectionEnded( SectionStats const& _sectionStats ) { virtual void sectionEnded( SectionStats const& _sectionStats ) {
if( _sectionStats.missingAssertions ) { if( _sectionStats.missingAssertions ) {
lazyPrint(); lazyPrint();
TextColour colour( TextColour::ResultError ); Colour colour( Colour::ResultError );
stream << "\nNo assertions in section, '" << _sectionStats.sectionInfo.name << "'\n" << std::endl; stream << "\nNo assertions in section, '" << _sectionStats.sectionInfo.name << "'\n" << std::endl;
} }
m_headerPrinted = false; m_headerPrinted = false;
@ -71,7 +71,7 @@ namespace Catch {
if( _testCaseStats.missingAssertions ) { if( _testCaseStats.missingAssertions ) {
lazyPrint(); lazyPrint();
TextColour colour( TextColour::ResultError ); Colour colour( Colour::ResultError );
stream << "\nNo assertions in test case, '" << _testCaseStats.testInfo.name << "'\n" << std::endl; stream << "\nNo assertions in test case, '" << _testCaseStats.testInfo.name << "'\n" << std::endl;
} }
StreamingReporterBase::testCaseEnded( _testCaseStats ); StreamingReporterBase::testCaseEnded( _testCaseStats );
@ -103,13 +103,13 @@ namespace Catch {
: stream( _stream ), : stream( _stream ),
stats( _stats ), stats( _stats ),
result( _stats.assertionResult ), result( _stats.assertionResult ),
colour( TextColour::None ), colour( Colour::None ),
message( result.getMessage() ), message( result.getMessage() ),
messages( _stats.infoMessages ) messages( _stats.infoMessages )
{ {
switch( result.getResultType() ) { switch( result.getResultType() ) {
case ResultWas::Ok: case ResultWas::Ok:
colour = TextColour::Success; colour = Colour::Success;
passOrFail = "PASSED"; passOrFail = "PASSED";
//if( result.hasMessage() ) //if( result.hasMessage() )
if( _stats.infoMessages.size() == 1 ) if( _stats.infoMessages.size() == 1 )
@ -119,11 +119,11 @@ namespace Catch {
break; break;
case ResultWas::ExpressionFailed: case ResultWas::ExpressionFailed:
if( result.isOk() ) { if( result.isOk() ) {
colour = TextColour::Success; colour = Colour::Success;
passOrFail = "FAILED - but was ok"; passOrFail = "FAILED - but was ok";
} }
else { else {
colour = TextColour::Error; colour = Colour::Error;
passOrFail = "FAILED"; passOrFail = "FAILED";
} }
if( _stats.infoMessages.size() == 1 ) if( _stats.infoMessages.size() == 1 )
@ -132,12 +132,12 @@ namespace Catch {
messageLabel = "with messages"; messageLabel = "with messages";
break; break;
case ResultWas::ThrewException: case ResultWas::ThrewException:
colour = TextColour::Error; colour = Colour::Error;
passOrFail = "FAILED"; passOrFail = "FAILED";
messageLabel = "due to unexpected exception with message"; messageLabel = "due to unexpected exception with message";
break; break;
case ResultWas::DidntThrowException: case ResultWas::DidntThrowException:
colour = TextColour::Error; colour = Colour::Error;
passOrFail = "FAILED"; passOrFail = "FAILED";
messageLabel = "because no exception was thrown where one was expected"; messageLabel = "because no exception was thrown where one was expected";
break; break;
@ -149,7 +149,7 @@ namespace Catch {
break; break;
case ResultWas::ExplicitFailure: case ResultWas::ExplicitFailure:
passOrFail = "FAILED"; passOrFail = "FAILED";
colour = TextColour::Error; colour = Colour::Error;
if( _stats.infoMessages.size() == 1 ) if( _stats.infoMessages.size() == 1 )
messageLabel = "explicitly with message"; messageLabel = "explicitly with message";
if( _stats.infoMessages.size() > 1 ) if( _stats.infoMessages.size() > 1 )
@ -157,7 +157,7 @@ namespace Catch {
break; break;
case ResultWas::Exception: case ResultWas::Exception:
passOrFail = "FAILED"; passOrFail = "FAILED";
colour = TextColour::Error; colour = Colour::Error;
if( _stats.infoMessages.size() == 1 ) if( _stats.infoMessages.size() == 1 )
messageLabel = "with message"; messageLabel = "with message";
if( _stats.infoMessages.size() > 1 ) if( _stats.infoMessages.size() > 1 )
@ -168,7 +168,7 @@ namespace Catch {
case ResultWas::Unknown: case ResultWas::Unknown:
case ResultWas::FailureBit: case ResultWas::FailureBit:
passOrFail = "** internal error **"; passOrFail = "** internal error **";
colour = TextColour::Error; colour = Colour::Error;
break; break;
} }
} }
@ -191,13 +191,13 @@ namespace Catch {
private: private:
void printResultType() const { void printResultType() const {
if( !passOrFail.empty() ) { if( !passOrFail.empty() ) {
TextColour colourGuard( colour ); Colour colourGuard( colour );
stream << passOrFail << ":\n"; stream << passOrFail << ":\n";
} }
} }
void printOriginalExpression() const { void printOriginalExpression() const {
if( result.hasExpression() ) { if( result.hasExpression() ) {
TextColour colourGuard( TextColour::OriginalExpression ); Colour colourGuard( Colour::OriginalExpression );
stream << " "; stream << " ";
if( !result.getTestMacroName().empty() ) if( !result.getTestMacroName().empty() )
stream << result.getTestMacroName() << "( "; stream << result.getTestMacroName() << "( ";
@ -210,7 +210,7 @@ namespace Catch {
void printReconstructedExpression() const { void printReconstructedExpression() const {
if( result.hasExpandedExpression() ) { if( result.hasExpandedExpression() ) {
stream << "with expansion:\n"; stream << "with expansion:\n";
TextColour colourGuard( TextColour::ReconstructedExpression ); Colour colourGuard( Colour::ReconstructedExpression );
stream << LineWrapper().setIndent(2).wrap( result.getExpandedExpression() ) << "\n"; stream << LineWrapper().setIndent(2).wrap( result.getExpandedExpression() ) << "\n";
} }
} }
@ -224,14 +224,14 @@ namespace Catch {
} }
} }
void printSourceInfo() const { void printSourceInfo() const {
TextColour colourGuard( TextColour::FileName ); Colour colourGuard( Colour::FileName );
stream << result.getSourceInfo() << ": "; stream << result.getSourceInfo() << ": ";
} }
std::ostream& stream; std::ostream& stream;
AssertionStats const& stats; AssertionStats const& stats;
AssertionResult const& result; AssertionResult const& result;
TextColour::Colours colour; Colour::Code colour;
std::string passOrFail; std::string passOrFail;
std::string messageLabel; std::string messageLabel;
std::string message; std::string message;
@ -253,7 +253,7 @@ namespace Catch {
} }
void lazyPrintRunInfo() { void lazyPrintRunInfo() {
stream << "\n" << getTildes() << "\n"; stream << "\n" << getTildes() << "\n";
TextColour colour( TextColour::SecondaryText ); Colour colour( Colour::SecondaryText );
stream << testRunInfo->name stream << testRunInfo->name
<< " is a CATCH v" << libraryVersion.majorVersion << "." << " is a CATCH v" << libraryVersion.majorVersion << "."
<< libraryVersion.minorVersion << " b" << libraryVersion.minorVersion << " b"
@ -277,7 +277,7 @@ namespace Catch {
? currentSectionInfo->lineInfo ? currentSectionInfo->lineInfo
: unusedTestCaseInfo->lineInfo ); : unusedTestCaseInfo->lineInfo );
if( currentSectionInfo ) { if( currentSectionInfo ) {
TextColour colourGuard( TextColour::Headers ); Colour colourGuard( Colour::Headers );
std::vector<ThreadedSectionInfo*> sections; std::vector<ThreadedSectionInfo*> sections;
for( ThreadedSectionInfo* section = currentSectionInfo.get(); for( ThreadedSectionInfo* section = currentSectionInfo.get();
section; section;
@ -301,11 +301,11 @@ namespace Catch {
void printOpenHeader( std::string const& _name, SourceLineInfo const& _lineInfo = SourceLineInfo() ) { void printOpenHeader( std::string const& _name, SourceLineInfo const& _lineInfo = SourceLineInfo() ) {
stream << getDashes() << "\n"; stream << getDashes() << "\n";
if( !_lineInfo.empty() ){ if( !_lineInfo.empty() ){
TextColour colourGuard( TextColour::FileName ); Colour colourGuard( Colour::FileName );
stream << _lineInfo << "\n\n"; stream << _lineInfo << "\n\n";
} }
{ {
TextColour colourGuard( TextColour::Headers ); Colour colourGuard( Colour::Headers );
stream << _name << "\n"; stream << _name << "\n";
} }
} }
@ -315,7 +315,7 @@ namespace Catch {
stream << "No tests ran"; stream << "No tests ran";
} }
else if( totals.assertions.failed ) { else if( totals.assertions.failed ) {
TextColour colour( TextColour::ResultError ); Colour colour( Colour::ResultError );
printCounts( "test case", totals.testCases ); printCounts( "test case", totals.testCases );
if( totals.testCases.failed > 0 ) { if( totals.testCases.failed > 0 ) {
stream << " ("; stream << " (";
@ -324,7 +324,7 @@ namespace Catch {
} }
} }
else { else {
TextColour colour( TextColour::ResultSuccess ); Colour colour( Colour::ResultSuccess );
stream << "All tests passed (" stream << "All tests passed ("
<< pluralise( totals.assertions.passed, "assertion" ) << " in " << pluralise( totals.assertions.passed, "assertion" ) << " in "
<< pluralise( totals.testCases.passed, "test case" ) << ")"; << pluralise( totals.testCases.passed, "test case" ) << ")";