summaryrefslogtreecommitdiff
path: root/include/cppunit
diff options
context:
space:
mode:
authorBaptiste Lepilleur <gaiacrtn@free.fr>2002-06-16 16:55:58 +0000
committerBaptiste Lepilleur <gaiacrtn@free.fr>2002-06-16 16:55:58 +0000
commit0a810d68d0550ba6f7f28f2e0dfcef691bdca7b4 (patch)
treea060d291bf0dfb6c75720ecbce7f27927b326a5b /include/cppunit
parent73a038f1eaa268cec330d971fb550befec6f7798 (diff)
downloadcppunit-0a810d68d0550ba6f7f28f2e0dfcef691bdca7b4.tar.gz
Release 1.
release 1.9.8 * include/cppunit/plugin/TestPlugIn.h: updated documentation. * include/cppunit/tools/XmlDocument.h: updated documentation. * include/cppunit/tools/StringTools.h: * src/cppunit/StringTools.cpp: added split() and wrap() functions. * include/cppunit/CompilerOutputter.h: * src/cppunit/CompilerOutputter.cpp: extracted wrap() and splitMessageIntoLines() to StringTools. * include/cppunit/XmlOutputterHook.h: * src/cppunit/XmlOutputterHook.cpp: removed rooNode parameter from beginDocument() and endDocument(). It can be retreive from document. Renamed 'node' occurences to 'element'. * include/cppunit/XmlOutputter.h: * src/cppunit/XmlOutputter.cpp: updated against XmlOutputterHook changes. Renamed 'node' occurences to 'element'. * examples/ClockerPlugIn/ClockerXmlHook.h: * examples/ClockerPlugIn/ClockerXmlHook.cpp: updated against XmlOutputterHook changes. * examples/cppunittest/XmlElementTest.h: * examples/cppunittest/XmlElementTest.cpp: Renamed 'node' occurences to 'element'. * examples/cppunittest/XmlOutputterTest.cpp: updated against XmlOutputterHook changes. * examples/cppunittest/StringToolsTest.h: * examples/cppunittest/StringToolsTest.cpp: added. Unit tests for StringTools. Turn out that VC++ dismiss empty lines in tools output, which is the reason why empty lines where not printed in CompilerOutputter.
Diffstat (limited to 'include/cppunit')
-rw-r--r--include/cppunit/CompilerOutputter.h11
-rw-r--r--include/cppunit/XmlOutputter.h12
-rw-r--r--include/cppunit/XmlOutputterHook.h51
-rw-r--r--include/cppunit/plugin/TestPlugIn.h5
-rw-r--r--include/cppunit/tools/StringTools.h8
-rw-r--r--include/cppunit/tools/XmlDocument.h3
6 files changed, 71 insertions, 19 deletions
diff --git a/include/cppunit/CompilerOutputter.h b/include/cppunit/CompilerOutputter.h
index 5b9c418..a87cabd 100644
--- a/include/cppunit/CompilerOutputter.h
+++ b/include/cppunit/CompilerOutputter.h
@@ -105,6 +105,12 @@ public:
void write();
+ void setNoWrap();
+
+ void setWrapColumn( int wrapColumn );
+
+ int wrapColumn() const;
+
virtual void printSuccess();
virtual void printFailureReport();
virtual void printFailuresList();
@@ -114,7 +120,6 @@ public:
virtual void printFailureType( TestFailure *failure );
virtual void printFailedTestName( TestFailure *failure );
virtual void printFailureMessage( TestFailure *failure );
- virtual std::string wrap( std::string message );
private:
/// Prevents the use of the copy constructor.
@@ -128,13 +133,11 @@ private:
virtual std::string extractBaseName( const std::string &fileName ) const;
- typedef std::vector<std::string> Lines;
- static Lines splitMessageIntoLines( std::string message );
-
private:
TestResultCollector *m_result;
std::ostream &m_stream;
std::string m_locationFormat;
+ int m_wrapColumn;
};
diff --git a/include/cppunit/XmlOutputter.h b/include/cppunit/XmlOutputter.h
index dc16913..190ed70 100644
--- a/include/cppunit/XmlOutputter.h
+++ b/include/cppunit/XmlOutputter.h
@@ -78,17 +78,19 @@ public:
typedef std::map<Test *,TestFailure*> FailedTests;
- /*! Returns the root element with its children.
+ /*! Sets the root element and adds its children.
+ *
+ * Set the root element of the XML Document and add its child elements.
*
* For all hooks, call beginDocument() just after creating the root element (it
* is empty at this time), and endDocument() once all the datas have been added
* to the root element.
- *
- * \return Root element.
*/
- virtual XmlElement *makeRootNode();
+ virtual void setRootNode();
+
virtual void addFailedTests( FailedTests &failedTests,
XmlElement *rootNode );
+
virtual void addSuccessfulTests( FailedTests &failedTests,
XmlElement *rootNode );
@@ -111,7 +113,7 @@ public:
XmlElement *testsNode );
virtual void addFailureLocation( TestFailure *failure,
- XmlElement *testNode );
+ XmlElement *testElement );
/*! Adds a successful test to the successful tests node.
diff --git a/include/cppunit/XmlOutputterHook.h b/include/cppunit/XmlOutputterHook.h
index b67c6cf..57d1440 100644
--- a/include/cppunit/XmlOutputterHook.h
+++ b/include/cppunit/XmlOutputterHook.h
@@ -15,27 +15,60 @@ class XmlElement;
/*! \brief Hook to customize Xml output.
+ *
+ * XmlOutputterHook can be passed to XmlOutputter to customize the XmlDocument.
+ *
+ * Common customizations are:
+ * - adding some datas to successfull or failed test with
+ * failTestAdded() and successfulTestAdded(),
+ * - adding some statistics with statisticsAdded(),
+ * - adding other datas with beginDocument() or endDocument().
+ *
+ * See examples/ClockerPlugIn which makes use of most the hook.
+ *
+ * %Test plug-ins can also implement hook to customize XML output.
+ *
+ * \see XmlOutputter, CppUnitTestPlugIn.
*/
class CPPUNIT_API XmlOutputterHook
{
public:
- virtual void beginDocument( XmlDocument *document,
- XmlElement *rootNode );
-
- virtual void endDocument( XmlDocument *document,
- XmlElement *rootNode );
-
+ /*! Called before any elements is added to the root element.
+ * \param document XML Document being created.
+ */
+ virtual void beginDocument( XmlDocument *document );
+
+ /*! Called after adding all elements to the root element.
+ * \param document XML Document being created.
+ */
+ virtual void endDocument( XmlDocument *document );
+
+ /*! Called after adding a fail test element.
+ * \param document XML Document being created.
+ * \param testElement <FailedTest> element.
+ * \param test Test that failed.
+ * \param failure Test failure data.
+ */
virtual void failTestAdded( XmlDocument *document,
- XmlElement *testNode,
+ XmlElement *testElement,
Test *test,
TestFailure *failure );
+ /*! Called after adding a successful test element.
+ * \param document XML Document being created.
+ * \param testElement <Test> element.
+ * \param test Test that was successful.
+ */
virtual void successfulTestAdded( XmlDocument *document,
- XmlElement *testNode,
+ XmlElement *testElement,
Test *test );
+ /*! Called after adding the statistic element.
+ * \param document XML Document being created.
+ * \param statisticsElement <Statistics> element.
+ */
virtual void statisticsAdded( XmlDocument *document,
- XmlElement *statisticsNode );
+ XmlElement *statisticsElement );
};
diff --git a/include/cppunit/plugin/TestPlugIn.h b/include/cppunit/plugin/TestPlugIn.h
index 0eaf960..b77d50b 100644
--- a/include/cppunit/plugin/TestPlugIn.h
+++ b/include/cppunit/plugin/TestPlugIn.h
@@ -32,8 +32,11 @@ class XmlOutputter;
* addListener() and removeListener() are called respectively before and after
* the test run.
*
+ * addXmlOutputterHooks() and removeXmlOutputterHooks() are called respectively
+ * before and after writing the XML output using a XmlOutputter.
+ *
* \see CPPUNIT_PLUGIN_IMPLEMENT, CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL
- * \see TestPlugInDefaultImpl.
+ * \see CppUnit::TestPlugInDefaultImpl, CppUnit::XmlOutputter.
*/
struct CppUnitTestPlugIn
{
diff --git a/include/cppunit/tools/StringTools.h b/include/cppunit/tools/StringTools.h
index 8242c9e..cc325dc 100644
--- a/include/cppunit/tools/StringTools.h
+++ b/include/cppunit/tools/StringTools.h
@@ -3,6 +3,7 @@
#include <cppunit/Portability.h>
#include <string>
+#include <vector>
namespace CppUnit
@@ -13,10 +14,17 @@ namespace CppUnit
namespace StringTools
{
+ typedef std::vector<std::string> Strings;
+
std::string CPPUNIT_API toString( int value );
std::string CPPUNIT_API toString( double value );
+ Strings CPPUNIT_API split( const std::string &text,
+ char separator );
+
+ std::string CPPUNIT_API wrap( const std::string &text,
+ int wrapColumn = 79 );
} // namespace StringTools
diff --git a/include/cppunit/tools/XmlDocument.h b/include/cppunit/tools/XmlDocument.h
index 3ed4107..564fb20 100644
--- a/include/cppunit/tools/XmlDocument.h
+++ b/include/cppunit/tools/XmlDocument.h
@@ -18,6 +18,9 @@ class XmlElement;
/*! A XML Document.
+ *
+ * A XmlDocument represents a XML file. It holds a pointer on the root XmlElement
+ * of the document. It also holds the encoding and style sheet used.
*/
class CPPUNIT_API XmlDocument
{