virtual void testEnded ( const ResultInfo& result ) { if( result.getResultType() == ResultWas::Ok ) { m_successes++; } else if( !result.ok() ) { m_failures++; std::vector<ResultInfo>::const_iterator it = m_info.begin(); std::vector<ResultInfo>::const_iterator itEnd = m_info.end(); for(; it != itEnd; ++it ) m_reporter->Result( *it ); m_info.clear(); } if( result.getResultType() == ResultWas::Info ) m_info.push_back( result ); else m_reporter->Result( result ); }
void MockReporter::Result( const ResultInfo& resultInfo ) { if( resultInfo.getResultType() == ResultWas::Ok ) return; switch( resultInfo.getResultType() ) { case ResultWas::Info: m_log << "Info"; break; case ResultWas::Warning: m_log << "Warning"; break; case ResultWas::ExplicitFailure: m_log << "ExplicitFailure"; break; case ResultWas::ExpressionFailed: m_log << "ExpressionFailed"; break; case ResultWas::Unknown: m_log << "Unknown"; break; case ResultWas::ThrewException: m_log << "ThrewException"; break; case ResultWas::DidntThrowException: m_log << "DidntThrowException"; break; // We shouldn't ever see these case ResultWas::Ok: m_log << "Ok"; break; case ResultWas::FailureBit: m_log << "FailureBit"; break; case ResultWas::Exception: m_log << "Exception"; break; default: m_log << "{unrecognised ResultType enum value}"; break; } if( resultInfo.hasExpression() ) m_log << resultInfo.getExpression(); if( resultInfo.hasMessage() ) m_log << "'" << resultInfo.getMessage() << "'"; if( resultInfo.hasExpandedExpression() ) m_log << resultInfo.getExpandedExpression(); }
virtual void Result( const ResultInfo& resultInfo ) { if( !m_config.includeSuccessfulResults() && resultInfo.getResultType() == ResultWas::Ok ) return; StartSpansLazily(); if( !resultInfo.getFilename().empty() ) { TextColour colour( TextColour::FileName ); m_config.stream() << SourceLineInfo( resultInfo.getFilename(), resultInfo.getLine() ); } if( resultInfo.hasExpression() ) { TextColour colour( TextColour::OriginalExpression ); m_config.stream() << resultInfo.getExpression(); if( resultInfo.ok() ) { TextColour successColour( TextColour::Success ); m_config.stream() << " succeeded"; } else { TextColour errorColour( TextColour::Error ); m_config.stream() << " failed"; } } switch( resultInfo.getResultType() ) { case ResultWas::ThrewException: { TextColour colour( TextColour::Error ); if( resultInfo.hasExpression() ) m_config.stream() << " with unexpected"; else m_config.stream() << "Unexpected"; m_config.stream() << " exception with message: '" << resultInfo.getMessage() << "'"; } break; case ResultWas::DidntThrowException: { TextColour colour( TextColour::Error ); if( resultInfo.hasExpression() ) m_config.stream() << " because no exception was thrown where one was expected"; else m_config.stream() << "No exception thrown where one was expected"; } break; case ResultWas::Info: streamVariableLengthText( "info", resultInfo.getMessage() ); break; case ResultWas::Warning: m_config.stream() << "warning:\n'" << resultInfo.getMessage() << "'"; break; case ResultWas::ExplicitFailure: { TextColour colour( TextColour::Error ); m_config.stream() << "failed with message: '" << resultInfo.getMessage() << "'"; } break; case ResultWas::Unknown: // These cases are here to prevent compiler warnings case ResultWas::Ok: case ResultWas::FailureBit: case ResultWas::ExpressionFailed: case ResultWas::Exception: default: if( !resultInfo.hasExpression() ) { if( resultInfo.ok() ) { TextColour colour( TextColour::Success ); m_config.stream() << " succeeded"; } else { TextColour colour( TextColour::Error ); m_config.stream() << " failed"; } } break; } if( resultInfo.hasExpandedExpression() ) { m_config.stream() << " for: "; TextColour colour( TextColour::ReconstructedExpression ); m_config.stream() << resultInfo.getExpandedExpression(); } m_config.stream() << std::endl; }