mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-04 05:09:53 +01:00
More formatting/ colour tweaks
This commit is contained in:
parent
67e9f01d38
commit
2c90533a26
@ -127,7 +127,7 @@ namespace Catch {
|
|||||||
|
|
||||||
inline std::ostream& operator << ( std::ostream& os, const SourceLineInfo& info ) {
|
inline std::ostream& operator << ( std::ostream& os, const SourceLineInfo& info ) {
|
||||||
#ifndef __GNUG__
|
#ifndef __GNUG__
|
||||||
os << info.file << "(" << info.line << "):";
|
os << info.file << "(" << info.line << ")";
|
||||||
#else
|
#else
|
||||||
os << info.file << ":" << info.line;
|
os << info.file << ":" << info.line;
|
||||||
#endif
|
#endif
|
||||||
|
@ -26,7 +26,8 @@ namespace Catch {
|
|||||||
OriginalExpression,
|
OriginalExpression,
|
||||||
ReconstructedExpression,
|
ReconstructedExpression,
|
||||||
|
|
||||||
SecondaryText
|
SecondaryText,
|
||||||
|
Headers
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void set( Colours colour ) = 0;
|
virtual void set( Colours colour ) = 0;
|
||||||
|
@ -22,8 +22,9 @@ namespace {
|
|||||||
Grey = FOREGROUND_INTENSITY,
|
Grey = FOREGROUND_INTENSITY,
|
||||||
BrightRed = FOREGROUND_RED | FOREGROUND_INTENSITY,
|
BrightRed = FOREGROUND_RED | FOREGROUND_INTENSITY,
|
||||||
BrightGreen = FOREGROUND_GREEN | FOREGROUND_INTENSITY,
|
BrightGreen = FOREGROUND_GREEN | FOREGROUND_INTENSITY,
|
||||||
|
BrightWhite = FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY,
|
||||||
DarkGreen = FOREGROUND_GREEN,
|
DarkGreen = FOREGROUND_GREEN,
|
||||||
Turquoise = FOREGROUND_BLUE | FOREGROUND_GREEN,
|
Cyan = FOREGROUND_BLUE | FOREGROUND_GREEN,
|
||||||
Yellow = FOREGROUND_RED | FOREGROUND_GREEN
|
Yellow = FOREGROUND_RED | FOREGROUND_GREEN
|
||||||
};
|
};
|
||||||
switch( colour ) {
|
switch( colour ) {
|
||||||
@ -32,9 +33,10 @@ namespace {
|
|||||||
case IConsoleColourCodes::ResultSuccess: return BrightGreen;
|
case IConsoleColourCodes::ResultSuccess: return BrightGreen;
|
||||||
case IConsoleColourCodes::Error: return BrightRed;
|
case IConsoleColourCodes::Error: return BrightRed;
|
||||||
case IConsoleColourCodes::Success: return DarkGreen;
|
case IConsoleColourCodes::Success: return DarkGreen;
|
||||||
case IConsoleColourCodes::OriginalExpression: return Turquoise;
|
case IConsoleColourCodes::OriginalExpression: return Cyan;
|
||||||
case IConsoleColourCodes::ReconstructedExpression: return Yellow;
|
case IConsoleColourCodes::ReconstructedExpression: return Yellow;
|
||||||
case IConsoleColourCodes::SecondaryText: return Grey;
|
case IConsoleColourCodes::SecondaryText: return Grey;
|
||||||
|
case IConsoleColourCodes::Headers: return 0;
|
||||||
default: return 0;
|
default: return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,8 +86,9 @@ namespace {
|
|||||||
// https://github.com/philsquared/Catch/pull/131
|
// https://github.com/philsquared/Catch/pull/131
|
||||||
|
|
||||||
const char* WhiteOrNormal = "[0m";
|
const char* WhiteOrNormal = "[0m";
|
||||||
const char* BoldRed = "[1;31m";
|
const char* BrightRed = "[1;31m";
|
||||||
const char* BoldGreen = "[1;32m";
|
const char* BrightGreen = "[1;32m";
|
||||||
|
// const char* BrightWhite = "[1;37m";
|
||||||
const char* Green = "[0;32m";
|
const char* Green = "[0;32m";
|
||||||
const char* Cyan = "[0;36m";
|
const char* Cyan = "[0;36m";
|
||||||
const char* Yellow = "[0;33m";
|
const char* Yellow = "[0;33m";
|
||||||
@ -101,13 +104,14 @@ namespace {
|
|||||||
const char* escapeCodeForColour( Colours colour ) {
|
const char* escapeCodeForColour( Colours colour ) {
|
||||||
switch( colour ) {
|
switch( colour ) {
|
||||||
case FileName: return WhiteOrNormal;
|
case FileName: return WhiteOrNormal;
|
||||||
case ResultError: return BoldRed;
|
case ResultError: return BrightRed;
|
||||||
case ResultSuccess: return BoldGreen;
|
case ResultSuccess: return BrightGreen;
|
||||||
case Error: return BoldRed;
|
case Error: return BrightRed;
|
||||||
case Success: return Green;
|
case Success: return Green;
|
||||||
case OriginalExpression: return Cyan;
|
case OriginalExpression: return Cyan;
|
||||||
case ReconstructedExpression: return Yellow;
|
case ReconstructedExpression: return Yellow;
|
||||||
case SecondaryText: return LightGrey;
|
case SecondaryText: return LightGrey;
|
||||||
|
case Headers: return WhiteOrNormal;
|
||||||
case None: return WhiteOrNormal;
|
case None: return WhiteOrNormal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -271,15 +271,13 @@ namespace Catch {
|
|||||||
unusedGroupInfo.reset();
|
unusedGroupInfo.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void lazyPrintTestCaseInfo() {
|
|
||||||
if( !currentSectionInfo ) {
|
|
||||||
printClosedHeader( unusedTestCaseInfo->name );
|
|
||||||
stream << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void printTestCaseAndSectionHeader() {
|
void printTestCaseAndSectionHeader() {
|
||||||
printOpenHeader( unusedTestCaseInfo->name );
|
printOpenHeader( unusedTestCaseInfo->name,
|
||||||
|
currentSectionInfo
|
||||||
|
? currentSectionInfo->lineInfo
|
||||||
|
: unusedTestCaseInfo->lineInfo );
|
||||||
if( currentSectionInfo ) {
|
if( currentSectionInfo ) {
|
||||||
|
TextColour colourGuard( TextColour::Headers );
|
||||||
std::vector<ThreadedSectionInfo*> sections;
|
std::vector<ThreadedSectionInfo*> sections;
|
||||||
for( ThreadedSectionInfo* section = currentSectionInfo.get();
|
for( ThreadedSectionInfo* section = currentSectionInfo.get();
|
||||||
section;
|
section;
|
||||||
@ -300,9 +298,16 @@ namespace Catch {
|
|||||||
printOpenHeader( _name );
|
printOpenHeader( _name );
|
||||||
stream << getDots() << "\n";
|
stream << getDots() << "\n";
|
||||||
}
|
}
|
||||||
void printOpenHeader( std::string const& _name ) {
|
void printOpenHeader( std::string const& _name, SourceLineInfo const& _lineInfo = SourceLineInfo() ) {
|
||||||
stream << getDashes() << "\n"
|
stream << getDashes() << "\n";
|
||||||
<< _name << "\n";
|
if( !_lineInfo.empty() ){
|
||||||
|
TextColour colourGuard( TextColour::FileName );
|
||||||
|
stream << _lineInfo << "\n\n";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
TextColour colourGuard( TextColour::Headers );
|
||||||
|
stream << _name << "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void printTotals( const Totals& totals ) {
|
void printTotals( const Totals& totals ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user