Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

More formatting/ colour tweaks

Commit
2c90533a264d6a61b3557966c481f183805a95b0
Author
Phil Nash ·
Parents
67e9f01d387f

Files · Download .tar.gz

Changes

 include/internal/catch_common.h                |  2 +-
 include/internal/catch_console_colour.hpp      |  3 ++-
 include/internal/catch_console_colour_impl.hpp | 18 +++++++++++-------
 include/reporters/catch_reporter_console.hpp   | 25 +++++++++++++++----------
 4 files changed, 29 insertions(+), 19 deletions(-)

diff --git a/include/internal/catch_common.h b/include/internal/catch_common.h
index 630277f2..d6627878 100644
--- a/include/internal/catch_common.h
+++ b/include/internal/catch_common.h
@@ -127,7 +127,7 @@ namespace Catch {
     
     inline std::ostream& operator << ( std::ostream& os, const SourceLineInfo& info ) {
 #ifndef __GNUG__
-        os << info.file << "(" << info.line << "):";
+        os << info.file << "(" << info.line << ")";
 #else                
         os << info.file << ":" << info.line;
 #endif            
diff --git a/include/internal/catch_console_colour.hpp b/include/internal/catch_console_colour.hpp
index cd7032a7..930738dc 100644
--- a/include/internal/catch_console_colour.hpp
+++ b/include/internal/catch_console_colour.hpp
@@ -26,7 +26,8 @@ namespace Catch {
             OriginalExpression,
             ReconstructedExpression,
             
-            SecondaryText
+            SecondaryText,
+            Headers
         };
 
         virtual void set( Colours colour ) = 0;
diff --git a/include/internal/catch_console_colour_impl.hpp b/include/internal/catch_console_colour_impl.hpp
index 939b0097..d00d969e 100644
--- a/include/internal/catch_console_colour_impl.hpp
+++ b/include/internal/catch_console_colour_impl.hpp
@@ -22,8 +22,9 @@ namespace {
                 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,
-                Turquoise = FOREGROUND_BLUE | FOREGROUND_GREEN,
+                Cyan = FOREGROUND_BLUE | FOREGROUND_GREEN,
                 Yellow = FOREGROUND_RED | FOREGROUND_GREEN
         };
         switch( colour ) {
@@ -32,9 +33,10 @@ namespace {
             case IConsoleColourCodes::ResultSuccess:        return BrightGreen;
             case IConsoleColourCodes::Error:                return BrightRed;
             case IConsoleColourCodes::Success:              return DarkGreen;
-            case IConsoleColourCodes::OriginalExpression:   return Turquoise;
+            case IConsoleColourCodes::OriginalExpression:   return Cyan;
             case IConsoleColourCodes::ReconstructedExpression: return Yellow;
             case IConsoleColourCodes::SecondaryText:        return Grey;
+            case IConsoleColourCodes::Headers:              return 0;
             default: return 0;
         }
     }
@@ -84,8 +86,9 @@ namespace {
     // https://github.com/philsquared/Catch/pull/131
 
     const char* WhiteOrNormal = "[0m";
-    const char* BoldRed =       "[1;31m";
-    const char* BoldGreen =     "[1;32m";
+    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";
@@ -101,13 +104,14 @@ namespace {
         const char* escapeCodeForColour( Colours colour ) {
             switch( colour ) {
                 case FileName:              return WhiteOrNormal;
-                case ResultError:           return BoldRed;
-                case ResultSuccess:         return BoldGreen;
-                case Error:                 return BoldRed;
+                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;
                 }
         }
diff --git a/include/reporters/catch_reporter_console.hpp b/include/reporters/catch_reporter_console.hpp
index 0be6b6c3..b210bf2d 100644
--- a/include/reporters/catch_reporter_console.hpp
+++ b/include/reporters/catch_reporter_console.hpp
@@ -271,15 +271,13 @@ namespace Catch {
                 unusedGroupInfo.reset();
             }
         }
-        void lazyPrintTestCaseInfo() {
-            if( !currentSectionInfo ) {
-                printClosedHeader( unusedTestCaseInfo->name );
-                stream << std::endl;
-            }
-        }
         void printTestCaseAndSectionHeader() {
-            printOpenHeader( unusedTestCaseInfo->name );
+            printOpenHeader(    unusedTestCaseInfo->name,
+                                currentSectionInfo
+                                    ? currentSectionInfo->lineInfo
+                                    : unusedTestCaseInfo->lineInfo );
             if( currentSectionInfo ) {
+                TextColour colourGuard( TextColour::Headers );
                 std::vector<ThreadedSectionInfo*> sections;
                 for(    ThreadedSectionInfo* section = currentSectionInfo.get();
                         section;
@@ -300,9 +298,16 @@ namespace Catch {
             printOpenHeader( _name );
             stream << getDots() << "\n";
         }
-        void printOpenHeader( std::string const& _name ) {
-            stream  << getDashes() << "\n"
-                    << _name << "\n";
+        void printOpenHeader( std::string const& _name, SourceLineInfo const& _lineInfo = SourceLineInfo() ) {
+            stream  << getDashes() << "\n";
+            if( !_lineInfo.empty() ){
+                TextColour colourGuard( TextColour::FileName );
+                stream << _lineInfo << "\n\n";
+            }
+            {
+                TextColour colourGuard( TextColour::Headers );
+                stream << _name << "\n";
+            }
         }
         
         void printTotals( const Totals& totals ) {