Removed Text tests (TextFlow has it's own test suite)

This commit is contained in:
Phil Nash 2017-07-20 23:09:50 +01:00
parent 93556a1fb3
commit 58d8bc6985
5 changed files with 28 additions and 1439 deletions

View File

@ -684,8 +684,6 @@ MatchersTests.cpp:<line number>: FAILED:
with expansion: with expansion:
"this string contains 'abc' as a substring" starts with: "string" "this string contains 'abc' as a substring" starts with: "string"
hello
hello
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Tabs and newlines show in output Tabs and newlines show in output
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@ -1018,6 +1016,6 @@ with expansion:
"{?}" == "1" "{?}" == "1"
=============================================================================== ===============================================================================
test cases: 185 | 134 passed | 47 failed | 4 failed as expected test cases: 182 | 131 passed | 47 failed | 4 failed as expected
assertions: 938 | 821 passed | 96 failed | 21 failed as expected assertions: 896 | 779 passed | 96 failed | 21 failed as expected

View File

@ -1781,544 +1781,6 @@ PASSED:
with expansion: with expansion:
1.23 <= Approx( 1.22 ) 1.23 <= Approx( 1.22 )
-------------------------------------------------------------------------------
Long strings can be wrapped
plain string
No wrapping
-------------------------------------------------------------------------------
TestMain.cpp:<line number>
...............................................................................
TestMain.cpp:<line number>:
PASSED:
CHECK( Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString )
with expansion:
"one two three four"
==
"one two three four"
TestMain.cpp:<line number>:
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:<line number>
...............................................................................
TestMain.cpp:<line number>:
PASSED:
CHECK( Text( testString, TextAttributes().setWidth( 17 ) ).toString() == "one two three\nfour" )
with expansion:
"one two three
four"
==
"one two three
four"
TestMain.cpp:<line number>:
PASSED:
CHECK( Text( testString, TextAttributes().setWidth( 16 ) ).toString() == "one two three\nfour" )
with expansion:
"one two three
four"
==
"one two three
four"
TestMain.cpp:<line number>:
PASSED:
CHECK( Text( testString, TextAttributes().setWidth( 14 ) ).toString() == "one two three\nfour" )
with expansion:
"one two three
four"
==
"one two three
four"
TestMain.cpp:<line number>:
PASSED:
CHECK( Text( testString, TextAttributes().setWidth( 13 ) ).toString() == "one two three\nfour" )
with expansion:
"one two three
four"
==
"one two three
four"
TestMain.cpp:<line number>:
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:<line number>
...............................................................................
TestMain.cpp:<line number>:
PASSED:
CHECK( Text( testString, TextAttributes().setWidth( 9 ) ).toString() == "one two\nthree\nfour" )
with expansion:
"one two
three
four"
==
"one two
three
four"
TestMain.cpp:<line number>:
PASSED:
CHECK( Text( testString, TextAttributes().setWidth( 8 ) ).toString() == "one two\nthree\nfour" )
with expansion:
"one two
three
four"
==
"one two
three
four"
TestMain.cpp:<line number>:
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:<line number>
...............................................................................
TestMain.cpp:<line number>:
PASSED:
CHECK( Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one\ntwo\nthree\nfour" )
with expansion:
"one
two
three
four"
==
"one
two
three
four"
TestMain.cpp:<line number>:
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:<line number>
...............................................................................
TestMain.cpp:<line number>:
PASSED:
CHECK( Text( "abcdef", TextAttributes().setWidth( 4 ) ).toString() == "abc-\ndef" )
with expansion:
"abc-
def"
==
"abc-
def"
TestMain.cpp:<line number>:
PASSED:
CHECK( Text( "abcdefg", TextAttributes().setWidth( 4 ) ).toString() == "abc-\ndefg" )
with expansion:
"abc-
defg"
==
"abc-
defg"
TestMain.cpp:<line number>:
PASSED:
CHECK( Text( "abcdefgh", TextAttributes().setWidth( 4 ) ).toString() == "abc-\ndef-\ngh" )
with expansion:
"abc-
def-
gh"
==
"abc-
def-
gh"
TestMain.cpp:<line number>:
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:<line number>:
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:<line number>
...............................................................................
TestMain.cpp:<line number>:
PASSED:
REQUIRE( text.size() == 4 )
with expansion:
4 == 4
TestMain.cpp:<line number>:
PASSED:
CHECK( text[0] == "one" )
with expansion:
"one" == "one"
TestMain.cpp:<line number>:
PASSED:
CHECK( text[1] == "two" )
with expansion:
"two" == "two"
TestMain.cpp:<line number>:
PASSED:
CHECK( text[2] == "three" )
with expansion:
"three" == "three"
TestMain.cpp:<line number>:
PASSED:
CHECK( text[3] == "four" )
with expansion:
"four" == "four"
-------------------------------------------------------------------------------
Long strings can be wrapped
plain string
Indent first line differently
-------------------------------------------------------------------------------
TestMain.cpp:<line number>
...............................................................................
TestMain.cpp:<line number>:
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:<line number>
...............................................................................
TestMain.cpp:<line number>:
PASSED:
CHECK( Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString )
with expansion:
"one two
three four"
==
"one two
three four"
TestMain.cpp:<line number>:
PASSED:
CHECK( Text( testString, TextAttributes().setWidth( 18 ) ).toString() == testString )
with expansion:
"one two
three four"
==
"one two
three four"
TestMain.cpp:<line number>:
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:<line number>
...............................................................................
TestMain.cpp:<line number>:
PASSED:
CHECK( Text( "abcdef\n", TextAttributes().setWidth( 10 ) ).toString() == "abcdef" )
with expansion:
"abcdef" == "abcdef"
TestMain.cpp:<line number>:
PASSED:
CHECK( Text( "abcdef", TextAttributes().setWidth( 6 ) ).toString() == "abcdef" )
with expansion:
"abcdef" == "abcdef"
TestMain.cpp:<line number>:
PASSED:
CHECK( Text( "abcdef\n", TextAttributes().setWidth( 6 ) ).toString() == "abcdef" )
with expansion:
"abcdef" == "abcdef"
TestMain.cpp:<line number>:
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:<line number>
...............................................................................
TestMain.cpp:<line number>:
PASSED:
CHECK( Text( testString, TextAttributes().setWidth( 9 ) ).toString() == "one two\nthree\nfour" )
with expansion:
"one two
three
four"
==
"one two
three
four"
TestMain.cpp:<line number>:
PASSED:
CHECK( Text( testString, TextAttributes().setWidth( 8 ) ).toString() == "one two\nthree\nfour" )
with expansion:
"one two
three
four"
==
"one two
three
four"
TestMain.cpp:<line number>:
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:<line number>
...............................................................................
TestMain.cpp:<line number>:
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:<line number>
...............................................................................
TestMain.cpp:<line number>:
PASSED:
CHECK( Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString )
with expansion:
"one,two(three) <here>"
==
"one,two(three) <here>"
TestMain.cpp:<line number>:
PASSED:
CHECK( Text( testString, TextAttributes().setWidth( 24 ) ).toString() == testString )
with expansion:
"one,two(three) <here>"
==
"one,two(three) <here>"
-------------------------------------------------------------------------------
Long strings can be wrapped
With wrap-before/ after characters
Wrap before
-------------------------------------------------------------------------------
TestMain.cpp:<line number>
...............................................................................
TestMain.cpp:<line number>:
PASSED:
CHECK( Text( testString, TextAttributes().setWidth( 11 ) ).toString() == "one,two\n(three)\n<here>" )
with expansion:
"one,two
(three)
<here>"
==
"one,two
(three)
<here>"
-------------------------------------------------------------------------------
Long strings can be wrapped
With wrap-before/ after characters
Wrap after
-------------------------------------------------------------------------------
TestMain.cpp:<line number>
...............................................................................
TestMain.cpp:<line number>:
PASSED:
CHECK( Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one,\ntwo\n(thre-\ne)\n<here>" )
with expansion:
"one,
two
(thre-
e)
<here>"
==
"one,
two
(thre-
e)
<here>"
TestMain.cpp:<line number>:
PASSED:
CHECK( Text( testString, TextAttributes().setWidth( 5 ) ).toString() == "one,\ntwo\n(thr-\nee)\n<her-\ne>" )
with expansion:
"one,
two
(thr-
ee)
<her-
e>"
==
"one,
two
(thr-
ee)
<her-
e>"
TestMain.cpp:<line number>:
PASSED:
CHECK( Text( testString, TextAttributes().setWidth( 4 ) ).toString() == "one,\ntwo\n(th-\nree)\n<he-\nre>" )
with expansion:
"one,
two
(th-
ree)
<he-
re>"
==
"one,
two
(th-
ree)
<he-
re>"
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
ManuallyRegistered ManuallyRegistered
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@ -5320,8 +4782,6 @@ PASSED:
with expansion: with expansion:
"hot potato" == "hot potato" "hot potato" == "hot potato"
hello
hello
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Tabs and newlines show in output Tabs and newlines show in output
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@ -5425,28 +4885,6 @@ PASSED:
with expansion: with expansion:
3221225472 (0x<hex digits>) == 3221225472 3221225472 (0x<hex digits>) == 3221225472
-------------------------------------------------------------------------------
Text can be formatted using the Text class
-------------------------------------------------------------------------------
TestMain.cpp:<line number>
...............................................................................
TestMain.cpp:<line number>:
PASSED:
CHECK( Text( "hi there" ).toString() == "hi there" )
with expansion:
"hi there" == "hi there"
TestMain.cpp:<line number>:
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 The NO_FAIL macro reports a failure but does not fail the test
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@ -7407,7 +6845,7 @@ TestMain.cpp:<line number>
TestMain.cpp:<line number>: TestMain.cpp:<line number>:
PASSED: PASSED:
CHECK( replaceInPlace( letters, "b", "z" ) ) CHECK( Catch::replaceInPlace( letters, "b", "z" ) )
with expansion: with expansion:
true true
@ -7426,7 +6864,7 @@ TestMain.cpp:<line number>
TestMain.cpp:<line number>: TestMain.cpp:<line number>:
PASSED: PASSED:
CHECK( replaceInPlace( letters, "c", "z" ) ) CHECK( Catch::replaceInPlace( letters, "c", "z" ) )
with expansion: with expansion:
true true
@ -7445,7 +6883,7 @@ TestMain.cpp:<line number>
TestMain.cpp:<line number>: TestMain.cpp:<line number>:
PASSED: PASSED:
CHECK( replaceInPlace( letters, "a", "z" ) ) CHECK( Catch::replaceInPlace( letters, "a", "z" ) )
with expansion: with expansion:
true true
@ -7464,7 +6902,7 @@ TestMain.cpp:<line number>
TestMain.cpp:<line number>: TestMain.cpp:<line number>:
PASSED: PASSED:
CHECK( replaceInPlace( letters, "g", "z" ) ) CHECK( Catch::replaceInPlace( letters, "g", "z" ) )
with expansion: with expansion:
true true
@ -7483,7 +6921,7 @@ TestMain.cpp:<line number>
TestMain.cpp:<line number>: TestMain.cpp:<line number>:
PASSED: PASSED:
CHECK( replaceInPlace( letters, letters, "replaced" ) ) CHECK( Catch::replaceInPlace( letters, letters, "replaced" ) )
with expansion: with expansion:
true true
@ -7502,7 +6940,7 @@ TestMain.cpp:<line number>
TestMain.cpp:<line number>: TestMain.cpp:<line number>:
PASSED: PASSED:
CHECK_FALSE( replaceInPlace( letters, "x", "z" ) ) CHECK_FALSE( Catch::replaceInPlace( letters, "x", "z" ) )
with expansion: with expansion:
!false !false
@ -7521,7 +6959,7 @@ TestMain.cpp:<line number>
TestMain.cpp:<line number>: TestMain.cpp:<line number>:
PASSED: PASSED:
CHECK( replaceInPlace( s, "'", "|'" ) ) CHECK( Catch::replaceInPlace( s, "'", "|'" ) )
with expansion: with expansion:
true true
@ -8152,6 +7590,6 @@ MiscTests.cpp:<line number>:
PASSED: PASSED:
=============================================================================== ===============================================================================
test cases: 185 | 133 passed | 48 failed | 4 failed as expected test cases: 182 | 130 passed | 48 failed | 4 failed as expected
assertions: 940 | 821 passed | 98 failed | 21 failed as expected assertions: 898 | 779 passed | 98 failed | 21 failed as expected

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<testsuitesspanner> <testsuitesspanner>
<testsuite name="<exe-name>" errors="15" failures="84" tests="941" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> <testsuite name="<exe-name>" errors="15" failures="84" tests="899" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<testcase classname="<exe-name>.global" name="# A test name that starts with a #" time="{duration}"/> <testcase classname="<exe-name>.global" name="# A test name that starts with a #" time="{duration}"/>
<testcase classname="<exe-name>.global" name="#748 - captures with unexpected exceptions/outside assertions" time="{duration}"> <testcase classname="<exe-name>.global" name="#748 - captures with unexpected exceptions/outside assertions" time="{duration}">
<error type="TEST_CASE"> <error type="TEST_CASE">
@ -295,20 +295,6 @@ ConditionTests.cpp:<line number>
</testcase> </testcase>
<testcase classname="<exe-name>.global" name="Inequality checks that should succeed" time="{duration}"/> <testcase classname="<exe-name>.global" name="Inequality checks that should succeed" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Less-than inequalities with different epsilons" time="{duration}"/> <testcase classname="<exe-name>.global" name="Less-than inequalities with different epsilons" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Long strings can be wrapped/plain string/No wrapping" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Long strings can be wrapped/plain string/Wrapped once" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Long strings can be wrapped/plain string/Wrapped twice" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Long strings can be wrapped/plain string/Wrapped three times" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Long strings can be wrapped/plain string/Short wrap" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Long strings can be wrapped/plain string/As container" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Long strings can be wrapped/plain string/Indent first line differently" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Long strings can be wrapped/With newlines/No wrapping" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Long strings can be wrapped/With newlines/Trailing newline" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Long strings can be wrapped/With newlines/Wrapped once" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Long strings can be wrapped/With newlines/Wrapped twice" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Long strings can be wrapped/With wrap-before/ after characters/No wrapping" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Long strings can be wrapped/With wrap-before/ after characters/Wrap before" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Long strings can be wrapped/With wrap-before/ after characters/Wrap after" time="{duration}"/>
<testcase classname="<exe-name>.global" name="ManuallyRegistered" time="{duration}"/> <testcase classname="<exe-name>.global" name="ManuallyRegistered" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Matchers can be (AllOf) composed with the &amp;&amp; operator" time="{duration}"/> <testcase classname="<exe-name>.global" name="Matchers can be (AllOf) composed with the &amp;&amp; operator" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Matchers can be (AnyOf) composed with the || operator" time="{duration}"/> <testcase classname="<exe-name>.global" name="Matchers can be (AnyOf) composed with the || operator" time="{duration}"/>
@ -533,12 +519,6 @@ MatchersTests.cpp:<line number>
<testcase classname="<exe-name>.global" name="StringRef/Comparisons" time="{duration}"/> <testcase classname="<exe-name>.global" name="StringRef/Comparisons" time="{duration}"/>
<testcase classname="<exe-name>.global" name="StringRef/From string/Copied" time="{duration}"/> <testcase classname="<exe-name>.global" name="StringRef/From string/Copied" time="{duration}"/>
<testcase classname="<exe-name>.global" name="StringRef/From string/Moved" time="{duration}"/> <testcase classname="<exe-name>.global" name="StringRef/From string/Moved" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Strings can be rendered with colour" time="{duration}">
<system-out>
hello
hello
</system-out>
</testcase>
<testcase classname="<exe-name>.global" name="Tabs and newlines show in output" time="{duration}"> <testcase classname="<exe-name>.global" name="Tabs and newlines show in output" time="{duration}">
<failure message="&quot;if ($b == 10) { <failure message="&quot;if ($b == 10) {
$a = 20; $a = 20;
@ -555,7 +535,6 @@ MiscTests.cpp:<line number>
<testcase classname="<exe-name>.global" name="Tag alias can be registered against tag patterns/Tag aliases must be of the form [@name]" time="{duration}"/> <testcase classname="<exe-name>.global" name="Tag alias can be registered against tag patterns/Tag aliases must be of the form [@name]" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Test case with one argument" time="{duration}"/> <testcase classname="<exe-name>.global" name="Test case with one argument" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Test enum bit values" time="{duration}"/> <testcase classname="<exe-name>.global" name="Test enum bit values" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Text can be formatted using the Text class" time="{duration}"/>
<testcase classname="<exe-name>.global" name="The NO_FAIL macro reports a failure but does not fail the test" time="{duration}"/> <testcase classname="<exe-name>.global" name="The NO_FAIL macro reports a failure but does not fail the test" time="{duration}"/>
<testcase classname="<exe-name>.global" name="This test 'should' fail but doesn't" time="{duration}"/> <testcase classname="<exe-name>.global" name="This test 'should' fail but doesn't" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Tracker" time="{duration}"/> <testcase classname="<exe-name>.global" name="Tracker" time="{duration}"/>
@ -810,8 +789,6 @@ EnumToString.cpp:<line number>
A string sent directly to stdout A string sent directly to stdout
Message from section one Message from section one
Message from section two Message from section two
hello
hello
</system-out> </system-out>
<system-err> <system-err>
A string sent directly to stderr A string sent directly to stderr

View File

@ -2089,599 +2089,6 @@
</Expression> </Expression>
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<TestCase name="Long strings can be wrapped" tags="[wrap]" filename="projects/<exe-name>/TestMain.cpp" >
<Section name="plain string" filename="projects/<exe-name>/TestMain.cpp" >
<Section name="No wrapping" filename="projects/<exe-name>/TestMain.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString
</Original>
<Expanded>
"one two three four"
==
"one two three four"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( testString, TextAttributes().setWidth( 18 ) ).toString() == testString
</Original>
<Expanded>
"one two three four"
==
"one two three four"
</Expanded>
</Expression>
<OverallResults successes="2" failures="0" expectedFailures="0"/>
</Section>
<OverallResults successes="2" failures="0" expectedFailures="0"/>
</Section>
<Section name="plain string" filename="projects/<exe-name>/TestMain.cpp" >
<Section name="Wrapped once" filename="projects/<exe-name>/TestMain.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( testString, TextAttributes().setWidth( 17 ) ).toString() == "one two three\nfour"
</Original>
<Expanded>
"one two three
four"
==
"one two three
four"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( testString, TextAttributes().setWidth( 16 ) ).toString() == "one two three\nfour"
</Original>
<Expanded>
"one two three
four"
==
"one two three
four"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( testString, TextAttributes().setWidth( 14 ) ).toString() == "one two three\nfour"
</Original>
<Expanded>
"one two three
four"
==
"one two three
four"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( testString, TextAttributes().setWidth( 13 ) ).toString() == "one two three\nfour"
</Original>
<Expanded>
"one two three
four"
==
"one two three
four"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( testString, TextAttributes().setWidth( 12 ) ).toString() == "one two\nthree four"
</Original>
<Expanded>
"one two
three four"
==
"one two
three four"
</Expanded>
</Expression>
<OverallResults successes="5" failures="0" expectedFailures="0"/>
</Section>
<OverallResults successes="5" failures="0" expectedFailures="0"/>
</Section>
<Section name="plain string" filename="projects/<exe-name>/TestMain.cpp" >
<Section name="Wrapped twice" filename="projects/<exe-name>/TestMain.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( testString, TextAttributes().setWidth( 9 ) ).toString() == "one two\nthree\nfour"
</Original>
<Expanded>
"one two
three
four"
==
"one two
three
four"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( testString, TextAttributes().setWidth( 8 ) ).toString() == "one two\nthree\nfour"
</Original>
<Expanded>
"one two
three
four"
==
"one two
three
four"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( testString, TextAttributes().setWidth( 7 ) ).toString() == "one two\nthree\nfour"
</Original>
<Expanded>
"one two
three
four"
==
"one two
three
four"
</Expanded>
</Expression>
<OverallResults successes="3" failures="0" expectedFailures="0"/>
</Section>
<OverallResults successes="3" failures="0" expectedFailures="0"/>
</Section>
<Section name="plain string" filename="projects/<exe-name>/TestMain.cpp" >
<Section name="Wrapped three times" filename="projects/<exe-name>/TestMain.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one\ntwo\nthree\nfour"
</Original>
<Expanded>
"one
two
three
four"
==
"one
two
three
four"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( testString, TextAttributes().setWidth( 5 ) ).toString() == "one\ntwo\nthree\nfour"
</Original>
<Expanded>
"one
two
three
four"
==
"one
two
three
four"
</Expanded>
</Expression>
<OverallResults successes="2" failures="0" expectedFailures="0"/>
</Section>
<OverallResults successes="2" failures="0" expectedFailures="0"/>
</Section>
<Section name="plain string" filename="projects/<exe-name>/TestMain.cpp" >
<Section name="Short wrap" filename="projects/<exe-name>/TestMain.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( "abcdef", TextAttributes().setWidth( 4 ) ).toString() == "abc-\ndef"
</Original>
<Expanded>
"abc-
def"
==
"abc-
def"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( "abcdefg", TextAttributes().setWidth( 4 ) ).toString() == "abc-\ndefg"
</Original>
<Expanded>
"abc-
defg"
==
"abc-
defg"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( "abcdefgh", TextAttributes().setWidth( 4 ) ).toString() == "abc-\ndef-\ngh"
</Original>
<Expanded>
"abc-
def-
gh"
==
"abc-
def-
gh"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( testString, TextAttributes().setWidth( 4 ) ).toString() == "one\ntwo\nthr-\nee\nfour"
</Original>
<Expanded>
"one
two
thr-
ee
four"
==
"one
two
thr-
ee
four"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( testString, TextAttributes().setWidth( 3 ) ).toString() == "one\ntwo\nth-\nree\nfo-\nur"
</Original>
<Expanded>
"one
two
th-
ree
fo-
ur"
==
"one
two
th-
ree
fo-
ur"
</Expanded>
</Expression>
<OverallResults successes="5" failures="0" expectedFailures="0"/>
</Section>
<OverallResults successes="5" failures="0" expectedFailures="0"/>
</Section>
<Section name="plain string" filename="projects/<exe-name>/TestMain.cpp" >
<Section name="As container" filename="projects/<exe-name>/TestMain.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
text.size() == 4
</Original>
<Expanded>
4 == 4
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
text[0] == "one"
</Original>
<Expanded>
"one" == "one"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
text[1] == "two"
</Original>
<Expanded>
"two" == "two"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
text[2] == "three"
</Original>
<Expanded>
"three" == "three"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
text[3] == "four"
</Original>
<Expanded>
"four" == "four"
</Expanded>
</Expression>
<OverallResults successes="5" failures="0" expectedFailures="0"/>
</Section>
<OverallResults successes="5" failures="0" expectedFailures="0"/>
</Section>
<Section name="plain string" filename="projects/<exe-name>/TestMain.cpp" >
<Section name="Indent first line differently" filename="projects/<exe-name>/TestMain.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
text.toString() == " one two\n three\n four"
</Original>
<Expanded>
" one two
three
four"
==
" one two
three
four"
</Expanded>
</Expression>
<OverallResults successes="1" failures="0" expectedFailures="0"/>
</Section>
<OverallResults successes="1" failures="0" expectedFailures="0"/>
</Section>
<Section name="With newlines" filename="projects/<exe-name>/TestMain.cpp" >
<Section name="No wrapping" filename="projects/<exe-name>/TestMain.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString
</Original>
<Expanded>
"one two
three four"
==
"one two
three four"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( testString, TextAttributes().setWidth( 18 ) ).toString() == testString
</Original>
<Expanded>
"one two
three four"
==
"one two
three four"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( testString, TextAttributes().setWidth( 10 ) ).toString() == testString
</Original>
<Expanded>
"one two
three four"
==
"one two
three four"
</Expanded>
</Expression>
<OverallResults successes="3" failures="0" expectedFailures="0"/>
</Section>
<OverallResults successes="3" failures="0" expectedFailures="0"/>
</Section>
<Section name="With newlines" filename="projects/<exe-name>/TestMain.cpp" >
<Section name="Trailing newline" filename="projects/<exe-name>/TestMain.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( "abcdef\n", TextAttributes().setWidth( 10 ) ).toString() == "abcdef"
</Original>
<Expanded>
"abcdef" == "abcdef"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( "abcdef", TextAttributes().setWidth( 6 ) ).toString() == "abcdef"
</Original>
<Expanded>
"abcdef" == "abcdef"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( "abcdef\n", TextAttributes().setWidth( 6 ) ).toString() == "abcdef"
</Original>
<Expanded>
"abcdef" == "abcdef"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( "abcdef\n", TextAttributes().setWidth( 5 ) ).toString() == "abcd-\nef"
</Original>
<Expanded>
"abcd-
ef"
==
"abcd-
ef"
</Expanded>
</Expression>
<OverallResults successes="4" failures="0" expectedFailures="0"/>
</Section>
<OverallResults successes="4" failures="0" expectedFailures="0"/>
</Section>
<Section name="With newlines" filename="projects/<exe-name>/TestMain.cpp" >
<Section name="Wrapped once" filename="projects/<exe-name>/TestMain.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( testString, TextAttributes().setWidth( 9 ) ).toString() == "one two\nthree\nfour"
</Original>
<Expanded>
"one two
three
four"
==
"one two
three
four"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( testString, TextAttributes().setWidth( 8 ) ).toString() == "one two\nthree\nfour"
</Original>
<Expanded>
"one two
three
four"
==
"one two
three
four"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( testString, TextAttributes().setWidth( 7 ) ).toString() == "one two\nthree\nfour"
</Original>
<Expanded>
"one two
three
four"
==
"one two
three
four"
</Expanded>
</Expression>
<OverallResults successes="3" failures="0" expectedFailures="0"/>
</Section>
<OverallResults successes="3" failures="0" expectedFailures="0"/>
</Section>
<Section name="With newlines" filename="projects/<exe-name>/TestMain.cpp" >
<Section name="Wrapped twice" filename="projects/<exe-name>/TestMain.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one\ntwo\nthree\nfour"
</Original>
<Expanded>
"one
two
three
four"
==
"one
two
three
four"
</Expanded>
</Expression>
<OverallResults successes="1" failures="0" expectedFailures="0"/>
</Section>
<OverallResults successes="1" failures="0" expectedFailures="0"/>
</Section>
<Section name="With wrap-before/ after characters" filename="projects/<exe-name>/TestMain.cpp" >
<Section name="No wrapping" filename="projects/<exe-name>/TestMain.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString
</Original>
<Expanded>
"one,two(three) &lt;here>"
==
"one,two(three) &lt;here>"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( testString, TextAttributes().setWidth( 24 ) ).toString() == testString
</Original>
<Expanded>
"one,two(three) &lt;here>"
==
"one,two(three) &lt;here>"
</Expanded>
</Expression>
<OverallResults successes="2" failures="0" expectedFailures="0"/>
</Section>
<OverallResults successes="2" failures="0" expectedFailures="0"/>
</Section>
<Section name="With wrap-before/ after characters" filename="projects/<exe-name>/TestMain.cpp" >
<Section name="Wrap before" filename="projects/<exe-name>/TestMain.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( testString, TextAttributes().setWidth( 11 ) ).toString() == "one,two\n(three)\n&lt;here>"
</Original>
<Expanded>
"one,two
(three)
&lt;here>"
==
"one,two
(three)
&lt;here>"
</Expanded>
</Expression>
<OverallResults successes="1" failures="0" expectedFailures="0"/>
</Section>
<OverallResults successes="1" failures="0" expectedFailures="0"/>
</Section>
<Section name="With wrap-before/ after characters" filename="projects/<exe-name>/TestMain.cpp" >
<Section name="Wrap after" filename="projects/<exe-name>/TestMain.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one,\ntwo\n(thre-\ne)\n&lt;here>"
</Original>
<Expanded>
"one,
two
(thre-
e)
&lt;here>"
==
"one,
two
(thre-
e)
&lt;here>"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( testString, TextAttributes().setWidth( 5 ) ).toString() == "one,\ntwo\n(thr-\nee)\n&lt;her-\ne>"
</Original>
<Expanded>
"one,
two
(thr-
ee)
&lt;her-
e>"
==
"one,
two
(thr-
ee)
&lt;her-
e>"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( testString, TextAttributes().setWidth( 4 ) ).toString() == "one,\ntwo\n(th-\nree)\n&lt;he-\nre>"
</Original>
<Expanded>
"one,
two
(th-
ree)
&lt;he-
re>"
==
"one,
two
(th-
ree)
&lt;he-
re>"
</Expanded>
</Expression>
<OverallResults successes="3" failures="0" expectedFailures="0"/>
</Section>
<OverallResults successes="3" failures="0" expectedFailures="0"/>
</Section>
<OverallResult success="true"/>
</TestCase>
<TestCase name="ManuallyRegistered" filename="projects/<exe-name>/TestMain.cpp" > <TestCase name="ManuallyRegistered" filename="projects/<exe-name>/TestMain.cpp" >
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
@ -6084,14 +5491,6 @@ Message from section two
</Section> </Section>
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<TestCase name="Strings can be rendered with colour" tags="[.][.colour][hide]" filename="projects/<exe-name>/TestMain.cpp" >
<OverallResult success="true">
<StdOut>
hello
hello
</StdOut>
</OverallResult>
</TestCase>
<TestCase name="Tabs and newlines show in output" tags="[.][failing][hide][whitespace]" filename="projects/<exe-name>/MiscTests.cpp" > <TestCase name="Tabs and newlines show in output" tags="[.][failing][hide][whitespace]" filename="projects/<exe-name>/MiscTests.cpp" >
<Expression success="false" type="CHECK" filename="projects/<exe-name>/MiscTests.cpp" > <Expression success="false" type="CHECK" filename="projects/<exe-name>/MiscTests.cpp" >
<Original> <Original>
@ -6205,29 +5604,6 @@ hello
</Expression> </Expression>
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<TestCase name="Text can be formatted using the Text class" filename="projects/<exe-name>/TestMain.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( "hi there" ).toString() == "hi there"
</Original>
<Expanded>
"hi there" == "hi there"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
Text( "hi there", narrow ).toString() == "hi\nthere"
</Original>
<Expanded>
"hi
there"
==
"hi
there"
</Expanded>
</Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="The NO_FAIL macro reports a failure but does not fail the test" tags="[messages]" filename="projects/<exe-name>/MessageTests.cpp" > <TestCase name="The NO_FAIL macro reports a failure but does not fail the test" tags="[messages]" filename="projects/<exe-name>/MessageTests.cpp" >
<Expression success="false" type="CHECK_NOFAIL" filename="projects/<exe-name>/MessageTests.cpp" > <Expression success="false" type="CHECK_NOFAIL" filename="projects/<exe-name>/MessageTests.cpp" >
<Original> <Original>
@ -8316,7 +7692,7 @@ spanner <OverallResult success="true"/>
<Section name="replace single char" filename="projects/<exe-name>/TestMain.cpp" > <Section name="replace single char" filename="projects/<exe-name>/TestMain.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" > <Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original> <Original>
replaceInPlace( letters, "b", "z" ) Catch::replaceInPlace( letters, "b", "z" )
</Original> </Original>
<Expanded> <Expanded>
true true
@ -8335,7 +7711,7 @@ spanner <OverallResult success="true"/>
<Section name="replace two chars" filename="projects/<exe-name>/TestMain.cpp" > <Section name="replace two chars" filename="projects/<exe-name>/TestMain.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" > <Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original> <Original>
replaceInPlace( letters, "c", "z" ) Catch::replaceInPlace( letters, "c", "z" )
</Original> </Original>
<Expanded> <Expanded>
true true
@ -8354,7 +7730,7 @@ spanner <OverallResult success="true"/>
<Section name="replace first char" filename="projects/<exe-name>/TestMain.cpp" > <Section name="replace first char" filename="projects/<exe-name>/TestMain.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" > <Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original> <Original>
replaceInPlace( letters, "a", "z" ) Catch::replaceInPlace( letters, "a", "z" )
</Original> </Original>
<Expanded> <Expanded>
true true
@ -8373,7 +7749,7 @@ spanner <OverallResult success="true"/>
<Section name="replace last char" filename="projects/<exe-name>/TestMain.cpp" > <Section name="replace last char" filename="projects/<exe-name>/TestMain.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" > <Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original> <Original>
replaceInPlace( letters, "g", "z" ) Catch::replaceInPlace( letters, "g", "z" )
</Original> </Original>
<Expanded> <Expanded>
true true
@ -8392,7 +7768,7 @@ spanner <OverallResult success="true"/>
<Section name="replace all chars" filename="projects/<exe-name>/TestMain.cpp" > <Section name="replace all chars" filename="projects/<exe-name>/TestMain.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" > <Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original> <Original>
replaceInPlace( letters, letters, "replaced" ) Catch::replaceInPlace( letters, letters, "replaced" )
</Original> </Original>
<Expanded> <Expanded>
true true
@ -8411,7 +7787,7 @@ spanner <OverallResult success="true"/>
<Section name="replace no chars" filename="projects/<exe-name>/TestMain.cpp" > <Section name="replace no chars" filename="projects/<exe-name>/TestMain.cpp" >
<Expression success="true" type="CHECK_FALSE" filename="projects/<exe-name>/TestMain.cpp" > <Expression success="true" type="CHECK_FALSE" filename="projects/<exe-name>/TestMain.cpp" >
<Original> <Original>
!replaceInPlace( letters, "x", "z" ) !Catch::replaceInPlace( letters, "x", "z" )
</Original> </Original>
<Expanded> <Expanded>
!false !false
@ -8430,7 +7806,7 @@ spanner <OverallResult success="true"/>
<Section name="escape '" filename="projects/<exe-name>/TestMain.cpp" > <Section name="escape '" filename="projects/<exe-name>/TestMain.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" > <Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
<Original> <Original>
replaceInPlace( s, "'", "|'" ) Catch::replaceInPlace( s, "'", "|'" )
</Original> </Original>
<Expanded> <Expanded>
true true
@ -9065,7 +8441,7 @@ spanner <OverallResult success="true"/>
</Section> </Section>
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<OverallResults successes="821" failures="99" expectedFailures="21"/> <OverallResults successes="779" failures="99" expectedFailures="21"/>
</Group> </Group>
<OverallResults successes="821" failures="98" expectedFailures="21"/> <OverallResults successes="779" failures="98" expectedFailures="21"/>
</Catch> </Catch>

View File

@ -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) <here>";
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<here>" );
}
SECTION( "Wrap after" ) {
CHECK( Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one,\ntwo\n(thre-\ne)\n<here>" );
CHECK( Text( testString, TextAttributes().setWidth( 5 ) ).toString() == "one,\ntwo\n(thr-\nee)\n<her-\ne>" );
CHECK( Text( testString, TextAttributes().setWidth( 4 ) ).toString() == "one,\ntwo\n(th-\nree)\n<he-\nre>" );
}
}
}
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<ColourIndex> 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<std::size_t>( _index >= 0
? _index
: static_cast<int>( string.size() )+_index );
}
std::string string;
std::vector<ColourIndex> colours;
};
TEST_CASE( "replaceInPlace" ) { TEST_CASE( "replaceInPlace" ) {
std::string letters = "abcdefcg"; std::string letters = "abcdefcg";
SECTION( "replace single char" ) { SECTION( "replace single char" ) {
CHECK( replaceInPlace( letters, "b", "z" ) ); CHECK( Catch::replaceInPlace( letters, "b", "z" ) );
CHECK( letters == "azcdefcg" ); CHECK( letters == "azcdefcg" );
} }
SECTION( "replace two chars" ) { SECTION( "replace two chars" ) {
CHECK( replaceInPlace( letters, "c", "z" ) ); CHECK( Catch::replaceInPlace( letters, "c", "z" ) );
CHECK( letters == "abzdefzg" ); CHECK( letters == "abzdefzg" );
} }
SECTION( "replace first char" ) { SECTION( "replace first char" ) {
CHECK( replaceInPlace( letters, "a", "z" ) ); CHECK( Catch::replaceInPlace( letters, "a", "z" ) );
CHECK( letters == "zbcdefcg" ); CHECK( letters == "zbcdefcg" );
} }
SECTION( "replace last char" ) { SECTION( "replace last char" ) {
CHECK( replaceInPlace( letters, "g", "z" ) ); CHECK( Catch::replaceInPlace( letters, "g", "z" ) );
CHECK( letters == "abcdefcz" ); CHECK( letters == "abcdefcz" );
} }
SECTION( "replace all chars" ) { SECTION( "replace all chars" ) {
CHECK( replaceInPlace( letters, letters, "replaced" ) ); CHECK( Catch::replaceInPlace( letters, letters, "replaced" ) );
CHECK( letters == "replaced" ); CHECK( letters == "replaced" );
} }
SECTION( "replace no chars" ) { SECTION( "replace no chars" ) {
CHECK_FALSE( replaceInPlace( letters, "x", "z" ) ); CHECK_FALSE( Catch::replaceInPlace( letters, "x", "z" ) );
CHECK( letters == letters ); CHECK( letters == letters );
} }
SECTION( "escape '" ) { SECTION( "escape '" ) {
std::string s = "didn't"; std::string s = "didn't";
CHECK( replaceInPlace( s, "'", "|'" ) ); CHECK( Catch::replaceInPlace( s, "'", "|'" ) );
CHECK( s == "didn|'t" ); 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() { inline void manuallyRegisteredTestFunction() {
SUCCEED( "was called" ); SUCCEED( "was called" );