MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / writeAssertion

Method writeAssertion

extern/Catch2/catch.hpp:17023–17079  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17021 }
17022
17023 void JunitReporter::writeAssertion( AssertionStats const& stats ) {
17024 AssertionResult const& result = stats.assertionResult;
17025 if( !result.isOk() ) {
17026 std::string elementName;
17027 switch( result.getResultType() ) {
17028 case ResultWas::ThrewException:
17029 case ResultWas::FatalErrorCondition:
17030 elementName = "error";
17031 break;
17032 case ResultWas::ExplicitFailure:
17033 case ResultWas::ExpressionFailed:
17034 case ResultWas::DidntThrowException:
17035 elementName = "failure";
17036 break;
17037
17038 // We should never see these here:
17039 case ResultWas::Info:
17040 case ResultWas::Warning:
17041 case ResultWas::Ok:
17042 case ResultWas::Unknown:
17043 case ResultWas::FailureBit:
17044 case ResultWas::Exception:
17045 elementName = "internalError";
17046 break;
17047 }
17048
17049 XmlWriter::ScopedElement e = xml.scopedElement( elementName );
17050
17051 xml.writeAttribute( "message", result.getExpression() );
17052 xml.writeAttribute( "type", result.getTestMacroName() );
17053
17054 ReusableStringStream rss;
17055 if (stats.totals.assertions.total() > 0) {
17056 rss << "FAILED" << ":\n";
17057 if (result.hasExpression()) {
17058 rss << " ";
17059 rss << result.getExpressionInMacro();
17060 rss << '\n';
17061 }
17062 if (result.hasExpandedExpression()) {
17063 rss << "with expansion:\n";
17064 rss << Column(result.getExpandedExpression()).indent(2) << '\n';
17065 }
17066 } else {
17067 rss << '\n';
17068 }
17069
17070 if( !result.getMessage().empty() )
17071 rss << result.getMessage() << '\n';
17072 for( auto const& msg : stats.infoMessages )
17073 if( msg.type == ResultWas::Info )
17074 rss << msg.message << '\n';
17075
17076 rss << "at " << result.getSourceInfo();
17077 xml.writeText( rss.str(), XmlFormatting::Newline );
17078 }
17079 }
17080

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