LineWrapper can indent first line differently to subsequent lines

- use this to wrap Given/ When/ Then with indent after the :
This commit is contained in:
Phil Nash
2013-04-05 20:55:57 +01:00
parent f186a912d4
commit 4746caacaf
9 changed files with 294 additions and 131 deletions

View File

@@ -288,7 +288,8 @@ namespace Catch {
if( !sections.empty() ) {
typedef std::vector<ThreadedSectionInfo*>::const_reverse_iterator It;
for( It it = sections.rbegin(), itEnd = sections.rend(); it != itEnd; ++it )
stream << " " << (*it)->name << "\n";
printUserString( (*it)->name, 2 );
}
}
stream << getDots() << "\n" << std::endl;
@@ -306,10 +307,24 @@ namespace Catch {
}
{
Colour colourGuard( Colour::Headers );
stream << _name << "\n";
printUserString( _name );
}
}
// if string has a : in first line will set indent to follow it on
// subsequent lines
void printUserString( std::string const& _string, std::size_t indent = 0 ) {
std::size_t i = _string.find( ": " );
if( i != std::string::npos )
i+=2;
else
i = 0;
stream << LineWrapper()
.setIndent( indent+i)
.setInitialIndent( indent )
.wrap( _string ) << "\n";
}
void printTotals( const Totals& totals ) {
if( totals.assertions.total() == 0 ) {
stream << "No tests ran";