From 150339335e3c5538c1e496ae01babf148bd29ec5 Mon Sep 17 00:00:00 2001 From: Baptiste Lepilleur Date: Sun, 7 Oct 2001 18:37:53 +0000 Subject: Include/cppunit/CompilerTestResultOutputter. include/cppunit/CompilerTestResultOutputter.h : renamed CompilerOutputter.h * src/cppunit/CompilerTestResultOutputter.cpp : renamed CompilerOutputter.cpp * include/cppunit/CompilerTestResultOutputter.h : * src/cppunit/CompilerTestResultOutputter.cpp : ajust max line length for wrapping. Added static factory method defaultOutputter(). Print the number of test runs on success. * include/cppunit/CompilerTestResultOutputter.h : renamed CompilerOutputter.h. * src/cppunit/CompilerTestResultOutputter.cpp : renamed CompilerOutputter.cpp. * examples/cppunittest/CppUnitTestMain.cpp : use factory method CompilerTestResultOutputter::defaultOutputter(). * src/msvc6/DSPlugIn/DSPlugIn.dsp : removed COM registration in post-build step. IT is automatically done by VC++ when the add-in is added. Caused build to failed if the add-in was used in VC++. * NEWS : updated. * src/cppunit/TestAssert.cpp : modified deprecated assert implementations to use Asserter. * examples/cppunittest/XmlTestResultOutputterTest.h : renamed XmlOutputterTest.h. * examples/cppunittest/XmlTestResultOutputterTest.cpp : renamed XmlOutputterTest.cpp. * NEWS : * examples/cppunittest/CppUnitTestMain.cpp : * examples/cppunittest/CppUnitTestMain.dsp : * examples/cppunittest/Makefile.am : * examples/cppunittest/XmlTestResultOutputterTest.h : * examples/cppunittest/XmlTestResultOutputterTest.cpp : * examples/msvc6/CppUniTestApp/CppUnitTestApp.dsp * include/cppunit/CompilerOutputter.h : * include/cppunit/Makefile.am : * include/cppunit/XmlTestResultOutputter.h : * src/cppunit/CompilerOutputter.cpp : * src/cppunit/cppunit.dsp : * src/cppunit/Makefile.am : * src/cppunit/XmlTestResultOutputter.cpp : change due to renaming CompilerTestResultOutputter to CompilerOutputter, XmlTestResultOutputter to XmlOuputter, XmlTestResultOutputterTest to XmlOutputterTest. --- include/cppunit/CompilerOutputter.h | 65 ++++++++++++++ include/cppunit/CompilerTestResultOutputter.h | 62 -------------- include/cppunit/Makefile.am | 4 +- include/cppunit/XmlOutputter.h | 119 ++++++++++++++++++++++++++ include/cppunit/XmlTestResultOutputter.h | 114 ------------------------ 5 files changed, 186 insertions(+), 178 deletions(-) create mode 100644 include/cppunit/CompilerOutputter.h delete mode 100644 include/cppunit/CompilerTestResultOutputter.h create mode 100644 include/cppunit/XmlOutputter.h delete mode 100644 include/cppunit/XmlTestResultOutputter.h (limited to 'include/cppunit') diff --git a/include/cppunit/CompilerOutputter.h b/include/cppunit/CompilerOutputter.h new file mode 100644 index 0000000..9f4840b --- /dev/null +++ b/include/cppunit/CompilerOutputter.h @@ -0,0 +1,65 @@ +#ifndef CPPUNIT_COMPILERTESTRESULTOUTPUTTER_H +#define CPPUNIT_COMPILERTESTRESULTOUTPUTTER_H + +#include +#include + +namespace CppUnit +{ + +class Exception; +class SourceLine; +class Test; +class TestFailure; +class TestResult; + +/*! \class CompilerOutputter + * \brief This class implements output test result in a compiler compatible format. + */ +class CompilerOutputter +{ +public: + /*! Constructs a CompilerOutputter object. + */ + CompilerOutputter( TestResult *result, + std::ostream &stream ); + + /// Destructor. + virtual ~CompilerOutputter(); + + static CompilerOutputter *defaultOutputter( TestResult *result, + std::ostream &stream ); + + virtual void write( ); + + virtual void printSucess(); + virtual void printFailureReport(); + virtual void printFailuresList(); + virtual void printStatistics(); + virtual void printFailureDetail( TestFailure *failure ); + virtual void printFailureLocation( SourceLine sourceLine ); + virtual void printFailureType( TestFailure *failure ); + virtual void printFailedTestName( TestFailure *failure ); + virtual void printFailureMessage( TestFailure *failure ); + virtual void printNotEqualMessage( Exception *thrownException ); + virtual void printDefaultMessage( Exception *thrownException ); + virtual std::string wrap( std::string message ); + +private: + /// Prevents the use of the copy constructor. + CompilerOutputter( const CompilerOutputter © ); + + /// Prevents the use of the copy operator. + void operator =( const CompilerOutputter © ); + +private: + TestResult *m_result; + std::ostream &m_stream; +}; + + +} // namespace CppUnit + + + +#endif // CPPUNIT_COMPILERTESTRESULTOUTPUTTER_H diff --git a/include/cppunit/CompilerTestResultOutputter.h b/include/cppunit/CompilerTestResultOutputter.h deleted file mode 100644 index 8c4514c..0000000 --- a/include/cppunit/CompilerTestResultOutputter.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef CPPUNIT_COMPILERTESTRESULTOUTPUTTER_H -#define CPPUNIT_COMPILERTESTRESULTOUTPUTTER_H - -#include -#include - -namespace CppUnit -{ - -class Exception; -class SourceLine; -class Test; -class TestFailure; -class TestResult; - -/*! \class CompilerTestResultOutputter - * \brief This class implements output test result in a compiler compatible format. - */ -class CompilerTestResultOutputter -{ -public: - /*! Constructs a CompilerTestResultOutputter object. - */ - CompilerTestResultOutputter( TestResult *result, - std::ostream &stream ); - - /// Destructor. - virtual ~CompilerTestResultOutputter(); - - virtual void write( ); - - virtual void printSucess(); - virtual void printFailureReport(); - virtual void printFailuresList(); - virtual void printStatistics(); - virtual void printFailureDetail( TestFailure *failure ); - virtual void printFailureLocation( SourceLine sourceLine ); - virtual void printFailureType( TestFailure *failure ); - virtual void printFailedTestName( TestFailure *failure ); - virtual void printFailureMessage( TestFailure *failure ); - virtual void printNotEqualMessage( Exception *thrownException ); - virtual void printDefaultMessage( Exception *thrownException ); - virtual std::string wrap( std::string message ); - -private: - /// Prevents the use of the copy constructor. - CompilerTestResultOutputter( const CompilerTestResultOutputter © ); - - /// Prevents the use of the copy operator. - void operator =( const CompilerTestResultOutputter © ); - -private: - TestResult *m_result; - std::ostream &m_stream; -}; - - -} // namespace CppUnit - - - -#endif // CPPUNIT_COMPILERTESTRESULTOUTPUTTER_H diff --git a/include/cppunit/Makefile.am b/include/cppunit/Makefile.am index 9e224a5..99dfa65 100644 --- a/include/cppunit/Makefile.am +++ b/include/cppunit/Makefile.am @@ -8,7 +8,7 @@ libcppunitinclude_HEADERS = \ config-msvc6.h \ config-bcb5.h \ Asserter.h \ - CompilerTestResultOutputter.h \ + CompilerOutputter.h \ Exception.h \ NotEqualException.h \ Portability.h \ @@ -24,4 +24,4 @@ libcppunitinclude_HEADERS = \ TextTestResult.h \ TextTestRunner.h \ TestListener.h \ - XmlTestResultOutputter.h + XmlOutputter.h diff --git a/include/cppunit/XmlOutputter.h b/include/cppunit/XmlOutputter.h new file mode 100644 index 0000000..6aeed92 --- /dev/null +++ b/include/cppunit/XmlOutputter.h @@ -0,0 +1,119 @@ +#ifndef CPPUNIT_XMLTESTRESULTOUTPUTTER_H +#define CPPUNIT_XMLTESTRESULTOUTPUTTER_H + +#include +#include +#include +#include +#include + + +namespace CppUnit +{ + +class Test; +class TestFailure; +class TestResult; + + +/*! This class ouputs a TestResult in XML format. + */ +class XmlOutputter +{ +public: + /*! Constructs a XmlOutputter object. + */ + XmlOutputter( TestResult *result, + std::ostream &stream ); + + /// Destructor. + virtual ~XmlOutputter(); + + /*! Write the specified result as an XML document in the specified stream. + * + * Refer to examples/cppunittest/XmlOutputterTest.cpp for example + * of use and XML document structure. + * + * \param result TestResult to write. + * \param stream Output stream the result are wrote into. + */ + virtual void write(); + + /*! This class represents an XML Element. + * \warning This class will probably be replaced with an abstract + * builder in future version. + */ + class 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; + + 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 void addFailedTests( FailedTests &failedTests, + Node *rootNode ); + virtual void addSucessfulTests( FailedTests &failedTests, + Node *rootNode ); + virtual void addStatistics( Node *rootNode ); + virtual void addFailedTest( Test *test, + TestFailure *failure, + int testNumber, + Node *testsNode ); + virtual void addFailureLocation( TestFailure *failure, + Node *testNode ); + virtual void addSucessfulTest( Test *test, + int testNumber, + Node *testsNode ); +protected: + virtual void fillFailedTestsMap( FailedTests &failedTests ); + +protected: + TestResult *m_result; + std::ostream &m_stream; + +private: + /// Prevents the use of the copy constructor. + XmlOutputter( const XmlOutputter © ); + + /// Prevents the use of the copy operator. + void operator =( const XmlOutputter © ); + +private: +}; + + +} // namespace CppUnit + +#endif // CPPUNIT_XMLTESTRESULTOUTPUTTER_H diff --git a/include/cppunit/XmlTestResultOutputter.h b/include/cppunit/XmlTestResultOutputter.h deleted file mode 100644 index 211ce02..0000000 --- a/include/cppunit/XmlTestResultOutputter.h +++ /dev/null @@ -1,114 +0,0 @@ -#ifndef CPPUNIT_XMLTESTRESULTOUTPUTTER_H -#define CPPUNIT_XMLTESTRESULTOUTPUTTER_H - -#include -#include -#include -#include -#include - - -namespace CppUnit -{ - -class Test; -class TestFailure; -class TestResult; - - -/*! This class ouputs a TestResult in XML format. - */ -class XmlTestResultOutputter -{ -public: - /*! Constructs a XmlTestResultOutputter object. - */ - XmlTestResultOutputter(); - - /// Destructor. - virtual ~XmlTestResultOutputter(); - - /*! Write the specified result as an XML document in the specified stream. - * - * Refer to examples/cppunittest/XmlTestResultOutputterTest.cpp for example - * of use and XML document structure. - * - * \param result TestResult to write. - * \param stream Output stream the result are wrote into. - */ - void write( TestResult *result, - std::ostream &stream ); - - /*! This class represents an XML Element. - * \warning This class will probably be replaced with an abstract - * builder in future version. - */ - class 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; - - 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( std::ostream &stream ); - virtual void writeTestsResult( TestResult *result, - std::ostream &stream ); - - typedef std::map FailedTests; - virtual Node *makeRootNode( TestResult *result ); - virtual Node *makeFailedTestsNode( FailedTests &failedTests, - TestResult *result ); - virtual Node *makeSucessfulTestsNode( FailedTests &failedTests, - TestResult *result ); - virtual Node *makeStatisticsNode( TestResult *result ); - virtual Node *makeFailedTestNode( Test *test, - TestFailure *failure, - int testNumber ); - virtual Node *makeFailureLocationNode( TestFailure *failure ); - virtual Node *makeSucessfulTestNode( Test *test, - int testNumber ); -protected: - void fillFailedTestsMap( TestResult *result, - FailedTests &failedTests ); - -private: - /// Prevents the use of the copy constructor. - XmlTestResultOutputter( const XmlTestResultOutputter © ); - - /// Prevents the use of the copy operator. - void operator =( const XmlTestResultOutputter © ); - -private: -}; - - -} // namespace CppUnit - -#endif // CPPUNIT_XMLTESTRESULTOUTPUTTER_H -- cgit v1.2.1