summaryrefslogtreecommitdiff
path: root/src/cppunit
diff options
context:
space:
mode:
Diffstat (limited to 'src/cppunit')
-rw-r--r--src/cppunit/XmlOutputter.cpp40
1 files changed, 30 insertions, 10 deletions
diff --git a/src/cppunit/XmlOutputter.cpp b/src/cppunit/XmlOutputter.cpp
index 7b9b2b7..d90513f 100644
--- a/src/cppunit/XmlOutputter.cpp
+++ b/src/cppunit/XmlOutputter.cpp
@@ -62,22 +62,42 @@ XmlOutputter::Node::addNode( Node *node )
std::string
-XmlOutputter::Node::toString() const
+XmlOutputter::Node::toString( const std::string &indent ) const
{
- std::string element = "<";
+ std::string element( indent );
+ element += "<";
element += m_name;
- element += " ";
- element += attributesAsString();
- element += " >\n";
+ if ( !m_attributes.empty() )
+ {
+ element += " ";
+ element += attributesAsString();
+ }
+ element += ">";
- Nodes::const_iterator itNode = m_nodes.begin();
- while ( itNode != m_nodes.end() )
+ if ( !m_nodes.empty() )
{
- const Node *node = *itNode++;
- element += node->toString();
+ element += "\n";
+
+ std::string subNodeIndent( indent + " " );
+ Nodes::const_iterator itNode = m_nodes.begin();
+ while ( itNode != m_nodes.end() )
+ {
+ const Node *node = *itNode++;
+ element += node->toString( subNodeIndent );
+ }
+
+ element += indent;
}
- element += escape( m_content );
+ if ( !m_content.empty() )
+ {
+ element += escape( m_content );
+ if ( !m_nodes.empty() )
+ {
+ element += "\n";
+ element += indent;
+ }
+ }
element += "</";
element += m_name;