| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4012,16 +4012,11 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener { | |||
| 4012 | 4012 | static void PrintXmlUnitTest(::std::ostream* stream, | |
| 4013 | 4013 | const UnitTest& unit_test); | |
| 4014 | 4014 | ||
| 4015 | - // Produces a string representing the test properties in a result as space | ||
| 4016 | - // delimited XML attributes based on the property key="value" pairs. | ||
| 4017 | - // When the std::string is not empty, it includes a space at the beginning, | ||
| 4018 | - // to delimit this attribute from prior attributes. | ||
| 4019 | - static std::string TestPropertiesAsXmlAttributes(const TestResult& result); | ||
| 4020 | - | ||
| 4021 | 4015 | // Streams an XML representation of the test properties of a TestResult | |
| 4022 | 4016 | // object. | |
| 4023 | 4017 | static void OutputXmlTestProperties(std::ostream* stream, | |
| 4024 | - const TestResult& result); | ||
| 4018 | + const TestResult& result, | ||
| 4019 | + const std::string& indent); | ||
| 4025 | 4020 | ||
| 4026 | 4021 | // The output file. | |
| 4027 | 4022 | const std::string output_file_; | |
@@ -4355,7 +4350,7 @@ void XmlUnitTestResultPrinter::OutputXmlTestResult(::std::ostream* stream, | |||
| 4355 | 4350 | if (failures == 0 && skips == 0) { | |
| 4356 | 4351 | *stream << ">\n"; | |
| 4357 | 4352 | } | |
| 4358 | - OutputXmlTestProperties(stream, result); | ||
| 4353 | + OutputXmlTestProperties(stream, result, /*indent=*/" "); | ||
| 4359 | 4354 | *stream << " </testcase>\n"; | |
| 4360 | 4355 | } | |
| 4361 | 4356 | } | |
@@ -4384,9 +4379,10 @@ void XmlUnitTestResultPrinter::PrintXmlTestSuite(std::ostream* stream, | |||
| 4384 | 4379 | OutputXmlAttribute( | |
| 4385 | 4380 | stream, kTestsuite, "timestamp", | |
| 4386 | 4381 | FormatEpochTimeInMillisAsIso8601(test_suite.start_timestamp())); | |
| 4387 | - *stream << TestPropertiesAsXmlAttributes(test_suite.ad_hoc_test_result()); | ||
| 4388 | 4382 | } | |
| 4389 | 4383 | *stream << ">\n"; | |
| 4384 | + OutputXmlTestProperties(stream, test_suite.ad_hoc_test_result(), | ||
| 4385 | + /*indent=*/" "); | ||
| 4390 | 4386 | for (int i = 0; i < test_suite.total_test_count(); ++i) { | |
| 4391 | 4387 | if (test_suite.GetTestInfo(i)->is_reportable()) | |
| 4392 | 4388 | OutputXmlTestInfo(stream, test_suite.name(), *test_suite.GetTestInfo(i)); | |
@@ -4424,11 +4420,12 @@ void XmlUnitTestResultPrinter::PrintXmlUnitTest(std::ostream* stream, | |||
| 4424 | 4420 | OutputXmlAttribute(stream, kTestsuites, "random_seed", | |
| 4425 | 4421 | StreamableToString(unit_test.random_seed())); | |
| 4426 | 4422 | } | |
| 4427 | - *stream << TestPropertiesAsXmlAttributes(unit_test.ad_hoc_test_result()); | ||
| 4428 | 4423 | ||
| 4429 | 4424 | OutputXmlAttribute(stream, kTestsuites, "name", "AllTests"); | |
| 4430 | 4425 | *stream << ">\n"; | |
| 4431 | 4426 | ||
| 4427 | + OutputXmlTestProperties(stream, unit_test.ad_hoc_test_result(), | ||
| 4428 | + /*indent=*/" "); | ||
| 4432 | 4429 | for (int i = 0; i < unit_test.total_test_suite_count(); ++i) { | |
| 4433 | 4430 | if (unit_test.GetTestSuite(i)->reportable_test_count() > 0) | |
| 4434 | 4431 | PrintXmlTestSuite(stream, *unit_test.GetTestSuite(i)); | |
@@ -4465,37 +4462,24 @@ void XmlUnitTestResultPrinter::PrintXmlTestsList( | |||
| 4465 | 4462 | *stream << "</" << kTestsuites << ">\n"; | |
| 4466 | 4463 | } | |
| 4467 | 4464 | ||
| 4468 | - // Produces a string representing the test properties in a result as space | ||
| 4469 | - // delimited XML attributes based on the property key="value" pairs. | ||
| 4470 | - std::string XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes( | ||
| 4471 | - const TestResult& result) { | ||
| 4472 | - Message attributes; | ||
| 4473 | - for (int i = 0; i < result.test_property_count(); ++i) { | ||
| 4474 | - const TestProperty& property = result.GetTestProperty(i); | ||
| 4475 | - attributes << " " << property.key() << "=" << "\"" | ||
| 4476 | - << EscapeXmlAttribute(property.value()) << "\""; | ||
| 4477 | - } | ||
| 4478 | - return attributes.GetString(); | ||
| 4479 | - } | ||
| 4480 | - | ||
| 4481 | 4465 | void XmlUnitTestResultPrinter::OutputXmlTestProperties( | |
| 4482 | - std::ostream* stream, const TestResult& result) { | ||
| 4466 | + std::ostream* stream, const TestResult& result, const std::string& indent) { | ||
| 4483 | 4467 | const std::string kProperties = "properties"; | |
| 4484 | 4468 | const std::string kProperty = "property"; | |
| 4485 | 4469 | ||
| 4486 | 4470 | if (result.test_property_count() <= 0) { | |
| 4487 | 4471 | return; | |
| 4488 | 4472 | } | |
| 4489 | 4473 | ||
| 4490 | - *stream << " <" << kProperties << ">\n"; | ||
| 4474 | + *stream << indent << "<" << kProperties << ">\n"; | ||
| 4491 | 4475 | for (int i = 0; i < result.test_property_count(); ++i) { | |
| 4492 | 4476 | const TestProperty& property = result.GetTestProperty(i); | |
| 4493 | - *stream << " <" << kProperty; | ||
| 4477 | + *stream << indent << " <" << kProperty; | ||
| 4494 | 4478 | *stream << " name=\"" << EscapeXmlAttribute(property.key()) << "\""; | |
| 4495 | 4479 | *stream << " value=\"" << EscapeXmlAttribute(property.value()) << "\""; | |
| 4496 | 4480 | *stream << "/>\n"; | |
| 4497 | 4481 | } | |
| 4498 | - *stream << " </" << kProperties << ">\n"; | ||
| 4482 | + *stream << indent << "</" << kProperties << ">\n"; | ||
| 4499 | 4483 | } | |
| 4500 | 4484 | ||
| 4501 | 4485 | // End XmlUnitTestResultPrinter | |
| Back | FazBrowse Home | New Git URL |
0 commit comments