mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 12:55:40 +02: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:
@@ -584,11 +584,11 @@ MiscTests.cpp:<line number>: FAILED:
|
||||
CHECK( s1 == s2 )
|
||||
with expansion:
|
||||
"if ($b == 10) {
|
||||
$a= 20;
|
||||
$a = 20;
|
||||
}"
|
||||
==
|
||||
"if ($b == 10) {
|
||||
$a = 20;
|
||||
$a = 20;
|
||||
}
|
||||
"
|
||||
|
||||
@@ -831,5 +831,5 @@ with expansion:
|
||||
|
||||
===============================================================================
|
||||
test cases: 159 | 115 passed | 42 failed | 2 failed as expected
|
||||
assertions: 909 | 813 passed | 78 failed | 18 failed as expected
|
||||
assertions: 915 | 819 passed | 78 failed | 18 failed as expected
|
||||
|
||||
|
@@ -2932,13 +2932,9 @@ TestMain.cpp:<line number>
|
||||
|
||||
TestMain.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK( Text( "abcdef\n", TextAttributes().setWidth( 10 ) ).toString() == "abcdef\n" )
|
||||
CHECK( Text( "abcdef\n", TextAttributes().setWidth( 10 ) ).toString() == "abcdef" )
|
||||
with expansion:
|
||||
"abcdef
|
||||
"
|
||||
==
|
||||
"abcdef
|
||||
"
|
||||
"abcdef" == "abcdef"
|
||||
|
||||
TestMain.cpp:<line number>:
|
||||
PASSED:
|
||||
@@ -2948,13 +2944,19 @@ with expansion:
|
||||
|
||||
TestMain.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK( Text( "abcdef\n", TextAttributes().setWidth( 6 ) ).toString() == "abcdef\n" )
|
||||
CHECK( Text( "abcdef\n", TextAttributes().setWidth( 6 ) ).toString() == "abcdef" )
|
||||
with expansion:
|
||||
"abcdef
|
||||
"
|
||||
"abcdef" == "abcdef"
|
||||
|
||||
TestMain.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK( Text( "abcdef\n", TextAttributes().setWidth( 5 ) ).toString() == "abcd-\nef" )
|
||||
with expansion:
|
||||
"abcd-
|
||||
ef"
|
||||
==
|
||||
"abcdef
|
||||
"
|
||||
"abcd-
|
||||
ef"
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Long strings can be wrapped
|
||||
@@ -3024,24 +3026,107 @@ with expansion:
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Long strings can be wrapped
|
||||
With tabs
|
||||
With wrap-before/ after characters
|
||||
No wrapping
|
||||
-------------------------------------------------------------------------------
|
||||
TestMain.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
TestMain.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK( Text( testString, TextAttributes().setWidth( 15 ) ).toString() == "one two three\n four\n five\n six" )
|
||||
CHECK( Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString )
|
||||
with expansion:
|
||||
"one two three
|
||||
four
|
||||
five
|
||||
six"
|
||||
"one,two(three) <here>"
|
||||
==
|
||||
"one two three
|
||||
four
|
||||
five
|
||||
six"
|
||||
"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>"
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Long text is truncted
|
||||
@@ -6458,11 +6543,11 @@ MiscTests.cpp:<line number>: FAILED:
|
||||
CHECK( s1 == s2 )
|
||||
with expansion:
|
||||
"if ($b == 10) {
|
||||
$a= 20;
|
||||
$a = 20;
|
||||
}"
|
||||
==
|
||||
"if ($b == 10) {
|
||||
$a = 20;
|
||||
$a = 20;
|
||||
}
|
||||
"
|
||||
|
||||
@@ -6478,36 +6563,32 @@ PASSED:
|
||||
CHECK_THAT( what, Contains( "[@zzz]" ) )
|
||||
with expansion:
|
||||
"error: tag alias, "[@zzz]" already registered.
|
||||
First seen at file:2
|
||||
Redefined at file:10" contains: "
|
||||
[@zzz]"
|
||||
First seen at file:2
|
||||
Redefined at file:10" contains: "[@zzz]"
|
||||
|
||||
TagAliasTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_THAT( what, Contains( "file" ) )
|
||||
with expansion:
|
||||
"error: tag alias, "[@zzz]" already registered.
|
||||
First seen at file:2
|
||||
Redefined at file:10" contains:
|
||||
"file"
|
||||
First seen at file:2
|
||||
Redefined at file:10" contains: "file"
|
||||
|
||||
TagAliasTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_THAT( what, Contains( "2" ) )
|
||||
with expansion:
|
||||
"error: tag alias, "[@zzz]" already registered.
|
||||
First seen at file:2
|
||||
Redefined at file:10" contains:
|
||||
"2"
|
||||
First seen at file:2
|
||||
Redefined at file:10" contains: "2"
|
||||
|
||||
TagAliasTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_THAT( what, Contains( "10" ) )
|
||||
with expansion:
|
||||
"error: tag alias, "[@zzz]" already registered.
|
||||
First seen at file:2
|
||||
Redefined at file:10" contains:
|
||||
"10"
|
||||
First seen at file:2
|
||||
Redefined at file:10" contains: "10"
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Tag alias can be registered against tag patterns
|
||||
@@ -8972,5 +9053,5 @@ PASSED:
|
||||
|
||||
===============================================================================
|
||||
test cases: 159 | 114 passed | 43 failed | 2 failed as expected
|
||||
assertions: 911 | 813 passed | 80 failed | 18 failed as expected
|
||||
assertions: 917 | 819 passed | 80 failed | 18 failed as expected
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.1" encoding="UTF-8"?>
|
||||
<testsuites>
|
||||
<testsuite name="<exe-name>" errors="13" failures="68" tests="912" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||
<testsuite name="<exe-name>" errors="13" failures="68" tests="918" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||
<testcase classname="global" name="# A test name that starts with a #" time="{duration}"/>
|
||||
<testcase classname="global" name="'Not' checks that should fail" time="{duration}">
|
||||
<failure message="false != false" type="CHECK">
|
||||
@@ -242,7 +242,9 @@ ConditionTests.cpp:<line number>
|
||||
<testcase classname="Long strings can be wrapped" name="With newlines/Trailing newline" time="{duration}"/>
|
||||
<testcase classname="Long strings can be wrapped" name="With newlines/Wrapped once" time="{duration}"/>
|
||||
<testcase classname="Long strings can be wrapped" name="With newlines/Wrapped twice" time="{duration}"/>
|
||||
<testcase classname="Long strings can be wrapped" name="With tabs" time="{duration}"/>
|
||||
<testcase classname="Long strings can be wrapped" name="With wrap-before/ after characters/No wrapping" time="{duration}"/>
|
||||
<testcase classname="Long strings can be wrapped" name="With wrap-before/ after characters/Wrap before" time="{duration}"/>
|
||||
<testcase classname="Long strings can be wrapped" name="With wrap-before/ after characters/Wrap after" time="{duration}"/>
|
||||
<testcase classname="global" name="Long text is truncted" time="{duration}"/>
|
||||
<testcase classname="global" name="ManuallyRegistered" time="{duration}"/>
|
||||
<testcase classname="global" name="Matchers can be (AllOf) composed with the && operator" time="{duration}"/>
|
||||
|
@@ -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