MCPcopy Create free account
hub / github.com/awslabs/aws-lambda-cpp / XmlUnitTestResultPrinter

Class XmlUnitTestResultPrinter

tests/gtest/gtest-all.cc:4967–5047  ·  view source on GitHub ↗

This class generates an XML output file.

Source from the content-addressed store, hash-verified

4965
4966// This class generates an XML output file.
4967class XmlUnitTestResultPrinter : public EmptyTestEventListener {
4968 public:
4969 explicit XmlUnitTestResultPrinter(const char* output_file);
4970
4971 void OnTestIterationEnd(const UnitTest& unit_test, int iteration) override;
4972 void ListTestsMatchingFilter(const std::vector<TestSuite*>& test_suites);
4973
4974 // Prints an XML summary of all unit tests.
4975 static void PrintXmlTestsList(std::ostream* stream,
4976 const std::vector<TestSuite*>& test_suites);
4977
4978 private:
4979 // Is c a whitespace character that is normalized to a space character
4980 // when it appears in an XML attribute value?
4981 static bool IsNormalizableWhitespace(char c) {
4982 return c == 0x9 || c == 0xA || c == 0xD;
4983 }
4984
4985 // May c appear in a well-formed XML document?
4986 static bool IsValidXmlCharacter(char c) {
4987 return IsNormalizableWhitespace(c) || c >= 0x20;
4988 }
4989
4990 // Returns an XML-escaped copy of the input string str. If
4991 // is_attribute is true, the text is meant to appear as an attribute
4992 // value, and normalizable whitespace is preserved by replacing it
4993 // with character references.
4994 static std::string EscapeXml(const std::string& str, bool is_attribute);
4995
4996 // Returns the given string with all characters invalid in XML removed.
4997 static std::string RemoveInvalidXmlCharacters(const std::string& str);
4998
4999 // Convenience wrapper around EscapeXml when str is an attribute value.
5000 static std::string EscapeXmlAttribute(const std::string& str) {
5001 return EscapeXml(str, true);
5002 }
5003
5004 // Convenience wrapper around EscapeXml when str is not an attribute value.
5005 static std::string EscapeXmlText(const char* str) {
5006 return EscapeXml(str, false);
5007 }
5008
5009 // Verifies that the given attribute belongs to the given element and
5010 // streams the attribute as XML.
5011 static void OutputXmlAttribute(std::ostream* stream,
5012 const std::string& element_name,
5013 const std::string& name,
5014 const std::string& value);
5015
5016 // Streams an XML CDATA section, escaping invalid CDATA sequences as needed.
5017 static void OutputXmlCDataSection(::std::ostream* stream, const char* data);
5018
5019 // Streams an XML representation of a TestInfo object.
5020 static void OutputXmlTestInfo(::std::ostream* stream,
5021 const char* test_suite_name,
5022 const TestInfo& test_info);
5023
5024 // Prints an XML representation of a TestSuite object

Callers 1

Calls

no outgoing calls

Tested by 1