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

Refactored printResultType into switch

Commit
3b970e20e9effbcafc5f6490998ff9ef68cfe9ec
Author
Phil Nash ·
Parents
60ed3c142c2e

Files · Download .tar.gz

Changes

 include/reporters/catch_reporter_console.hpp | 33 ++++++++++++++++------------
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/include/reporters/catch_reporter_console.hpp b/include/reporters/catch_reporter_console.hpp
index ee9f5fa7..c9ef00ee 100644
--- a/include/reporters/catch_reporter_console.hpp
+++ b/include/reporters/catch_reporter_console.hpp
@@ -61,20 +61,25 @@ namespace Catch {
         }
         
         bool printResultType( AssertionResult const& _result ) {
-            if( _result.getResultType() == ResultWas::Info ||
-                _result.getResultType() == ResultWas::Warning ) {
-            }
-            else if( _result.succeeded() ) {
-                TextColour successColour( TextColour::Success );
-                stream << "passed ";
-            }
-            else if( _result.isOk() ) {
-                TextColour okAnywayColour( TextColour::Success );
-                stream << "failed - but was ok ";
-            }
-            else {
-                TextColour errorColour( TextColour::Error );
-                stream << "failed ";
+            switch( _result.getResultType() ) {
+                case ResultWas::Info:
+                case ResultWas::Warning:
+                    break;
+                case ResultWas::Ok:
+                    {
+                        TextColour successColour( TextColour::Success );
+                        stream << "passed ";
+                    }
+                    break;
+                default:
+                    if( _result.isOk() ) {
+                        TextColour okAnywayColour( TextColour::Success );
+                        stream << "failed - but was ok ";
+                    }
+                    else {
+                        TextColour errorColour( TextColour::Error );
+                        stream << "failed ";
+                    }
             }
             return false;
         }