Fixed line wrap bug

Added line wrap tests and modified wrap algo to wrap within words using a -
This commit is contained in:
Phil Nash
2013-03-25 09:20:51 +00:00
parent 29426b6359
commit 2927c240a1
2 changed files with 42 additions and 3 deletions

View File

@@ -25,8 +25,14 @@ namespace Catch {
for( std::size_t pos = 0; pos < paragraph.size(); ++pos ) {
if( pos == width ) {
addIndent( os, indent );
os << paragraph.substr( 0, wrapPoint ) << "\n";
return recursivelyWrapLine( os, paragraph.substr( wrapPoint+1 ), columns, indent+tab );
if( paragraph[wrapPoint] == ' ' ) {
os << paragraph.substr( 0, wrapPoint ) << "\n";
while( paragraph[++wrapPoint] == ' ' );
}
else {
os << paragraph.substr( 0, --wrapPoint ) << "-\n";
}
return recursivelyWrapLine( os, paragraph.substr( wrapPoint ), columns, indent+tab );
}
if( paragraph[pos] == '\t' ) {
tab = pos;