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 ); }
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; }