mirror of
https://github.com/catchorg/Catch2.git
synced 2025-11-04 22:19:34 +01:00
Text formatting rework
Rewrote main wrapping loop. Now uses iterators instead of indices and intermediate strings. Differentiates between chars to wrap before, after or instead of. Doesn’t preserve trailing newlines. Wraps or more characters. Dropped support for using tab character as an indent setting control char. Hopefully avoids all the undefined behaviour and other bugs of the previous implementation.
This commit is contained in:
@@ -2987,14 +2987,10 @@ three four"
|
||||
<Section name="Trailing newline">
|
||||
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
|
||||
<Original>
|
||||
Text( "abcdef\n", TextAttributes().setWidth( 10 ) ).toString() == "abcdef\n"
|
||||
Text( "abcdef\n", TextAttributes().setWidth( 10 ) ).toString() == "abcdef"
|
||||
</Original>
|
||||
<Expanded>
|
||||
"abcdef
|
||||
"
|
||||
==
|
||||
"abcdef
|
||||
"
|
||||
"abcdef" == "abcdef"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
|
||||
@@ -3007,19 +3003,27 @@ three four"
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
|
||||
<Original>
|
||||
Text( "abcdef\n", TextAttributes().setWidth( 6 ) ).toString() == "abcdef\n"
|
||||
Text( "abcdef\n", TextAttributes().setWidth( 6 ) ).toString() == "abcdef"
|
||||
</Original>
|
||||
<Expanded>
|
||||
"abcdef
|
||||
"
|
||||
==
|
||||
"abcdef
|
||||
"
|
||||
"abcdef" == "abcdef"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="3" failures="0" expectedFailures="0"/>
|
||||
<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="3" failures="0" expectedFailures="0"/>
|
||||
<OverallResults successes="4" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="With newlines">
|
||||
<Section name="Wrapped once">
|
||||
@@ -3091,25 +3095,116 @@ four"
|
||||
</Section>
|
||||
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="With tabs">
|
||||
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
|
||||
<Original>
|
||||
Text( testString, TextAttributes().setWidth( 15 ) ).toString() == "one two three\n four\n five\n six"
|
||||
</Original>
|
||||
<Expanded>
|
||||
"one two three
|
||||
four
|
||||
five
|
||||
six"
|
||||
<Section name="With wrap-before/ after characters">
|
||||
<Section name="No wrapping">
|
||||
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
|
||||
<Original>
|
||||
Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString
|
||||
</Original>
|
||||
<Expanded>
|
||||
"one,two(three) <here>"
|
||||
==
|
||||
"one two three
|
||||
four
|
||||
five
|
||||
six"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
"one,two(three) <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) <here>"
|
||||
==
|
||||
"one,two(three) <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">
|
||||
<Section name="Wrap before">
|
||||
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
|
||||
<Original>
|
||||
Text( testString, TextAttributes().setWidth( 11 ) ).toString() == "one,two\n(three)\n<here>"
|
||||
</Original>
|
||||
<Expanded>
|
||||
"one,two
|
||||
(three)
|
||||
<here>"
|
||||
==
|
||||
"one,two
|
||||
(three)
|
||||
<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">
|
||||
<Section name="Wrap after">
|
||||
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
|
||||
<Original>
|
||||
Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one,\ntwo\n(thre-\ne)\n<here>"
|
||||
</Original>
|
||||
<Expanded>
|
||||
"one,
|
||||
two
|
||||
(thre-
|
||||
e)
|
||||
<here>"
|
||||
==
|
||||
"one,
|
||||
two
|
||||
(thre-
|
||||
e)
|
||||
<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<her-\ne>"
|
||||
</Original>
|
||||
<Expanded>
|
||||
"one,
|
||||
two
|
||||
(thr-
|
||||
ee)
|
||||
<her-
|
||||
e>"
|
||||
==
|
||||
"one,
|
||||
two
|
||||
(thr-
|
||||
ee)
|
||||
<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<he-\nre>"
|
||||
</Original>
|
||||
<Expanded>
|
||||
"one,
|
||||
two
|
||||
(th-
|
||||
ree)
|
||||
<he-
|
||||
re>"
|
||||
==
|
||||
"one,
|
||||
two
|
||||
(th-
|
||||
ree)
|
||||
<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="Long text is truncted">
|
||||
@@ -9432,7 +9527,7 @@ there"
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<OverallResults successes="813" failures="81" expectedFailures="18"/>
|
||||
<OverallResults successes="819" failures="81" expectedFailures="18"/>
|
||||
</Group>
|
||||
<OverallResults successes="813" failures="80" expectedFailures="18"/>
|
||||
<OverallResults successes="819" failures="80" expectedFailures="18"/>
|
||||
</Catch>
|
||||
|
||||
Reference in New Issue
Block a user