summaryrefslogtreecommitdiff
path: root/include/cppunit/tools
diff options
context:
space:
mode:
authorBaptiste Lepilleur <gaiacrtn@free.fr>2002-06-14 19:21:01 +0000
committerBaptiste Lepilleur <gaiacrtn@free.fr>2002-06-14 19:21:01 +0000
commit73a038f1eaa268cec330d971fb550befec6f7798 (patch)
treec3eba5d793e37413889acad5b0b9f70caf89b0f6 /include/cppunit/tools
parentf39e160fba25476de7d41e2f19d756db7ee76dc7 (diff)
downloadcppunit-73a038f1eaa268cec330d971fb550befec6f7798.tar.gz
Include/cppunit/plugin/PlugInManager.
include/cppunit/plugin/PlugInManager.h: * src/cppunit/PlugInManager.cpp: added two methods to use the plug-in interface for Xml Outputter hooks. * include/cppunit/plugin/TestPlugIn.h: added two methods to the plug-in interface for Xml Outputter hooks. * include/cppunit/plugin/TestPlugInAdapter.h: * src/cppunit/plugin/TestPlugInAdapter.cpp: renamed TestPlugInDefaultImpl. Added empty implementation for Xml outputter hook methods. * include/cppunit/tools/StringTools.h: * src/cppunit/tools/StringTools.cpp: added. Functions to manipulate string (conversion, wrapping...) * include/cppunit/tools/XmlElement.h: * src/cppunit/XmlElement.cpp: renamed addNode() to addElement(). Added methods to walk and modify XmlElement (for hook). Added documentation. Use StringTools. * include/cppunit/XmlOutputter.h: * src/cppunit/XmlOutputter.cpp: added hook calls & management. * include/cppunit/XmlOutputterHook.h: * src/cppunit/XmlOutputterHook.cpp: added. Hook to customize XML output. * src/DllPlugInTester/DllPlugInTester.cpp: call plug-in XmlOutputterHook when writing XML output. Modified so that memory is freed before unloading the test plug-in (caused crash when freeing the XmlDocument). * examples/ReadMe.txt: * examples/ClockerPlugIn/ReadMe.txt: added details about the plug-in (usage, xml content...) * examples/ClockerPlugIn/ClockerModel.h: * examples/ClockerPlugIn/ClockerModel.cpp: extracted from ClockerListener. Represents the test hierarchy and tracked time for each test. * examples/ClockerPlugIn/ClockerListener.h: * examples/ClockerPlugIn/ClockerListener.cpp: extracted test hierarchy tracking to ClockerModel. Replaced the 'flat' view option with a 'text' option to print the timed test tree to stdout. * examples/ClockerPlugIn/ClockerPlugIn.cpp: updated to hook the XML output and use the new classes. * examples/ClockerPlugIn/ClockerXmlHook.h: * examples/ClockerPlugIn/ClockerXmlHook.cpp: added. XmlOutputterHook to includes the timed test hierarchy and test timing in the XML output. * examples/cppunittest/XmlElementTest.h: * examples/cppunittest/XmlElementTest.cpp: added new test cases. * examples/cppunittest/XmlOutputterTest.h: * examples/cppunittest/XmlOutputterTest.cpp: added tests for XmlOutputterHook.
Diffstat (limited to 'include/cppunit/tools')
-rw-r--r--include/cppunit/tools/Makefile.am1
-rw-r--r--include/cppunit/tools/StringTools.h27
-rw-r--r--include/cppunit/tools/XmlElement.h85
3 files changed, 110 insertions, 3 deletions
diff --git a/include/cppunit/tools/Makefile.am b/include/cppunit/tools/Makefile.am
index 7035ef7..d06fdb3 100644
--- a/include/cppunit/tools/Makefile.am
+++ b/include/cppunit/tools/Makefile.am
@@ -1,5 +1,6 @@
libcppunitincludedir = $(includedir)/cppunit/tools
libcppunitinclude_HEADERS = \
+ StringTools.h \
XmlElement.h \
XmlDocument.h \ No newline at end of file
diff --git a/include/cppunit/tools/StringTools.h b/include/cppunit/tools/StringTools.h
new file mode 100644
index 0000000..8242c9e
--- /dev/null
+++ b/include/cppunit/tools/StringTools.h
@@ -0,0 +1,27 @@
+#ifndef CPPUNIT_TOOLS_STRINGTOOLS_H
+#define CPPUNIT_TOOLS_STRINGTOOLS_H
+
+#include <cppunit/Portability.h>
+#include <string>
+
+
+namespace CppUnit
+{
+
+/*! \brief Tool functions to manipulate string.
+ */
+namespace StringTools
+{
+
+ std::string CPPUNIT_API toString( int value );
+
+ std::string CPPUNIT_API toString( double value );
+
+
+} // namespace StringTools
+
+
+} // namespace CppUnit
+
+
+#endif // CPPUNIT_TOOLS_STRINGTOOLS_H
diff --git a/include/cppunit/tools/XmlElement.h b/include/cppunit/tools/XmlElement.h
index 323642e..760002d 100644
--- a/include/cppunit/tools/XmlElement.h
+++ b/include/cppunit/tools/XmlElement.h
@@ -22,23 +22,103 @@ class XmlElement;
#endif
-/*! A XML Element.
+/*! \brief A XML Element.
+ *
+ * A XML element has:
+ * - a name, specified on construction,
+ * - a content, specified on construction (may be empty),
+ * - zero or more attributes, added with addAttribute(),
+ * - zero or more child elements, added with addElement().
*/
class CPPUNIT_API XmlElement
{
public:
+ /*! \brief Constructs an element with the specified name and string content.
+ * \param elementName Name of the element. Must not be empty.
+ * \param content Content of the element.
+ */
XmlElement( std::string elementName,
std::string content ="" );
+
+ /*! \brief Constructs an element with the specified name and numeric content.
+ * \param elementName Name of the element. Must not be empty.
+ * \param numericContent Content of the element.
+ */
XmlElement( std::string elementName,
int numericContent );
+
+ /*! \brief Destructs the element and its child elements.
+ */
virtual ~XmlElement();
+ /*! \brief Returns the name of the element.
+ * \return Name of the element.
+ */
+ std::string name() const;
+
+ /*! \brief Returns the content of the element.
+ * \return Content of the element.
+ */
+ std::string content() const;
+
+ /*! \brief Sets the name of the element.
+ * \param name New name for the element.
+ */
+ void setName( const std::string &name );
+
+ /*! \brief Sets the content of the element.
+ * \param content New content for the element.
+ */
+ void setContent( const std::string &content );
+
+ /*! \overload.
+ */
+ void setContent( int numericContent );
+
+ /*! \brief Adds an attribute with the specified string value.
+ * \param attributeName Name of the attribute. Must not be an empty.
+ * \param value Value of the attribute.
+ */
void addAttribute( std::string attributeName,
std::string value );
+
+ /*! \brief Adds an attribute with the specified numeric value.
+ * \param attributeName Name of the attribute. Must not be empty.
+ * \param value Numeric value of the attribute.
+ */
void addAttribute( std::string attributeName,
int numericValue );
- void addNode( XmlElement *element );
+ /*! \brief Adds a child element to the element.
+ * \param element Child element to add. Must not be \c NULL.
+ */
+ void addElement( XmlElement *element );
+
+ /*! \brief Returns the number of child elements.
+ * \return Number of child elements (element added with addElement()).
+ */
+ int elementCount() const;
+
+ /*! \brief Returns the child element at the specified index.
+ * \param index Zero based index of the element to return.
+ * \returns Element at the specified index. Never \c NULL.
+ * \exception std::invalid_argument if \a index < 0 or index >= elementCount().
+ */
+ XmlElement *elementAt( int index ) const;
+
+ /*! \brief Returns the first child element with the specified name.
+ * \param name Name of the child element to return.
+ * \return First child element found which is named \a name.
+ * \exception std::invalid_argument if there is no child element with the specified
+ * name.
+ */
+ XmlElement *elementFor( const std::string &name ) const;
+
+ /*! \brief Returns a XML string that represents the element.
+ * \param indent String of spaces representing the amount of 'indent'.
+ * \return XML string that represents the element, its attributes and its
+ * child elements.
+ */
std::string toString( const std::string &indent = "" ) const;
private:
@@ -46,7 +126,6 @@ private:
std::string attributesAsString() const;
std::string escape( std::string value ) const;
- static std::string asString( int value );
private:
std::string m_name;