More console reporter refactoring

This commit is contained in:
Phil Nash 2013-01-15 08:09:20 +00:00
parent 313481006f
commit 9beb6f24a1

View File

@ -63,16 +63,15 @@ namespace Catch {
struct ResultComponents { struct ResultComponents {
ResultComponents( AssertionResult const& _result ) ResultComponents( AssertionResult const& _result )
: colour( TextColour::None ) : colour( TextColour::None ),
message( _result.getMessage() )
{ {
switch( _result.getResultType() ) { switch( _result.getResultType() ) {
case ResultWas::Ok: case ResultWas::Ok:
colour = TextColour::Success; colour = TextColour::Success;
passOrFail = "passed"; passOrFail = "passed";
if( _result.hasMessage() ){ if( _result.hasMessage() )
messageLabel = "with message"; messageLabel = "with message";
message = _result.getMessage();
}
break; break;
case ResultWas::ExpressionFailed: case ResultWas::ExpressionFailed:
if( _result.isOk() ) { if( _result.isOk() ) {
@ -85,14 +84,12 @@ namespace Catch {
} }
if( _result.hasMessage() ){ if( _result.hasMessage() ){
messageLabel = "with message"; messageLabel = "with message";
message = _result.getMessage();
} }
break; break;
case ResultWas::ThrewException: case ResultWas::ThrewException:
colour = TextColour::Error; colour = TextColour::Error;
passOrFail = "failed"; passOrFail = "failed";
messageLabel = "due to unexpected exception with message"; messageLabel = "due to unexpected exception with message";
message = _result.getMessage();
break; break;
case ResultWas::DidntThrowException: case ResultWas::DidntThrowException:
colour = TextColour::Error; colour = TextColour::Error;
@ -101,27 +98,24 @@ namespace Catch {
break; break;
case ResultWas::Info: case ResultWas::Info:
messageLabel = "info"; messageLabel = "info";
message = _result.getMessage();
break; break;
case ResultWas::Warning: case ResultWas::Warning:
messageLabel = "warning"; messageLabel = "warning";
message = _result.getMessage();
break; break;
case ResultWas::ExplicitFailure: case ResultWas::ExplicitFailure:
passOrFail = "failed"; passOrFail = "failed";
colour = TextColour::Error; colour = TextColour::Error;
messageLabel = "explicitly with message"; messageLabel = "explicitly with message";
message = _result.getMessage();
break; break;
case ResultWas::Exception: case ResultWas::Exception:
passOrFail = "failed"; passOrFail = "failed";
colour = TextColour::Error; colour = TextColour::Error;
if( _result.hasMessage() ){ if( _result.hasMessage() )
messageLabel = "with message"; messageLabel = "with message";
message = _result.getMessage();
}
break; break;
case ResultWas::Unknown: // These cases are here to prevent compiler warnings
// These cases are here to prevent compiler warnings
case ResultWas::Unknown:
case ResultWas::FailureBit: case ResultWas::FailureBit:
passOrFail = "** internal error **"; passOrFail = "** internal error **";
colour = TextColour::Error; colour = TextColour::Error;