MCPcopy Create free account
hub / github.com/Profactor/cv-plot / writeAssertion

Method writeAssertion

CvPlot/ext/catch2/inc/catch.hpp:16656–16716  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16654 }
16655
16656 void JunitReporter::writeAssertion( AssertionStats const& stats ) {
16657 AssertionResult const& result = stats.assertionResult;
16658 if( !result.isOk() ) {
16659 std::string elementName;
16660 switch( result.getResultType() ) {
16661 case ResultWas::ThrewException:
16662 case ResultWas::FatalErrorCondition:
16663 elementName = "error";
16664 break;
16665 case ResultWas::ExplicitFailure:
16666 elementName = "failure";
16667 break;
16668 case ResultWas::ExpressionFailed:
16669 elementName = "failure";
16670 break;
16671 case ResultWas::DidntThrowException:
16672 elementName = "failure";
16673 break;
16674
16675 // We should never see these here:
16676 case ResultWas::Info:
16677 case ResultWas::Warning:
16678 case ResultWas::Ok:
16679 case ResultWas::Unknown:
16680 case ResultWas::FailureBit:
16681 case ResultWas::Exception:
16682 elementName = "internalError";
16683 break;
16684 }
16685
16686 XmlWriter::ScopedElement e = xml.scopedElement( elementName );
16687
16688 xml.writeAttribute( "message", result.getExpression() );
16689 xml.writeAttribute( "type", result.getTestMacroName() );
16690
16691 ReusableStringStream rss;
16692 if (stats.totals.assertions.total() > 0) {
16693 rss << "FAILED" << ":\n";
16694 if (result.hasExpression()) {
16695 rss << " ";
16696 rss << result.getExpressionInMacro();
16697 rss << '\n';
16698 }
16699 if (result.hasExpandedExpression()) {
16700 rss << "with expansion:\n";
16701 rss << Column(result.getExpandedExpression()).indent(2) << '\n';
16702 }
16703 } else {
16704 rss << '\n';
16705 }
16706
16707 if( !result.getMessage().empty() )
16708 rss << result.getMessage() << '\n';
16709 for( auto const& msg : stats.infoMessages )
16710 if( msg.type == ResultWas::Info )
16711 rss << msg.message << '\n';
16712
16713 rss << "at " << result.getSourceInfo();

Callers

nothing calls this directly

Calls 15

ColumnClass · 0.85
isOkMethod · 0.80
getResultTypeMethod · 0.80
scopedElementMethod · 0.80
getExpressionMethod · 0.80
getTestMacroNameMethod · 0.80
hasExpressionMethod · 0.80
getExpressionInMacroMethod · 0.80
hasExpandedExpressionMethod · 0.80
getExpandedExpressionMethod · 0.80
getMessageMethod · 0.80
getSourceInfoMethod · 0.80

Tested by

no test coverage detected