From 58d8bc6985a70e537cfcc4959dfc405ba9cb2a00 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Thu, 20 Jul 2017 23:09:50 +0100 Subject: [PATCH] Removed Text tests (TextFlow has it's own test suite) --- .../Baselines/console.std.approved.txt | 6 +- .../Baselines/console.sw.approved.txt | 580 +--------------- .../SelfTest/Baselines/junit.sw.approved.txt | 25 +- .../SelfTest/Baselines/xml.sw.approved.txt | 642 +----------------- projects/SelfTest/TestMain.cpp | 214 +----- 5 files changed, 28 insertions(+), 1439 deletions(-) diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index a19e84c5..9e41f7f5 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -684,8 +684,6 @@ MatchersTests.cpp:: FAILED: with expansion: "this string contains 'abc' as a substring" starts with: "string" -hello -hello ------------------------------------------------------------------------------- Tabs and newlines show in output ------------------------------------------------------------------------------- @@ -1018,6 +1016,6 @@ with expansion: "{?}" == "1" =============================================================================== -test cases: 185 | 134 passed | 47 failed | 4 failed as expected -assertions: 938 | 821 passed | 96 failed | 21 failed as expected +test cases: 182 | 131 passed | 47 failed | 4 failed as expected +assertions: 896 | 779 passed | 96 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index 4373d02f..971c0e32 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -1781,544 +1781,6 @@ PASSED: with expansion: 1.23 <= Approx( 1.22 ) -------------------------------------------------------------------------------- -Long strings can be wrapped - plain string - No wrapping -------------------------------------------------------------------------------- -TestMain.cpp: -............................................................................... - -TestMain.cpp:: -PASSED: - CHECK( Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString ) -with expansion: - "one two three four" - == - "one two three four" - -TestMain.cpp:: -PASSED: - CHECK( Text( testString, TextAttributes().setWidth( 18 ) ).toString() == testString ) -with expansion: - "one two three four" - == - "one two three four" - -------------------------------------------------------------------------------- -Long strings can be wrapped - plain string - Wrapped once -------------------------------------------------------------------------------- -TestMain.cpp: -............................................................................... - -TestMain.cpp:: -PASSED: - CHECK( Text( testString, TextAttributes().setWidth( 17 ) ).toString() == "one two three\nfour" ) -with expansion: - "one two three - four" - == - "one two three - four" - -TestMain.cpp:: -PASSED: - CHECK( Text( testString, TextAttributes().setWidth( 16 ) ).toString() == "one two three\nfour" ) -with expansion: - "one two three - four" - == - "one two three - four" - -TestMain.cpp:: -PASSED: - CHECK( Text( testString, TextAttributes().setWidth( 14 ) ).toString() == "one two three\nfour" ) -with expansion: - "one two three - four" - == - "one two three - four" - -TestMain.cpp:: -PASSED: - CHECK( Text( testString, TextAttributes().setWidth( 13 ) ).toString() == "one two three\nfour" ) -with expansion: - "one two three - four" - == - "one two three - four" - -TestMain.cpp:: -PASSED: - CHECK( Text( testString, TextAttributes().setWidth( 12 ) ).toString() == "one two\nthree four" ) -with expansion: - "one two - three four" - == - "one two - three four" - -------------------------------------------------------------------------------- -Long strings can be wrapped - plain string - Wrapped twice -------------------------------------------------------------------------------- -TestMain.cpp: -............................................................................... - -TestMain.cpp:: -PASSED: - CHECK( Text( testString, TextAttributes().setWidth( 9 ) ).toString() == "one two\nthree\nfour" ) -with expansion: - "one two - three - four" - == - "one two - three - four" - -TestMain.cpp:: -PASSED: - CHECK( Text( testString, TextAttributes().setWidth( 8 ) ).toString() == "one two\nthree\nfour" ) -with expansion: - "one two - three - four" - == - "one two - three - four" - -TestMain.cpp:: -PASSED: - CHECK( Text( testString, TextAttributes().setWidth( 7 ) ).toString() == "one two\nthree\nfour" ) -with expansion: - "one two - three - four" - == - "one two - three - four" - -------------------------------------------------------------------------------- -Long strings can be wrapped - plain string - Wrapped three times -------------------------------------------------------------------------------- -TestMain.cpp: -............................................................................... - -TestMain.cpp:: -PASSED: - CHECK( Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one\ntwo\nthree\nfour" ) -with expansion: - "one - two - three - four" - == - "one - two - three - four" - -TestMain.cpp:: -PASSED: - CHECK( Text( testString, TextAttributes().setWidth( 5 ) ).toString() == "one\ntwo\nthree\nfour" ) -with expansion: - "one - two - three - four" - == - "one - two - three - four" - -------------------------------------------------------------------------------- -Long strings can be wrapped - plain string - Short wrap -------------------------------------------------------------------------------- -TestMain.cpp: -............................................................................... - -TestMain.cpp:: -PASSED: - CHECK( Text( "abcdef", TextAttributes().setWidth( 4 ) ).toString() == "abc-\ndef" ) -with expansion: - "abc- - def" - == - "abc- - def" - -TestMain.cpp:: -PASSED: - CHECK( Text( "abcdefg", TextAttributes().setWidth( 4 ) ).toString() == "abc-\ndefg" ) -with expansion: - "abc- - defg" - == - "abc- - defg" - -TestMain.cpp:: -PASSED: - CHECK( Text( "abcdefgh", TextAttributes().setWidth( 4 ) ).toString() == "abc-\ndef-\ngh" ) -with expansion: - "abc- - def- - gh" - == - "abc- - def- - gh" - -TestMain.cpp:: -PASSED: - CHECK( Text( testString, TextAttributes().setWidth( 4 ) ).toString() == "one\ntwo\nthr-\nee\nfour" ) -with expansion: - "one - two - thr- - ee - four" - == - "one - two - thr- - ee - four" - -TestMain.cpp:: -PASSED: - CHECK( Text( testString, TextAttributes().setWidth( 3 ) ).toString() == "one\ntwo\nth-\nree\nfo-\nur" ) -with expansion: - "one - two - th- - ree - fo- - ur" - == - "one - two - th- - ree - fo- - ur" - -------------------------------------------------------------------------------- -Long strings can be wrapped - plain string - As container -------------------------------------------------------------------------------- -TestMain.cpp: -............................................................................... - -TestMain.cpp:: -PASSED: - REQUIRE( text.size() == 4 ) -with expansion: - 4 == 4 - -TestMain.cpp:: -PASSED: - CHECK( text[0] == "one" ) -with expansion: - "one" == "one" - -TestMain.cpp:: -PASSED: - CHECK( text[1] == "two" ) -with expansion: - "two" == "two" - -TestMain.cpp:: -PASSED: - CHECK( text[2] == "three" ) -with expansion: - "three" == "three" - -TestMain.cpp:: -PASSED: - CHECK( text[3] == "four" ) -with expansion: - "four" == "four" - -------------------------------------------------------------------------------- -Long strings can be wrapped - plain string - Indent first line differently -------------------------------------------------------------------------------- -TestMain.cpp: -............................................................................... - -TestMain.cpp:: -PASSED: - CHECK( text.toString() == " one two\n three\n four" ) -with expansion: - " one two - three - four" - == - " one two - three - four" - -------------------------------------------------------------------------------- -Long strings can be wrapped - With newlines - No wrapping -------------------------------------------------------------------------------- -TestMain.cpp: -............................................................................... - -TestMain.cpp:: -PASSED: - CHECK( Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString ) -with expansion: - "one two - three four" - == - "one two - three four" - -TestMain.cpp:: -PASSED: - CHECK( Text( testString, TextAttributes().setWidth( 18 ) ).toString() == testString ) -with expansion: - "one two - three four" - == - "one two - three four" - -TestMain.cpp:: -PASSED: - CHECK( Text( testString, TextAttributes().setWidth( 10 ) ).toString() == testString ) -with expansion: - "one two - three four" - == - "one two - three four" - -------------------------------------------------------------------------------- -Long strings can be wrapped - With newlines - Trailing newline -------------------------------------------------------------------------------- -TestMain.cpp: -............................................................................... - -TestMain.cpp:: -PASSED: - CHECK( Text( "abcdef\n", TextAttributes().setWidth( 10 ) ).toString() == "abcdef" ) -with expansion: - "abcdef" == "abcdef" - -TestMain.cpp:: -PASSED: - CHECK( Text( "abcdef", TextAttributes().setWidth( 6 ) ).toString() == "abcdef" ) -with expansion: - "abcdef" == "abcdef" - -TestMain.cpp:: -PASSED: - CHECK( Text( "abcdef\n", TextAttributes().setWidth( 6 ) ).toString() == "abcdef" ) -with expansion: - "abcdef" == "abcdef" - -TestMain.cpp:: -PASSED: - CHECK( Text( "abcdef\n", TextAttributes().setWidth( 5 ) ).toString() == "abcd-\nef" ) -with expansion: - "abcd- - ef" - == - "abcd- - ef" - -------------------------------------------------------------------------------- -Long strings can be wrapped - With newlines - Wrapped once -------------------------------------------------------------------------------- -TestMain.cpp: -............................................................................... - -TestMain.cpp:: -PASSED: - CHECK( Text( testString, TextAttributes().setWidth( 9 ) ).toString() == "one two\nthree\nfour" ) -with expansion: - "one two - three - four" - == - "one two - three - four" - -TestMain.cpp:: -PASSED: - CHECK( Text( testString, TextAttributes().setWidth( 8 ) ).toString() == "one two\nthree\nfour" ) -with expansion: - "one two - three - four" - == - "one two - three - four" - -TestMain.cpp:: -PASSED: - CHECK( Text( testString, TextAttributes().setWidth( 7 ) ).toString() == "one two\nthree\nfour" ) -with expansion: - "one two - three - four" - == - "one two - three - four" - -------------------------------------------------------------------------------- -Long strings can be wrapped - With newlines - Wrapped twice -------------------------------------------------------------------------------- -TestMain.cpp: -............................................................................... - -TestMain.cpp:: -PASSED: - CHECK( Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one\ntwo\nthree\nfour" ) -with expansion: - "one - two - three - four" - == - "one - two - three - four" - -------------------------------------------------------------------------------- -Long strings can be wrapped - With wrap-before/ after characters - No wrapping -------------------------------------------------------------------------------- -TestMain.cpp: -............................................................................... - -TestMain.cpp:: -PASSED: - CHECK( Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString ) -with expansion: - "one,two(three) " - == - "one,two(three) " - -TestMain.cpp:: -PASSED: - CHECK( Text( testString, TextAttributes().setWidth( 24 ) ).toString() == testString ) -with expansion: - "one,two(three) " - == - "one,two(three) " - -------------------------------------------------------------------------------- -Long strings can be wrapped - With wrap-before/ after characters - Wrap before -------------------------------------------------------------------------------- -TestMain.cpp: -............................................................................... - -TestMain.cpp:: -PASSED: - CHECK( Text( testString, TextAttributes().setWidth( 11 ) ).toString() == "one,two\n(three)\n" ) -with expansion: - "one,two - (three) - " - == - "one,two - (three) - " - -------------------------------------------------------------------------------- -Long strings can be wrapped - With wrap-before/ after characters - Wrap after -------------------------------------------------------------------------------- -TestMain.cpp: -............................................................................... - -TestMain.cpp:: -PASSED: - CHECK( Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one,\ntwo\n(thre-\ne)\n" ) -with expansion: - "one, - two - (thre- - e) - " - == - "one, - two - (thre- - e) - " - -TestMain.cpp:: -PASSED: - CHECK( Text( testString, TextAttributes().setWidth( 5 ) ).toString() == "one,\ntwo\n(thr-\nee)\n" ) -with expansion: - "one, - two - (thr- - ee) - " - == - "one, - two - (thr- - ee) - " - -TestMain.cpp:: -PASSED: - CHECK( Text( testString, TextAttributes().setWidth( 4 ) ).toString() == "one,\ntwo\n(th-\nree)\n" ) -with expansion: - "one, - two - (th- - ree) - " - == - "one, - two - (th- - ree) - " - ------------------------------------------------------------------------------- ManuallyRegistered ------------------------------------------------------------------------------- @@ -5320,8 +4782,6 @@ PASSED: with expansion: "hot potato" == "hot potato" -hello -hello ------------------------------------------------------------------------------- Tabs and newlines show in output ------------------------------------------------------------------------------- @@ -5425,28 +4885,6 @@ PASSED: with expansion: 3221225472 (0x) == 3221225472 -------------------------------------------------------------------------------- -Text can be formatted using the Text class -------------------------------------------------------------------------------- -TestMain.cpp: -............................................................................... - -TestMain.cpp:: -PASSED: - CHECK( Text( "hi there" ).toString() == "hi there" ) -with expansion: - "hi there" == "hi there" - -TestMain.cpp:: -PASSED: - CHECK( Text( "hi there", narrow ).toString() == "hi\nthere" ) -with expansion: - "hi - there" - == - "hi - there" - ------------------------------------------------------------------------------- The NO_FAIL macro reports a failure but does not fail the test ------------------------------------------------------------------------------- @@ -7407,7 +6845,7 @@ TestMain.cpp: TestMain.cpp:: PASSED: - CHECK( replaceInPlace( letters, "b", "z" ) ) + CHECK( Catch::replaceInPlace( letters, "b", "z" ) ) with expansion: true @@ -7426,7 +6864,7 @@ TestMain.cpp: TestMain.cpp:: PASSED: - CHECK( replaceInPlace( letters, "c", "z" ) ) + CHECK( Catch::replaceInPlace( letters, "c", "z" ) ) with expansion: true @@ -7445,7 +6883,7 @@ TestMain.cpp: TestMain.cpp:: PASSED: - CHECK( replaceInPlace( letters, "a", "z" ) ) + CHECK( Catch::replaceInPlace( letters, "a", "z" ) ) with expansion: true @@ -7464,7 +6902,7 @@ TestMain.cpp: TestMain.cpp:: PASSED: - CHECK( replaceInPlace( letters, "g", "z" ) ) + CHECK( Catch::replaceInPlace( letters, "g", "z" ) ) with expansion: true @@ -7483,7 +6921,7 @@ TestMain.cpp: TestMain.cpp:: PASSED: - CHECK( replaceInPlace( letters, letters, "replaced" ) ) + CHECK( Catch::replaceInPlace( letters, letters, "replaced" ) ) with expansion: true @@ -7502,7 +6940,7 @@ TestMain.cpp: TestMain.cpp:: PASSED: - CHECK_FALSE( replaceInPlace( letters, "x", "z" ) ) + CHECK_FALSE( Catch::replaceInPlace( letters, "x", "z" ) ) with expansion: !false @@ -7521,7 +6959,7 @@ TestMain.cpp: TestMain.cpp:: PASSED: - CHECK( replaceInPlace( s, "'", "|'" ) ) + CHECK( Catch::replaceInPlace( s, "'", "|'" ) ) with expansion: true @@ -8152,6 +7590,6 @@ MiscTests.cpp:: PASSED: =============================================================================== -test cases: 185 | 133 passed | 48 failed | 4 failed as expected -assertions: 940 | 821 passed | 98 failed | 21 failed as expected +test cases: 182 | 130 passed | 48 failed | 4 failed as expected +assertions: 898 | 779 passed | 98 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index b567d061..58807c18 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -1,6 +1,6 @@ - + @@ -295,20 +295,6 @@ ConditionTests.cpp: - - - - - - - - - - - - - - @@ -533,12 +519,6 @@ MatchersTests.cpp: - - -hello -hello - - .global" name="Tag alias can be registered against tag patterns/Tag aliases must be of the form [@name]" time="{duration}"/> - @@ -810,8 +789,6 @@ EnumToString.cpp: A string sent directly to stdout Message from section one Message from section two -hello -hello A string sent directly to stderr diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index 22c8a4ca..e70ad12e 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -2089,599 +2089,6 @@ - -
-
- - - Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString - - - "one two three four" -== -"one two three four" - - - - - Text( testString, TextAttributes().setWidth( 18 ) ).toString() == testString - - - "one two three four" -== -"one two three four" - - - -
- -
-
-
- - - Text( testString, TextAttributes().setWidth( 17 ) ).toString() == "one two three\nfour" - - - "one two three -four" -== -"one two three -four" - - - - - Text( testString, TextAttributes().setWidth( 16 ) ).toString() == "one two three\nfour" - - - "one two three -four" -== -"one two three -four" - - - - - Text( testString, TextAttributes().setWidth( 14 ) ).toString() == "one two three\nfour" - - - "one two three -four" -== -"one two three -four" - - - - - Text( testString, TextAttributes().setWidth( 13 ) ).toString() == "one two three\nfour" - - - "one two three -four" -== -"one two three -four" - - - - - Text( testString, TextAttributes().setWidth( 12 ) ).toString() == "one two\nthree four" - - - "one two -three four" -== -"one two -three four" - - - -
- -
-
-
- - - Text( testString, TextAttributes().setWidth( 9 ) ).toString() == "one two\nthree\nfour" - - - "one two -three -four" -== -"one two -three -four" - - - - - Text( testString, TextAttributes().setWidth( 8 ) ).toString() == "one two\nthree\nfour" - - - "one two -three -four" -== -"one two -three -four" - - - - - Text( testString, TextAttributes().setWidth( 7 ) ).toString() == "one two\nthree\nfour" - - - "one two -three -four" -== -"one two -three -four" - - - -
- -
-
-
- - - Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one\ntwo\nthree\nfour" - - - "one -two -three -four" -== -"one -two -three -four" - - - - - Text( testString, TextAttributes().setWidth( 5 ) ).toString() == "one\ntwo\nthree\nfour" - - - "one -two -three -four" -== -"one -two -three -four" - - - -
- -
-
-
- - - Text( "abcdef", TextAttributes().setWidth( 4 ) ).toString() == "abc-\ndef" - - - "abc- -def" -== -"abc- -def" - - - - - Text( "abcdefg", TextAttributes().setWidth( 4 ) ).toString() == "abc-\ndefg" - - - "abc- -defg" -== -"abc- -defg" - - - - - Text( "abcdefgh", TextAttributes().setWidth( 4 ) ).toString() == "abc-\ndef-\ngh" - - - "abc- -def- -gh" -== -"abc- -def- -gh" - - - - - Text( testString, TextAttributes().setWidth( 4 ) ).toString() == "one\ntwo\nthr-\nee\nfour" - - - "one -two -thr- -ee -four" -== -"one -two -thr- -ee -four" - - - - - Text( testString, TextAttributes().setWidth( 3 ) ).toString() == "one\ntwo\nth-\nree\nfo-\nur" - - - "one -two -th- -ree -fo- -ur" -== -"one -two -th- -ree -fo- -ur" - - - -
- -
-
-
- - - text.size() == 4 - - - 4 == 4 - - - - - text[0] == "one" - - - "one" == "one" - - - - - text[1] == "two" - - - "two" == "two" - - - - - text[2] == "three" - - - "three" == "three" - - - - - text[3] == "four" - - - "four" == "four" - - - -
- -
-
-
- - - text.toString() == " one two\n three\n four" - - - " one two - three - four" -== -" one two - three - four" - - - -
- -
-
-
- - - Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString - - - "one two -three four" -== -"one two -three four" - - - - - Text( testString, TextAttributes().setWidth( 18 ) ).toString() == testString - - - "one two -three four" -== -"one two -three four" - - - - - Text( testString, TextAttributes().setWidth( 10 ) ).toString() == testString - - - "one two -three four" -== -"one two -three four" - - - -
- -
-
-
- - - Text( "abcdef\n", TextAttributes().setWidth( 10 ) ).toString() == "abcdef" - - - "abcdef" == "abcdef" - - - - - Text( "abcdef", TextAttributes().setWidth( 6 ) ).toString() == "abcdef" - - - "abcdef" == "abcdef" - - - - - Text( "abcdef\n", TextAttributes().setWidth( 6 ) ).toString() == "abcdef" - - - "abcdef" == "abcdef" - - - - - Text( "abcdef\n", TextAttributes().setWidth( 5 ) ).toString() == "abcd-\nef" - - - "abcd- -ef" -== -"abcd- -ef" - - - -
- -
-
-
- - - Text( testString, TextAttributes().setWidth( 9 ) ).toString() == "one two\nthree\nfour" - - - "one two -three -four" -== -"one two -three -four" - - - - - Text( testString, TextAttributes().setWidth( 8 ) ).toString() == "one two\nthree\nfour" - - - "one two -three -four" -== -"one two -three -four" - - - - - Text( testString, TextAttributes().setWidth( 7 ) ).toString() == "one two\nthree\nfour" - - - "one two -three -four" -== -"one two -three -four" - - - -
- -
-
-
- - - Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one\ntwo\nthree\nfour" - - - "one -two -three -four" -== -"one -two -three -four" - - - -
- -
-
-
- - - Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString - - - "one,two(three) <here>" -== -"one,two(three) <here>" - - - - - Text( testString, TextAttributes().setWidth( 24 ) ).toString() == testString - - - "one,two(three) <here>" -== -"one,two(three) <here>" - - - -
- -
-
-
- - - Text( testString, TextAttributes().setWidth( 11 ) ).toString() == "one,two\n(three)\n<here>" - - - "one,two -(three) -<here>" -== -"one,two -(three) -<here>" - - - -
- -
-
-
- - - Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one,\ntwo\n(thre-\ne)\n<here>" - - - "one, -two -(thre- -e) -<here>" -== -"one, -two -(thre- -e) -<here>" - - - - - Text( testString, TextAttributes().setWidth( 5 ) ).toString() == "one,\ntwo\n(thr-\nee)\n<her-\ne>" - - - "one, -two -(thr- -ee) -<her- -e>" -== -"one, -two -(thr- -ee) -<her- -e>" - - - - - Text( testString, TextAttributes().setWidth( 4 ) ).toString() == "one,\ntwo\n(th-\nree)\n<he-\nre>" - - - "one, -two -(th- -ree) -<he- -re>" -== -"one, -two -(th- -ree) -<he- -re>" - - - -
- -
- -
@@ -6084,14 +5491,6 @@ Message from section two
- - - -hello -hello - - - @@ -6205,29 +5604,6 @@ hello - - - - Text( "hi there" ).toString() == "hi there" - - - "hi there" == "hi there" - - - - - Text( "hi there", narrow ).toString() == "hi\nthere" - - - "hi -there" -== -"hi -there" - - - - @@ -8316,7 +7692,7 @@ spanner
- replaceInPlace( letters, "b", "z" ) + Catch::replaceInPlace( letters, "b", "z" ) true @@ -8335,7 +7711,7 @@ spanner
- replaceInPlace( letters, "c", "z" ) + Catch::replaceInPlace( letters, "c", "z" ) true @@ -8354,7 +7730,7 @@ spanner
- replaceInPlace( letters, "a", "z" ) + Catch::replaceInPlace( letters, "a", "z" ) true @@ -8373,7 +7749,7 @@ spanner
- replaceInPlace( letters, "g", "z" ) + Catch::replaceInPlace( letters, "g", "z" ) true @@ -8392,7 +7768,7 @@ spanner
- replaceInPlace( letters, letters, "replaced" ) + Catch::replaceInPlace( letters, letters, "replaced" ) true @@ -8411,7 +7787,7 @@ spanner
- !replaceInPlace( letters, "x", "z" ) + !Catch::replaceInPlace( letters, "x", "z" ) !false @@ -8430,7 +7806,7 @@ spanner
- replaceInPlace( s, "'", "|'" ) + Catch::replaceInPlace( s, "'", "|'" ) true @@ -9065,7 +8441,7 @@ spanner
- + - + diff --git a/projects/SelfTest/TestMain.cpp b/projects/SelfTest/TestMain.cpp index 59fe2db5..84cf35ed 100644 --- a/projects/SelfTest/TestMain.cpp +++ b/projects/SelfTest/TestMain.cpp @@ -232,239 +232,39 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]" } -TEST_CASE( "Long strings can be wrapped", "[wrap]" ) { - - using namespace Catch; - SECTION( "plain string" ) { - // guide: 123456789012345678 - std::string testString = "one two three four"; - - SECTION( "No wrapping" ) { - CHECK( Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString ); - CHECK( Text( testString, TextAttributes().setWidth( 18 ) ).toString() == testString ); - } - SECTION( "Wrapped once" ) { - CHECK( Text( testString, TextAttributes().setWidth( 17 ) ).toString() == "one two three\nfour" ); - CHECK( Text( testString, TextAttributes().setWidth( 16 ) ).toString() == "one two three\nfour" ); - CHECK( Text( testString, TextAttributes().setWidth( 14 ) ).toString() == "one two three\nfour" ); - CHECK( Text( testString, TextAttributes().setWidth( 13 ) ).toString() == "one two three\nfour" ); - CHECK( Text( testString, TextAttributes().setWidth( 12 ) ).toString() == "one two\nthree four" ); - } - SECTION( "Wrapped twice" ) { - CHECK( Text( testString, TextAttributes().setWidth( 9 ) ).toString() == "one two\nthree\nfour" ); - CHECK( Text( testString, TextAttributes().setWidth( 8 ) ).toString() == "one two\nthree\nfour" ); - CHECK( Text( testString, TextAttributes().setWidth( 7 ) ).toString() == "one two\nthree\nfour" ); - } - SECTION( "Wrapped three times" ) { - CHECK( Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one\ntwo\nthree\nfour" ); - CHECK( Text( testString, TextAttributes().setWidth( 5 ) ).toString() == "one\ntwo\nthree\nfour" ); - } - SECTION( "Short wrap" ) { - CHECK( Text( "abcdef", TextAttributes().setWidth( 4 ) ).toString() == "abc-\ndef" ); - CHECK( Text( "abcdefg", TextAttributes().setWidth( 4 ) ).toString() == "abc-\ndefg" ); - CHECK( Text( "abcdefgh", TextAttributes().setWidth( 4 ) ).toString() == "abc-\ndef-\ngh" ); - - CHECK( Text( testString, TextAttributes().setWidth( 4 ) ).toString() == "one\ntwo\nthr-\nee\nfour" ); - CHECK( Text( testString, TextAttributes().setWidth( 3 ) ).toString() == "one\ntwo\nth-\nree\nfo-\nur" ); - } - SECTION( "As container" ) { - Text text( testString, TextAttributes().setWidth( 6 ) ); - REQUIRE( text.size() == 4 ); - CHECK( text[0] == "one" ); - CHECK( text[1] == "two" ); - CHECK( text[2] == "three" ); - CHECK( text[3] == "four" ); - } - SECTION( "Indent first line differently" ) { - Text text( testString, TextAttributes() - .setWidth( 10 ) - .setIndent( 4 ) - .setInitialIndent( 1 ) ); - CHECK( text.toString() == " one two\n three\n four" ); - } - - } - - SECTION( "With newlines" ) { - - // guide: 1234567890123456789 - std::string testString = "one two\nthree four"; - - SECTION( "No wrapping" ) { - CHECK( Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString ); - CHECK( Text( testString, TextAttributes().setWidth( 18 ) ).toString() == testString ); - CHECK( Text( testString, TextAttributes().setWidth( 10 ) ).toString() == testString ); - } - SECTION( "Trailing newline" ) { - CHECK( Text( "abcdef\n", TextAttributes().setWidth( 10 ) ).toString() == "abcdef" ); - CHECK( Text( "abcdef", TextAttributes().setWidth( 6 ) ).toString() == "abcdef" ); - CHECK( Text( "abcdef\n", TextAttributes().setWidth( 6 ) ).toString() == "abcdef" ); - CHECK( Text( "abcdef\n", TextAttributes().setWidth( 5 ) ).toString() == "abcd-\nef" ); - } - SECTION( "Wrapped once" ) { - CHECK( Text( testString, TextAttributes().setWidth( 9 ) ).toString() == "one two\nthree\nfour" ); - CHECK( Text( testString, TextAttributes().setWidth( 8 ) ).toString() == "one two\nthree\nfour" ); - CHECK( Text( testString, TextAttributes().setWidth( 7 ) ).toString() == "one two\nthree\nfour" ); - } - SECTION( "Wrapped twice" ) { - CHECK( Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one\ntwo\nthree\nfour" ); - } - } - - SECTION( "With wrap-before/ after characters" ) { - std::string testString = "one,two(three) "; - - SECTION( "No wrapping" ) { - CHECK( Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString ); - CHECK( Text( testString, TextAttributes().setWidth( 24 ) ).toString() == testString ); - } - SECTION( "Wrap before" ) { - CHECK( Text( testString, TextAttributes().setWidth( 11 ) ).toString() == "one,two\n(three)\n" ); - } - SECTION( "Wrap after" ) { - CHECK( Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one,\ntwo\n(thre-\ne)\n" ); - CHECK( Text( testString, TextAttributes().setWidth( 5 ) ).toString() == "one,\ntwo\n(thr-\nee)\n" ); - CHECK( Text( testString, TextAttributes().setWidth( 4 ) ).toString() == "one,\ntwo\n(th-\nree)\n" ); - } - } - -} - -using namespace Catch; - -class ColourString { -public: - - struct ColourIndex { - ColourIndex( Colour::Code _colour, std::size_t _fromIndex, std::size_t _toIndex ) - : colour( _colour ), - fromIndex( _fromIndex ), - toIndex( _toIndex ) - {} - - Colour::Code colour; - std::size_t fromIndex; - std::size_t toIndex; - }; - - ColourString( std::string const& _string ) - : string( _string ) - {} - ColourString( std::string const& _string, std::vector const& _colours ) - : string( _string ), colours( _colours ) - {} - - ColourString& addColour( Colour::Code colour, int _index ) { - colours.push_back( ColourIndex( colour, - resolveRelativeIndex( _index ), - resolveRelativeIndex( _index )+1 ) ); - return *this; - } - ColourString& addColour( Colour::Code colour, int _fromIndex, int _toIndex ) { - colours.push_back( ColourIndex( colour, - resolveRelativeIndex(_fromIndex), - resolveLastRelativeIndex( _toIndex ) ) ); - return *this; - } - - void writeToStream( std::ostream& _stream ) const { - std::size_t last = 0; - for( std::size_t i = 0; i < colours.size(); ++i ) { - ColourIndex const& index = colours[i]; - if( index.fromIndex > last ) - _stream << string.substr( last, index.fromIndex-last ); - { - Colour colourGuard( index.colour ); - _stream << string.substr( index.fromIndex, index.toIndex-index.fromIndex ); - } - last = index.toIndex; - } - if( last < string.size() ) - _stream << string.substr( last ); - } - friend std::ostream& operator << ( std::ostream& _stream, ColourString const& _colourString ) { - _colourString.writeToStream( _stream ); - return _stream; - } - -private: - - std::size_t resolveLastRelativeIndex( int _index ) { - std::size_t index = resolveRelativeIndex( _index ); - return index == 0 ? string.size() : index; - } - std::size_t resolveRelativeIndex( int _index ) { - return static_cast( _index >= 0 - ? _index - : static_cast( string.size() )+_index ); - } - std::string string; - std::vector colours; -}; - TEST_CASE( "replaceInPlace" ) { std::string letters = "abcdefcg"; SECTION( "replace single char" ) { - CHECK( replaceInPlace( letters, "b", "z" ) ); + CHECK( Catch::replaceInPlace( letters, "b", "z" ) ); CHECK( letters == "azcdefcg" ); } SECTION( "replace two chars" ) { - CHECK( replaceInPlace( letters, "c", "z" ) ); + CHECK( Catch::replaceInPlace( letters, "c", "z" ) ); CHECK( letters == "abzdefzg" ); } SECTION( "replace first char" ) { - CHECK( replaceInPlace( letters, "a", "z" ) ); + CHECK( Catch::replaceInPlace( letters, "a", "z" ) ); CHECK( letters == "zbcdefcg" ); } SECTION( "replace last char" ) { - CHECK( replaceInPlace( letters, "g", "z" ) ); + CHECK( Catch::replaceInPlace( letters, "g", "z" ) ); CHECK( letters == "abcdefcz" ); } SECTION( "replace all chars" ) { - CHECK( replaceInPlace( letters, letters, "replaced" ) ); + CHECK( Catch::replaceInPlace( letters, letters, "replaced" ) ); CHECK( letters == "replaced" ); } SECTION( "replace no chars" ) { - CHECK_FALSE( replaceInPlace( letters, "x", "z" ) ); + CHECK_FALSE( Catch::replaceInPlace( letters, "x", "z" ) ); CHECK( letters == letters ); } SECTION( "escape '" ) { std::string s = "didn't"; - CHECK( replaceInPlace( s, "'", "|'" ) ); + CHECK( Catch::replaceInPlace( s, "'", "|'" ) ); CHECK( s == "didn|'t" ); } } -// !TBD: This will be folded into Text class -TEST_CASE( "Strings can be rendered with colour", "[.colour]" ) { - - { - ColourString cs( "hello" ); - cs .addColour( Colour::Red, 0 ) - .addColour( Colour::Green, -1 ); - - Catch::cout() << cs << std::endl; - } - - { - ColourString cs( "hello" ); - cs .addColour( Colour::Blue, 1, -2 ); - - Catch::cout() << cs << std::endl; - } - -} - -TEST_CASE( "Text can be formatted using the Text class" ) { - - CHECK( Text( "hi there" ).toString() == "hi there" ); - - TextAttributes narrow; - narrow.setWidth( 6 ); - - CHECK( Text( "hi there", narrow ).toString() == "hi\nthere" ); -} - inline void manuallyRegisteredTestFunction() { SUCCEED( "was called" );