From 3b970e20e9effbcafc5f6490998ff9ef68cfe9ec Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Mon, 14 Jan 2013 18:58:50 +0000 Subject: [PATCH] Refactored printResultType into switch --- 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; }