summaryrefslogtreecommitdiff
path: root/src/cppunit/CompilerOutputter.cpp
diff options
context:
space:
mode:
authorBaptiste Lepilleur <gaiacrtn@free.fr>2001-10-14 11:23:31 +0000
committerBaptiste Lepilleur <gaiacrtn@free.fr>2001-10-14 11:23:31 +0000
commite27118dd97d6125d3869b4972eff8da5996a768c (patch)
treec15c08831fe1694f6d2298f1573f3fbb02724dc5 /src/cppunit/CompilerOutputter.cpp
parentff0517a7f94155d1c349c1f241b5f2bf5ba57cd7 (diff)
downloadcppunit-e27118dd97d6125d3869b4972eff8da5996a768c.tar.gz
Include/cppunitui/
include/cppunitui/* : added, Qt TestRunner. * examples/qt/* : added, example showing the use of Qt TestRunner. * src/qttestrunner : added, source of the Qt TestRunner DLL.
Diffstat (limited to 'src/cppunit/CompilerOutputter.cpp')
-rw-r--r--src/cppunit/CompilerOutputter.cpp44
1 files changed, 36 insertions, 8 deletions
diff --git a/src/cppunit/CompilerOutputter.cpp b/src/cppunit/CompilerOutputter.cpp
index aee0ef6..c9f308e 100644
--- a/src/cppunit/CompilerOutputter.cpp
+++ b/src/cppunit/CompilerOutputter.cpp
@@ -1,3 +1,4 @@
+#include <algorithm>
#include <cppunit/NotEqualException.h>
#include <cppunit/SourceLine.h>
#include <cppunit/TestResult.h>
@@ -178,20 +179,47 @@ CompilerOutputter::printStatistics()
std::string
CompilerOutputter::wrap( std::string message )
{
- const int maxLineLength = 80;
+ Lines lines = splitMessageIntoLines( message );
std::string wrapped;
- int index =0;
- while ( index < message.length() )
+ for ( Lines::iterator it = lines.begin(); it != lines.end(); ++it )
{
- std::string line( message.substr( index, maxLineLength ) );
- wrapped += line;
- index += maxLineLength;
- if ( index < message.length() )
- wrapped += "\n";
+ std::string line( *it );
+ const int maxLineLength = 80;
+ int index =0;
+ while ( index < line.length() )
+ {
+ std::string line( line.substr( index, maxLineLength ) );
+ wrapped += line;
+ index += maxLineLength;
+ if ( index < line.length() )
+ wrapped += "\n";
+ }
+ wrapped += '\n';
}
return wrapped;
}
+CompilerOutputter::Lines
+CompilerOutputter::splitMessageIntoLines( std::string message )
+{
+ 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;
+}
+
+
} // namespace CppUnit