MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / OutputXmlTestInfo

Method OutputXmlTestInfo

rtpose_wrapper/src/gtest/gtest-all.cpp:4527–4572  ·  view source on GitHub ↗

Prints an XML representation of a TestInfo object. TODO(wan): There is also value in printing properties with the plain printer.

Source from the content-addressed store, hash-verified

4525// Prints an XML representation of a TestInfo object.
4526// TODO(wan): There is also value in printing properties with the plain printer.
4527void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,
4528 const char* test_case_name,
4529 const TestInfo& test_info) {
4530 const TestResult& result = *test_info.result();
4531 *stream << " <testcase name=\""
4532 << EscapeXmlAttribute(test_info.name()).c_str() << "\"";
4533
4534 if (test_info.value_param() != NULL) {
4535 *stream << " value_param=\"" << EscapeXmlAttribute(test_info.value_param())
4536 << "\"";
4537 }
4538 if (test_info.type_param() != NULL) {
4539 *stream << " type_param=\"" << EscapeXmlAttribute(test_info.type_param())
4540 << "\"";
4541 }
4542
4543 *stream << " status=\""
4544 << (test_info.should_run() ? "run" : "notrun")
4545 << "\" time=\""
4546 << FormatTimeInMillisAsSeconds(result.elapsed_time())
4547 << "\" classname=\"" << EscapeXmlAttribute(test_case_name).c_str()
4548 << "\"" << TestPropertiesAsXmlAttributes(result).c_str();
4549
4550 int failures = 0;
4551 for (int i = 0; i < result.total_part_count(); ++i) {
4552 const TestPartResult& part = result.GetTestPartResult(i);
4553 if (part.failed()) {
4554 if (++failures == 1)
4555 *stream << ">\n";
4556 *stream << " <failure message=\""
4557 << EscapeXmlAttribute(part.summary()).c_str()
4558 << "\" type=\"\">";
4559 const string location = internal::FormatCompilerIndependentFileLocation(
4560 part.file_name(), part.line_number());
4561 const string message = location + "\n" + part.message();
4562 OutputXmlCDataSection(stream,
4563 RemoveInvalidXmlCharacters(message).c_str());
4564 *stream << "</failure>\n";
4565 }
4566 }
4567
4568 if (failures == 0)
4569 *stream << " />\n";
4570 else
4571 *stream << " </testcase>\n";
4572}
4573
4574// Prints an XML representation of a TestCase object
4575void XmlUnitTestResultPrinter::PrintXmlTestCase(FILE* out,

Callers

nothing calls this directly

Calls 5

elapsed_timeMethod · 0.80
total_part_countMethod · 0.80
file_nameMethod · 0.80

Tested by

no test coverage detected