From 4746caacaf3821d39543838d2a4b10b1d9dc94d8 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Fri, 5 Apr 2013 20:55:57 +0100 Subject: [PATCH] LineWrapper can indent first line differently to subsequent lines - use this to wrap Given/ When/ Then with indent after the : --- .../internal/catch_console_colour_impl.hpp | 9 +- include/internal/catch_line_wrap.h | 7 +- include/internal/catch_line_wrap.hpp | 29 +- include/reporters/catch_reporter_console.hpp | 19 +- .../CatchSelfTest => SelfTest}/BDDTests.cpp | 4 + .../SelfTest/Baselines/approvedResults.txt | 329 ++++++++++++------ projects/SelfTest/TestMain.cpp | 8 + .../TestCatch/TestCatch/TestCatch.vcproj | 12 + .../CatchSelfTest.xcodeproj/project.pbxproj | 8 +- 9 files changed, 294 insertions(+), 131 deletions(-) rename projects/{XCode4/CatchSelfTest/CatchSelfTest => SelfTest}/BDDTests.cpp (85%) diff --git a/include/internal/catch_console_colour_impl.hpp b/include/internal/catch_console_colour_impl.hpp index 188e36d9..938a5363 100644 --- a/include/internal/catch_console_colour_impl.hpp +++ b/include/internal/catch_console_colour_impl.hpp @@ -32,10 +32,7 @@ namespace { GetConsoleScreenBufferInfo( stdoutHandle, &csbiInfo ); originalAttributes = csbiInfo.wAttributes; } - ~Win32ColourImpl() { - use( Colour::None ); - } - + virtual void use( Colour::Code _colourCode ) { switch( _colourCode ) { case Colour::None: return setTextAttribute( originalAttributes ); @@ -86,10 +83,6 @@ namespace { // https://github.com/philsquared/Catch/pull/131 class PosixColourImpl : public Detail::IColourImpl { public: - PosixColourImpl() { - use( Colour::None ); - } - virtual void use( Colour::Code _colourCode ) { switch( _colourCode ) { case Colour::None: diff --git a/include/internal/catch_line_wrap.h b/include/internal/catch_line_wrap.h index 7cd08055..cfd31df8 100644 --- a/include/internal/catch_line_wrap.h +++ b/include/internal/catch_line_wrap.h @@ -18,7 +18,9 @@ namespace Catch { LineWrapper(); LineWrapper& setIndent( std::size_t _indent ); + LineWrapper& setInitialIndent( std::size_t _initalIndent ); LineWrapper& setRight( std::size_t _right ); + LineWrapper& setTabChar( char _tabChar ); LineWrapper& wrap( std::string const& _str ); @@ -38,12 +40,15 @@ namespace Catch { void wrapInternal( std::string const& _str ); void addLine( const std::string& _line ); bool isWrapPoint( char c ); + std::size_t getCurrentIndent() const; - std::string indent; std::size_t right; std::size_t nextTab; std::size_t tab; + std::size_t indent; + std::size_t initialIndent; std::string wrappableChars; + char tabChar; int recursionCount; std::vector lines; }; diff --git a/include/internal/catch_line_wrap.hpp b/include/internal/catch_line_wrap.hpp index bd41d69a..05e9143b 100644 --- a/include/internal/catch_line_wrap.hpp +++ b/include/internal/catch_line_wrap.hpp @@ -16,12 +16,19 @@ namespace Catch { : right( CATCH_CONFIG_CONSOLE_WIDTH-1 ), nextTab( 0 ), tab( 0 ), + indent( 0 ), + initialIndent( (std::size_t)-1 ), // use indent by default wrappableChars( " [({.,/|\\" ), + tabChar( '\t' ), recursionCount( 0 ) {} LineWrapper& LineWrapper::setIndent( std::size_t _indent ) { - indent = std::string( _indent, ' ' ); + indent = _indent; + return *this; + } + LineWrapper& LineWrapper::setInitialIndent( std::size_t _initialIndent ) { + initialIndent = _initialIndent; return *this; } LineWrapper& LineWrapper::setRight( std::size_t _right ) { @@ -33,13 +40,17 @@ namespace Catch { wrapInternal( _str ); return *this; } + LineWrapper& LineWrapper::setTabChar( char _tabChar ) { + tabChar = _tabChar; + return *this; + } bool LineWrapper::isWrapPoint( char c ) { return wrappableChars.find( c ) != std::string::npos; } void LineWrapper::wrapInternal( std::string const& _str ) { assert( ++recursionCount < 100 ); - std::size_t width = right - indent.size(); + std::size_t width = right - getCurrentIndent(); std::size_t wrapPoint = width-tab; for( std::size_t pos = 0; pos < _str.size(); ++pos ) { if( _str[pos] == '\n' ) @@ -61,7 +72,7 @@ namespace Catch { } return wrapInternal( _str.substr( wrapPoint ) ); } - if( _str[pos] == '\t' ) { + if( _str[pos] == tabChar ) { nextTab = pos; std::string withoutTab = _str.substr( 0, nextTab ) + _str.substr( nextTab+1 ); return wrapInternal( withoutTab ); @@ -89,14 +100,18 @@ namespace Catch { } void LineWrapper::addLine( const std::string& _line ) { - if( tab > 0 ) - lines.push_back( indent + std::string( tab, ' ' ) + _line ); - else - lines.push_back( indent + _line ); + lines.push_back( std::string( tab + getCurrentIndent(), ' ' ) + _line ); if( nextTab > 0 ) tab = nextTab; } + std::size_t LineWrapper::getCurrentIndent() const + { + return (initialIndent != (std::size_t)-1 && lines.empty() ) + ? initialIndent + : indent; + } + } // end namespace Catch #endif // TWOBLUECUBES_CATCH_LINE_WRAP_HPP_INCLUDED diff --git a/include/reporters/catch_reporter_console.hpp b/include/reporters/catch_reporter_console.hpp index f1a798f3..cb50436d 100644 --- a/include/reporters/catch_reporter_console.hpp +++ b/include/reporters/catch_reporter_console.hpp @@ -288,7 +288,8 @@ namespace Catch { if( !sections.empty() ) { typedef std::vector::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"; diff --git a/projects/XCode4/CatchSelfTest/CatchSelfTest/BDDTests.cpp b/projects/SelfTest/BDDTests.cpp similarity index 85% rename from projects/XCode4/CatchSelfTest/CatchSelfTest/BDDTests.cpp rename to projects/SelfTest/BDDTests.cpp index bdde0333..4220c820 100644 --- a/projects/XCode4/CatchSelfTest/CatchSelfTest/BDDTests.cpp +++ b/projects/SelfTest/BDDTests.cpp @@ -61,4 +61,8 @@ SCENARIO( "This is a really long scenario name to see how the list command dea "[very long tags][lots][long][tags][verbose]" "[one very long tag name that should cause line wrapping writing out using the list command]" "[anotherReallyLongTagNameButThisOneHasNoObviousWrapPointsSoShouldSplitWithinAWordUsingADashCharacter]" ) { + GIVEN( "A section name that is so long that it cannot fit in a single console width" ) + WHEN( "The test headers are printed as part of the normal running of the scenario" ) + THEN( "The, deliberately very long and overly verbose (you see what I did there?) section names must wrap, along with an indent" ) + SUCCEED("boo!"); } diff --git a/projects/SelfTest/Baselines/approvedResults.txt b/projects/SelfTest/Baselines/approvedResults.txt index bd8e6d8f..a4af322e 100644 --- a/projects/SelfTest/Baselines/approvedResults.txt +++ b/projects/SelfTest/Baselines/approvedResults.txt @@ -4706,14 +4706,34 @@ with expansion: "four" == "four" ------------------------------------------------------------------------------- -TestMain.cpp:477 +TestMain.cpp:470 + +Long strings can be wrapped + plain string + Indent first line differently +............................................................................... + +TestMain.cpp:475: +PASSED: + CHECK( Catch::LineWrapper() .setRight( 10 ) .setIndent( 4 ) .setInitialIndent( 1 ) .wrap( testString ).toString() == " one two\n three\n four" ) +with expansion: + " one two + three + four" + == + " one two + three + four" + +------------------------------------------------------------------------------- +TestMain.cpp:485 Long strings can be wrapped With newlines No wrapping ............................................................................... -TestMain.cpp:478: +TestMain.cpp:486: PASSED: CHECK( Catch::LineWrapper().setRight( 80 ).wrap( testString ).toString() == testString ) with expansion: @@ -4723,7 +4743,7 @@ with expansion: "one two three four" -TestMain.cpp:479: +TestMain.cpp:487: PASSED: CHECK( Catch::LineWrapper().setRight( 18 ).wrap( testString ).toString() == testString ) with expansion: @@ -4733,7 +4753,7 @@ with expansion: "one two three four" -TestMain.cpp:480: +TestMain.cpp:488: PASSED: CHECK( Catch::LineWrapper().setRight( 10 ).wrap( testString ).toString() == testString ) with expansion: @@ -4744,14 +4764,14 @@ with expansion: three four" ------------------------------------------------------------------------------- -TestMain.cpp:482 +TestMain.cpp:490 Long strings can be wrapped With newlines Trailing newline ............................................................................... -TestMain.cpp:483: +TestMain.cpp:491: PASSED: CHECK( Catch::LineWrapper().setRight( 10 ).wrap( "abcdef\n" ).toString() == "abcdef\n" ) with expansion: @@ -4761,13 +4781,13 @@ with expansion: "abcdef " -TestMain.cpp:484: +TestMain.cpp:492: PASSED: CHECK( Catch::LineWrapper().setRight( 6 ).wrap( "abcdef" ).toString() == "abcdef" ) with expansion: "abcdef" == "abcdef" -TestMain.cpp:485: +TestMain.cpp:493: PASSED: CHECK( Catch::LineWrapper().setRight( 6 ).wrap( "abcdef\n" ).toString() == "abcdef\n" ) with expansion: @@ -4778,14 +4798,14 @@ with expansion: " ------------------------------------------------------------------------------- -TestMain.cpp:487 +TestMain.cpp:495 Long strings can be wrapped With newlines Wrapped once ............................................................................... -TestMain.cpp:488: +TestMain.cpp:496: PASSED: CHECK( Catch::LineWrapper().setRight( 9 ).wrap( testString ).toString() == "one two\nthree\nfour" ) with expansion: @@ -4797,7 +4817,7 @@ with expansion: three four" -TestMain.cpp:489: +TestMain.cpp:497: PASSED: CHECK( Catch::LineWrapper().setRight( 8 ).wrap( testString ).toString() == "one two\nthree\nfour" ) with expansion: @@ -4809,7 +4829,7 @@ with expansion: three four" -TestMain.cpp:490: +TestMain.cpp:498: PASSED: CHECK( Catch::LineWrapper().setRight( 7 ).wrap( testString ).toString() == "one two\nthree\nfour" ) with expansion: @@ -4822,14 +4842,14 @@ with expansion: four" ------------------------------------------------------------------------------- -TestMain.cpp:492 +TestMain.cpp:500 Long strings can be wrapped With newlines Wrapped twice ............................................................................... -TestMain.cpp:493: +TestMain.cpp:501: PASSED: CHECK( Catch::LineWrapper().setRight( 6 ).wrap( testString ).toString() == "one\ntwo\nthree\nfour" ) with expansion: @@ -4843,6 +4863,17 @@ with expansion: three four" +hello +hello +------------------------------------------------------------------------------- +TestMain.cpp:604 + +Strings can be rendered with colour +............................................................................... + + +No assertions in test case, 'Strings can be rendered with colour' + ------------------------------------------------------------------------------- TrickyTests.cpp:32 @@ -5161,6 +5192,40 @@ PASSED: with expansion: true +------------------------------------------------------------------------------- +VariadicMacrosTests.cpp:12 + +Anonymous test case 1 +............................................................................... + +VariadicMacrosTests.cpp:14: +PASSED: +with message: + anonymous test case + +------------------------------------------------------------------------------- +VariadicMacrosTests.cpp:17 + +Test case with one argument +............................................................................... + +VariadicMacrosTests.cpp:19: +PASSED: +with message: + no assertions + +------------------------------------------------------------------------------- +VariadicMacrosTests.cpp:24 + +Variadic macros + Section with one argument +............................................................................... + +VariadicMacrosTests.cpp:26: +PASSED: +with message: + no assertions + ------------------------------------------------------------------------------- BDDTests.cpp:19 @@ -5365,50 +5430,25 @@ with expansion: 0 == 0 ------------------------------------------------------------------------------- -BDDTests.cpp:63 +BDDTests.cpp:66 -Scenario: This is a really long scenario name to see how the list command deals with wrapping +Scenario: This is a really long scenario name to see how the list command + deals with wrapping + Given: A section name that is so long that it cannot fit in a single + console width + When: The test headers are printed as part of the normal running of the + scenario + Then: The, deliberately very long and overly verbose (you see what I did + there?) section names must wrap, along with an indent ............................................................................... - -No assertions in test case, 'Scenario: This is a really long scenario name to see how the list command deals with wrapping' - -------------------------------------------------------------------------------- -VariadicMacrosTests.cpp:12 - -Anonymous test case 1 -............................................................................... - -VariadicMacrosTests.cpp:14: +BDDTests.cpp:67: PASSED: with message: - anonymous test case - -------------------------------------------------------------------------------- -VariadicMacrosTests.cpp:17 - -Test case with one argument -............................................................................... - -VariadicMacrosTests.cpp:19: -PASSED: -with message: - no assertions - -------------------------------------------------------------------------------- -VariadicMacrosTests.cpp:24 - -Variadic macros - Section with one argument -............................................................................... - -VariadicMacrosTests.cpp:26: -PASSED: -with message: - no assertions + boo! =============================================================================== -108 test cases - 48 failed (697 assertions - 105 failed) +109 test cases - 48 failed (699 assertions - 105 failed) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -5729,7 +5769,7 @@ with expansion: 13 test cases - 3 failed (40 assertions - 4 failed) - + @@ -6136,6 +6176,12 @@ An error + + +hello +hello + + @@ -6168,12 +6214,12 @@ TrickyTests.cpp:106 - - - + + + Message from section one @@ -6187,6 +6233,9 @@ Some information Message from section one Message from section two Some information + +hello +hello An error @@ -11262,12 +11311,32 @@ TestMain.cpp" line="468"> +
+
+TestMain.cpp" line="475"> + + Catch::LineWrapper() .setRight( 10 ) .setIndent( 4 ) .setInitialIndent( 1 ) .wrap( testString ).toString() == " one two\n three\n four" + + + " one two + three + four" +== +" one two + three + four" + + + +
+ +
-TestMain.cpp" line="478"> +TestMain.cpp" line="486"> Catch::LineWrapper().setRight( 80 ).wrap( testString ).toString() == testString @@ -11279,7 +11348,7 @@ three four" three four" -TestMain.cpp" line="479"> +TestMain.cpp" line="487"> Catch::LineWrapper().setRight( 18 ).wrap( testString ).toString() == testString @@ -11291,7 +11360,7 @@ three four" three four" -TestMain.cpp" line="480"> +TestMain.cpp" line="488"> Catch::LineWrapper().setRight( 10 ).wrap( testString ).toString() == testString @@ -11309,7 +11378,7 @@ three four"
-TestMain.cpp" line="483"> +TestMain.cpp" line="491"> Catch::LineWrapper().setRight( 10 ).wrap( "abcdef\n" ).toString() == "abcdef\n" @@ -11321,7 +11390,7 @@ TestMain.cpp" line="483"> " -TestMain.cpp" line="484"> +TestMain.cpp" line="492"> Catch::LineWrapper().setRight( 6 ).wrap( "abcdef" ).toString() == "abcdef" @@ -11329,7 +11398,7 @@ TestMain.cpp" line="484"> "abcdef" == "abcdef" -TestMain.cpp" line="485"> +TestMain.cpp" line="493"> Catch::LineWrapper().setRight( 6 ).wrap( "abcdef\n" ).toString() == "abcdef\n" @@ -11347,7 +11416,7 @@ TestMain.cpp" line="485">
-TestMain.cpp" line="488"> +TestMain.cpp" line="496"> Catch::LineWrapper().setRight( 9 ).wrap( testString ).toString() == "one two\nthree\nfour" @@ -11361,7 +11430,7 @@ three four" -TestMain.cpp" line="489"> +TestMain.cpp" line="497"> Catch::LineWrapper().setRight( 8 ).wrap( testString ).toString() == "one two\nthree\nfour" @@ -11375,7 +11444,7 @@ three four" -TestMain.cpp" line="490"> +TestMain.cpp" line="498"> Catch::LineWrapper().setRight( 7 ).wrap( testString ).toString() == "one two\nthree\nfour" @@ -11395,7 +11464,7 @@ four"
-TestMain.cpp" line="493"> +TestMain.cpp" line="501"> Catch::LineWrapper().setRight( 6 ).wrap( testString ).toString() == "one\ntwo\nthree\nfour" @@ -11417,6 +11486,9 @@ four"
+ + + TrickyTests.cpp" line="37"> @@ -11705,6 +11777,18 @@ TrickyTests.cpp" line="335">
+ + + + + + + +
+ +
+ +
@@ -11911,23 +11995,20 @@ BDDTests.cpp" line="54"> - - - - - - - - - -
+
+
+
+ +
+ +
- + - + [Started testing: CatchSelfTest] [Started group: '~dummy'] @@ -13389,21 +13470,35 @@ TestMain.cpp:468: wrapper[3] == "four" succeeded for: "four" == "four" [End of section: 'plain string' All 5 assertions passed] +[Started section: 'plain string'] +[Started section: 'Indent first line differently'] +TestMain.cpp:475: Catch::LineWrapper() .setRight( 10 ) .setIndent( 4 ) .setInitialIndent( 1 ) .wrap( testString ).toString() == " one two\n three\n four" succeeded for: + " one two + three + four" +== +" one two + three + four" +[End of section: 'Indent first line differently' 1 assertion passed] + +[End of section: 'plain string' 1 assertion passed] + [Started section: 'With newlines'] [Started section: 'No wrapping'] -TestMain.cpp:478: Catch::LineWrapper().setRight( 80 ).wrap( testString ).toString() == testString succeeded for: +TestMain.cpp:486: Catch::LineWrapper().setRight( 80 ).wrap( testString ).toString() == testString succeeded for: "one two three four" == "one two three four" -TestMain.cpp:479: Catch::LineWrapper().setRight( 18 ).wrap( testString ).toString() == testString succeeded for: +TestMain.cpp:487: Catch::LineWrapper().setRight( 18 ).wrap( testString ).toString() == testString succeeded for: "one two three four" == "one two three four" -TestMain.cpp:480: Catch::LineWrapper().setRight( 10 ).wrap( testString ).toString() == testString succeeded for: +TestMain.cpp:488: Catch::LineWrapper().setRight( 10 ).wrap( testString ).toString() == testString succeeded for: "one two three four" == @@ -13415,13 +13510,13 @@ three four" [Started section: 'With newlines'] [Started section: 'Trailing newline'] -TestMain.cpp:483: Catch::LineWrapper().setRight( 10 ).wrap( "abcdef\n" ).toString() == "abcdef\n" succeeded for: "abcdef +TestMain.cpp:491: Catch::LineWrapper().setRight( 10 ).wrap( "abcdef\n" ).toString() == "abcdef\n" succeeded for: "abcdef " == "abcdef " -TestMain.cpp:484: Catch::LineWrapper().setRight( 6 ).wrap( "abcdef" ).toString() == "abcdef" succeeded for: "abcdef" == "abcdef" -TestMain.cpp:485: Catch::LineWrapper().setRight( 6 ).wrap( "abcdef\n" ).toString() == "abcdef\n" succeeded for: "abcdef +TestMain.cpp:492: Catch::LineWrapper().setRight( 6 ).wrap( "abcdef" ).toString() == "abcdef" succeeded for: "abcdef" == "abcdef" +TestMain.cpp:493: Catch::LineWrapper().setRight( 6 ).wrap( "abcdef\n" ).toString() == "abcdef\n" succeeded for: "abcdef " == "abcdef @@ -13432,7 +13527,7 @@ TestMain.cpp:485: Catch::LineWrapper().setRight( 6 ).wrap( "abcdef\n" ).toString [Started section: 'With newlines'] [Started section: 'Wrapped once'] -TestMain.cpp:488: Catch::LineWrapper().setRight( 9 ).wrap( testString ).toString() == "one two\nthree\nfour" succeeded for: +TestMain.cpp:496: Catch::LineWrapper().setRight( 9 ).wrap( testString ).toString() == "one two\nthree\nfour" succeeded for: "one two three four" @@ -13440,7 +13535,7 @@ four" "one two three four" -TestMain.cpp:489: Catch::LineWrapper().setRight( 8 ).wrap( testString ).toString() == "one two\nthree\nfour" succeeded for: +TestMain.cpp:497: Catch::LineWrapper().setRight( 8 ).wrap( testString ).toString() == "one two\nthree\nfour" succeeded for: "one two three four" @@ -13448,7 +13543,7 @@ four" "one two three four" -TestMain.cpp:490: Catch::LineWrapper().setRight( 7 ).wrap( testString ).toString() == "one two\nthree\nfour" succeeded for: +TestMain.cpp:498: Catch::LineWrapper().setRight( 7 ).wrap( testString ).toString() == "one two\nthree\nfour" succeeded for: "one two three four" @@ -13462,7 +13557,7 @@ four" [Started section: 'With newlines'] [Started section: 'Wrapped twice'] -TestMain.cpp:493: Catch::LineWrapper().setRight( 6 ).wrap( testString ).toString() == "one\ntwo\nthree\nfour" succeeded for: +TestMain.cpp:501: Catch::LineWrapper().setRight( 6 ).wrap( testString ).toString() == "one\ntwo\nthree\nfour" succeeded for: "one two three @@ -13476,7 +13571,15 @@ four" [End of section: 'With newlines' 1 assertion passed] -[Finished: 'Long strings can be wrapped' All tests passed (31 assertions in 1 test case)] +[Finished: 'Long strings can be wrapped' All tests passed (32 assertions in 1 test case)] +hello +hello + +[Running: Strings can be rendered with colour] + +No assertions in test case, 'Strings can be rendered with colour' + +[Finished: 'Strings can be rendered with colour' 1 test case failed (1 assertion failed)] [Running: ./succeeding/Tricky/std::pair] TrickyTests.cpp:37: (std::pair( 1, 2 )) == aNicePair succeeded for: std::pair( 1, 2 ) == std::pair( 1, 2 ) @@ -13579,6 +13682,24 @@ TrickyTests.cpp:335: Catch::isTrue( true ) succeeded for: true [Finished: 'Assertions then sections' All tests passed (6 assertions in 1 test case)] +[Running: Anonymous test case 1] +VariadicMacrosTests.cpp:14: succeeded +[with message: anonymous test case] +[Finished: 'Anonymous test case 1' All tests passed (1 assertion in 1 test case)] + +[Running: Test case with one argument] +VariadicMacrosTests.cpp:19: succeeded +[with message: no assertions] +[Finished: 'Test case with one argument' All tests passed (1 assertion in 1 test case)] + +[Running: Variadic macros] +[Started section: 'Section with one argument'] +VariadicMacrosTests.cpp:26: succeeded +[with message: no assertions] +[End of section: 'Section with one argument' 1 assertion passed] + +[Finished: 'Variadic macros' All tests passed (1 assertion in 1 test case)] + [Running: Scenario: Do that thing with the thing] [Started section: ' Given: This stuff exists'] [Started section: ' When: I do this'] @@ -13660,32 +13781,22 @@ BDDTests.cpp:54: v.size() == 0 succeeded for: 0 == 0 [Finished: 'Scenario: Vector resizing affects size and capacity' All tests passed (15 assertions in 1 test case)] [Running: Scenario: This is a really long scenario name to see how the list command deals with wrapping] +[Started section: ' Given: A section name that is so long that it cannot fit in a single console width'] +[Started section: ' When: The test headers are printed as part of the normal running of the scenario'] +[Started section: ' Then: The, deliberately very long and overly verbose (you see what I did there?) section names must wrap, along with an indent'] +BDDTests.cpp:67: succeeded +[with message: boo!] +[End of section: ' Then: The, deliberately very long and overly verbose (you see what I did there?) section names must wrap, along with an indent' 1 assertion passed] -No assertions in test case, 'Scenario: This is a really long scenario name to see how the list command deals with wrapping' +[End of section: ' When: The test headers are printed as part of the normal running of the scenario' 1 assertion passed] -[Finished: 'Scenario: This is a really long scenario name to see how the list command deals with wrapping' 1 test case failed (1 assertion failed)] +[End of section: ' Given: A section name that is so long that it cannot fit in a single console width' 1 assertion passed] -[Running: Anonymous test case 1] -VariadicMacrosTests.cpp:14: succeeded -[with message: anonymous test case] -[Finished: 'Anonymous test case 1' All tests passed (1 assertion in 1 test case)] - -[Running: Test case with one argument] -VariadicMacrosTests.cpp:19: succeeded -[with message: no assertions] -[Finished: 'Test case with one argument' All tests passed (1 assertion in 1 test case)] - -[Running: Variadic macros] -[Started section: 'Section with one argument'] -VariadicMacrosTests.cpp:26: succeeded -[with message: no assertions] -[End of section: 'Section with one argument' 1 assertion passed] - -[Finished: 'Variadic macros' All tests passed (1 assertion in 1 test case)] -[End of group: '~dummy'. 48 of 108 test cases failed (105 of 697 assertions failed)] +[Finished: 'Scenario: This is a really long scenario name to see how the list command deals with wrapping' All tests passed (1 assertion in 1 test case)] +[End of group: '~dummy'. 48 of 109 test cases failed (105 of 699 assertions failed)] -[Testing completed. 48 of 108 test cases failed (105 of 697 assertions failed)] +[Testing completed. 48 of 109 test cases failed (105 of 699 assertions failed)] [Started testing: CatchSelfTest] [Started group: '~dummy'] diff --git a/projects/SelfTest/TestMain.cpp b/projects/SelfTest/TestMain.cpp index 579caae5..e1a44be0 100644 --- a/projects/SelfTest/TestMain.cpp +++ b/projects/SelfTest/TestMain.cpp @@ -467,6 +467,14 @@ TEST_CASE( "Long strings can be wrapped", "[wrap]" ) { CHECK( wrapper[2] == "three" ); CHECK( wrapper[3] == "four" ); } + SECTION( "Indent first line differently", "" ) { + CHECK( Catch::LineWrapper() + .setRight( 10 ) + .setIndent( 4 ) + .setInitialIndent( 1 ) + .wrap( testString ).toString() == " one two\n three\n four" ); + } + } SECTION( "With newlines", "" ) { diff --git a/projects/VS2008/TestCatch/TestCatch/TestCatch.vcproj b/projects/VS2008/TestCatch/TestCatch/TestCatch.vcproj index 591fd8cc..c094bb38 100644 --- a/projects/VS2008/TestCatch/TestCatch/TestCatch.vcproj +++ b/projects/VS2008/TestCatch/TestCatch/TestCatch.vcproj @@ -343,6 +343,14 @@ + + + + @@ -375,6 +383,10 @@ RelativePath="..\..\..\SelfTest\TrickyTests.cpp" > + +