From 5ad4640702a80078748b38ebaeda37e69dce1189 Mon Sep 17 00:00:00 2001 From: Baptiste Lepilleur Date: Thu, 23 May 2002 17:38:39 +0000 Subject: Include/cppunit/XmlOutputter. include/cppunit/XmlOutputter.h: * src/cppunit/XmlOutputter.cpp: extracted class XmlOutputter::Node to XmlElement. Extracted xml 'prolog' generation to XmlDocument. * include/cppunit/tools/XmlElement.h: * src/cppunit/tools/XmlElement.cpp: added, extracted from XmlOutputter::Node. * include/cppunit/tools/XmlDocument.h: * src/cppunit/tools/XmlDocument.cpp: added, extracted from XmlOutputter. Handle XML document prolog (encoding & style-sheet) and manage the root element. * src/DllPlugInTester/DllPlugInTester.cpp: bug fix, flag --xsl was ignored. * examples/cppunittest/XmlOutputterTest.h: * examples/cppunittest/XmlOutputterTest.cpp: updated for XmlOuputter changes. extracted tests for XmlOutputter::Node to XmlElementTest * examples/cppunittest/XmlElementTest.h: * examples/cppunittest/XmlElementTest.cpp: added, tests extracted from XmlOutputterTest. --- include/cppunit/XmlOutputter.h | 60 +++++++----------------------------------- 1 file changed, 10 insertions(+), 50 deletions(-) (limited to 'include/cppunit/XmlOutputter.h') diff --git a/include/cppunit/XmlOutputter.h b/include/cppunit/XmlOutputter.h index 2be3ffb..3336405 100644 --- a/include/cppunit/XmlOutputter.h +++ b/include/cppunit/XmlOutputter.h @@ -9,11 +9,8 @@ #endif #include -#include #include #include -#include -#include namespace CppUnit @@ -22,6 +19,8 @@ namespace CppUnit class Test; class TestFailure; class TestResultCollector; +class XmlDocument; +class XmlElement; /*! \brief Outputs a TestResultCollector in XML format. @@ -56,63 +55,23 @@ public: */ virtual void setStyleSheet( const std::string &styleSheet ); - /*! \brief An XML Element. - * \warning This class will probably be replaced with an abstract - * builder in future version. - */ - class CPPUNIT_API Node - { - public: - Node( std::string elementName, - std::string content ="" ); - Node( std::string elementName, - int numericContent ); - virtual ~Node(); - - void addAttribute( std::string attributeName, - std::string value ); - void addAttribute( std::string attributeName, - int numericValue ); - void addNode( Node *node ); - - std::string toString( const std::string &indent = "" ) const; - - private: - typedef std::pair Attribute; - - std::string attributesAsString() const; - std::string escape( std::string value ) const; - static std::string asString( int value ); - - private: - std::string m_name; - std::string m_content; - typedef std::deque Attributes; - Attributes m_attributes; - typedef std::deque Nodes; - Nodes m_nodes; - }; - - - virtual void writeProlog(); - virtual void writeTestsResult(); typedef std::map FailedTests; - virtual Node *makeRootNode(); + virtual XmlElement *makeRootNode(); virtual void addFailedTests( FailedTests &failedTests, - Node *rootNode ); + XmlElement *rootNode ); virtual void addSuccessfulTests( FailedTests &failedTests, - Node *rootNode ); - virtual void addStatistics( Node *rootNode ); + XmlElement *rootNode ); + virtual void addStatistics( XmlElement *rootNode ); virtual void addFailedTest( Test *test, TestFailure *failure, int testNumber, - Node *testsNode ); + XmlElement *testsNode ); virtual void addFailureLocation( TestFailure *failure, - Node *testNode ); + XmlElement *testNode ); virtual void addSuccessfulTest( Test *test, int testNumber, - Node *testsNode ); + XmlElement *testsNode ); protected: virtual void fillFailedTestsMap( FailedTests &failedTests ); @@ -121,6 +80,7 @@ protected: std::ostream &m_stream; std::string m_encoding; std::string m_styleSheet; + XmlDocument *m_xml; private: /// Prevents the use of the copy constructor. -- cgit v1.2.1