summaryrefslogtreecommitdiff
path: root/src/cppunit/CompilerOutputter.cpp
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 /src/cppunit/CompilerOutputter.cpp
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 'src/cppunit/CompilerOutputter.cpp')
-rw-r--r--src/cppunit/CompilerOutputter.cpp58
1 files changed, 20 insertions, 38 deletions
diff --git a/src/cppunit/CompilerOutputter.cpp b/src/cppunit/CompilerOutputter.cpp
index 4bc9e31..4628d4c 100644
--- a/src/cppunit/CompilerOutputter.cpp
+++ b/src/cppunit/CompilerOutputter.cpp
@@ -4,6 +4,7 @@
#include <cppunit/TestResultCollector.h>
#include <cppunit/CompilerOutputter.h>
#include <algorithm>
+#include <cppunit/tools/StringTools.h>
namespace CppUnit
@@ -15,6 +16,7 @@ CompilerOutputter::CompilerOutputter( TestResultCollector *result,
: m_result( result )
, m_stream( stream )
, m_locationFormat( locationFormat )
+ , m_wrapColumn( 79 )
{
}
@@ -170,7 +172,12 @@ CompilerOutputter::printFailureMessage( TestFailure *failure )
m_stream << std::endl;
Exception *thrownException = failure->thrownException();
m_stream << thrownException->message().shortDescription() << std::endl;
- m_stream << wrap( thrownException->message().details() ) << std::endl;
+
+ std::string message = thrownException->message().details();
+ if ( m_wrapColumn > 0 )
+ message = StringTools::wrap( message, m_wrapColumn );
+
+ m_stream << message << std::endl;
}
@@ -186,50 +193,25 @@ CompilerOutputter::printStatistics()
}
-std::string
-CompilerOutputter::wrap( std::string message )
+void
+CompilerOutputter::setWrapColumn( int wrapColumn )
{
- Lines lines = splitMessageIntoLines( message );
- std::string wrapped;
- for ( Lines::iterator it = lines.begin(); it != lines.end(); ++it )
- {
- std::string line( *it );
- const int maxLineLength = 79;
- int index =0;
- while ( index < line.length() )
- {
- std::string lineSlice( line.substr( index, maxLineLength ) );
- wrapped += lineSlice;
- index += maxLineLength;
- if ( index < line.length() )
- wrapped += "\n";
- }
- wrapped += '\n';
- }
- return wrapped;
+ m_wrapColumn = wrapColumn;
}
-CompilerOutputter::Lines
-CompilerOutputter::splitMessageIntoLines( std::string message )
+void
+CompilerOutputter::setNoWrap()
{
- Lines lines;
-
- std::string::iterator itStart = message.begin();
- while ( true )
- {
- std::string::iterator itEol = std::find( itStart,
- message.end(),
- '\n' );
- lines.push_back( message.substr( itStart - message.begin(),
- itEol - itStart ) );
- if ( itEol == message.end() )
- break;
- itStart = itEol +1;
- }
- return lines;
+ m_wrapColumn = 0;
}
+int
+CompilerOutputter::wrapColumn() const
+{
+ return m_wrapColumn;
+}
+
} // namespace CppUnit