Skip to content

Commit

Permalink
Update outdated tests for stringifying characters
Browse files Browse the repository at this point in the history
Previously the tests relied purely on output changes in approvals.
Now the stringification output is checked directly as part of the
unit tests.
  • Loading branch information
horenmar committed Mar 1, 2024
1 parent fb51116 commit c3fd4eb
Show file tree
Hide file tree
Showing 12 changed files with 153 additions and 292 deletions.
26 changes: 11 additions & 15 deletions tests/SelfTest/Baselines/compact.sw.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -350,20 +350,16 @@ Details.tests.cpp:<line number>: passed: lt( "a", "b" ) for: true
Details.tests.cpp:<line number>: passed: lt( "a", "B" ) for: true
Details.tests.cpp:<line number>: passed: lt( "A", "b" ) for: true
Details.tests.cpp:<line number>: passed: lt( "A", "B" ) for: true
ToStringGeneral.tests.cpp:<line number>: passed: tab == '\t' for: '\t' == '\t'
ToStringGeneral.tests.cpp:<line number>: passed: newline == '\n' for: '\n' == '\n'
ToStringGeneral.tests.cpp:<line number>: passed: carr_return == '\r' for: '\r' == '\r'
ToStringGeneral.tests.cpp:<line number>: passed: form_feed == '\f' for: '\f' == '\f'
ToStringGeneral.tests.cpp:<line number>: passed: space == ' ' for: ' ' == ' '
ToStringGeneral.tests.cpp:<line number>: passed: c == chars[i] for: 'a' == 'a'
ToStringGeneral.tests.cpp:<line number>: passed: c == chars[i] for: 'z' == 'z'
ToStringGeneral.tests.cpp:<line number>: passed: c == chars[i] for: 'A' == 'A'
ToStringGeneral.tests.cpp:<line number>: passed: c == chars[i] for: 'Z' == 'Z'
ToStringGeneral.tests.cpp:<line number>: passed: null_terminator == '\0' for: 0 == 0
ToStringGeneral.tests.cpp:<line number>: passed: c == i for: 2 == 2
ToStringGeneral.tests.cpp:<line number>: passed: c == i for: 3 == 3
ToStringGeneral.tests.cpp:<line number>: passed: c == i for: 4 == 4
ToStringGeneral.tests.cpp:<line number>: passed: c == i for: 5 == 5
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify('\t') == "'\\t'" for: "'\t'" == "'\t'"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify('\n') == "'\\n'" for: "'\n'" == "'\n'"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify('\r') == "'\\r'" for: "'\r'" == "'\r'"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify('\f') == "'\\f'" for: "'\f'" == "'\f'"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( ' ' ) == "' '" for: "' '" == "' '"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( 'A' ) == "'A'" for: "'A'" == "'A'"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( 'z' ) == "'z'" for: "'z'" == "'z'"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( '\0' ) == "0" for: "0" == "0"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( static_cast<char>(2) ) == "2" for: "2" == "2"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( static_cast<char>(5) ) == "5" for: "5" == "5"
Clara.tests.cpp:<line number>: passed: name.empty() for: true
Clara.tests.cpp:<line number>: passed: name == "foo" for: "foo" == "foo"
Clara.tests.cpp:<line number>: passed: !(parse_result) for: !{?}
Expand Down Expand Up @@ -2690,6 +2686,6 @@ InternalBenchmark.tests.cpp:<line number>: passed: q3 == 23. for: 23.0 == 23.0
Misc.tests.cpp:<line number>: passed:
Misc.tests.cpp:<line number>: passed:
test cases: 417 | 312 passed | 85 failed | 6 skipped | 14 failed as expected
assertions: 2260 | 2079 passed | 146 failed | 35 failed as expected
assertions: 2256 | 2075 passed | 146 failed | 35 failed as expected


26 changes: 11 additions & 15 deletions tests/SelfTest/Baselines/compact.sw.multi.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -348,20 +348,16 @@ Details.tests.cpp:<line number>: passed: lt( "a", "b" ) for: true
Details.tests.cpp:<line number>: passed: lt( "a", "B" ) for: true
Details.tests.cpp:<line number>: passed: lt( "A", "b" ) for: true
Details.tests.cpp:<line number>: passed: lt( "A", "B" ) for: true
ToStringGeneral.tests.cpp:<line number>: passed: tab == '\t' for: '\t' == '\t'
ToStringGeneral.tests.cpp:<line number>: passed: newline == '\n' for: '\n' == '\n'
ToStringGeneral.tests.cpp:<line number>: passed: carr_return == '\r' for: '\r' == '\r'
ToStringGeneral.tests.cpp:<line number>: passed: form_feed == '\f' for: '\f' == '\f'
ToStringGeneral.tests.cpp:<line number>: passed: space == ' ' for: ' ' == ' '
ToStringGeneral.tests.cpp:<line number>: passed: c == chars[i] for: 'a' == 'a'
ToStringGeneral.tests.cpp:<line number>: passed: c == chars[i] for: 'z' == 'z'
ToStringGeneral.tests.cpp:<line number>: passed: c == chars[i] for: 'A' == 'A'
ToStringGeneral.tests.cpp:<line number>: passed: c == chars[i] for: 'Z' == 'Z'
ToStringGeneral.tests.cpp:<line number>: passed: null_terminator == '\0' for: 0 == 0
ToStringGeneral.tests.cpp:<line number>: passed: c == i for: 2 == 2
ToStringGeneral.tests.cpp:<line number>: passed: c == i for: 3 == 3
ToStringGeneral.tests.cpp:<line number>: passed: c == i for: 4 == 4
ToStringGeneral.tests.cpp:<line number>: passed: c == i for: 5 == 5
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify('\t') == "'\\t'" for: "'\t'" == "'\t'"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify('\n') == "'\\n'" for: "'\n'" == "'\n'"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify('\r') == "'\\r'" for: "'\r'" == "'\r'"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify('\f') == "'\\f'" for: "'\f'" == "'\f'"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( ' ' ) == "' '" for: "' '" == "' '"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( 'A' ) == "'A'" for: "'A'" == "'A'"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( 'z' ) == "'z'" for: "'z'" == "'z'"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( '\0' ) == "0" for: "0" == "0"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( static_cast<char>(2) ) == "2" for: "2" == "2"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( static_cast<char>(5) ) == "5" for: "5" == "5"
Clara.tests.cpp:<line number>: passed: name.empty() for: true
Clara.tests.cpp:<line number>: passed: name == "foo" for: "foo" == "foo"
Clara.tests.cpp:<line number>: passed: !(parse_result) for: !{?}
Expand Down Expand Up @@ -2679,6 +2675,6 @@ InternalBenchmark.tests.cpp:<line number>: passed: q3 == 23. for: 23.0 == 23.0
Misc.tests.cpp:<line number>: passed:
Misc.tests.cpp:<line number>: passed:
test cases: 417 | 312 passed | 85 failed | 6 skipped | 14 failed as expected
assertions: 2260 | 2079 passed | 146 failed | 35 failed as expected
assertions: 2256 | 2075 passed | 146 failed | 35 failed as expected


2 changes: 1 addition & 1 deletion tests/SelfTest/Baselines/console.std.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1589,5 +1589,5 @@ due to unexpected exception with message:

===============================================================================
test cases: 417 | 326 passed | 70 failed | 7 skipped | 14 failed as expected
assertions: 2243 | 2079 passed | 129 failed | 35 failed as expected
assertions: 2239 | 2075 passed | 129 failed | 35 failed as expected

62 changes: 21 additions & 41 deletions tests/SelfTest/Baselines/console.sw.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2904,24 +2904,24 @@ ToStringGeneral.tests.cpp:<line number>
...............................................................................

ToStringGeneral.tests.cpp:<line number>: PASSED:
CHECK( tab == '\t' )
CHECK( ::Catch::Detail::stringify('\t') == "'\\t'" )
with expansion:
'\t' == '\t'
"'\t'" == "'\t'"

ToStringGeneral.tests.cpp:<line number>: PASSED:
CHECK( newline == '\n' )
CHECK( ::Catch::Detail::stringify('\n') == "'\\n'" )
with expansion:
'\n' == '\n'
"'\n'" == "'\n'"

ToStringGeneral.tests.cpp:<line number>: PASSED:
CHECK( carr_return == '\r' )
CHECK( ::Catch::Detail::stringify('\r') == "'\\r'" )
with expansion:
'\r' == '\r'
"'\r'" == "'\r'"

ToStringGeneral.tests.cpp:<line number>: PASSED:
CHECK( form_feed == '\f' )
CHECK( ::Catch::Detail::stringify('\f') == "'\\f'" )
with expansion:
'\f' == '\f'
"'\f'" == "'\f'"

-------------------------------------------------------------------------------
Character pretty printing
Expand All @@ -2931,29 +2931,19 @@ ToStringGeneral.tests.cpp:<line number>
...............................................................................

ToStringGeneral.tests.cpp:<line number>: PASSED:
CHECK( space == ' ' )
CHECK( ::Catch::Detail::stringify( ' ' ) == "' '" )
with expansion:
' ' == ' '
"' '" == "' '"

ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == chars[i] )
CHECK( ::Catch::Detail::stringify( 'A' ) == "'A'" )
with expansion:
'a' == 'a'
"'A'" == "'A'"

ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == chars[i] )
CHECK( ::Catch::Detail::stringify( 'z' ) == "'z'" )
with expansion:
'z' == 'z'

ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == chars[i] )
with expansion:
'A' == 'A'

ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == chars[i] )
with expansion:
'Z' == 'Z'
"'z'" == "'z'"

-------------------------------------------------------------------------------
Character pretty printing
Expand All @@ -2963,29 +2953,19 @@ ToStringGeneral.tests.cpp:<line number>
...............................................................................

ToStringGeneral.tests.cpp:<line number>: PASSED:
CHECK( null_terminator == '\0' )
with expansion:
0 == 0

ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == i )
with expansion:
2 == 2

ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == i )
CHECK( ::Catch::Detail::stringify( '\0' ) == "0" )
with expansion:
3 == 3
"0" == "0"

ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == i )
CHECK( ::Catch::Detail::stringify( static_cast<char>(2) ) == "2" )
with expansion:
4 == 4
"2" == "2"

ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == i )
CHECK( ::Catch::Detail::stringify( static_cast<char>(5) ) == "5" )
with expansion:
5 == 5
"5" == "5"

-------------------------------------------------------------------------------
Clara::Arg supports single-arg parse the way Opt does
Expand Down Expand Up @@ -18752,5 +18732,5 @@ Misc.tests.cpp:<line number>: PASSED:

===============================================================================
test cases: 417 | 312 passed | 85 failed | 6 skipped | 14 failed as expected
assertions: 2260 | 2079 passed | 146 failed | 35 failed as expected
assertions: 2256 | 2075 passed | 146 failed | 35 failed as expected

62 changes: 21 additions & 41 deletions tests/SelfTest/Baselines/console.sw.multi.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2902,24 +2902,24 @@ ToStringGeneral.tests.cpp:<line number>
...............................................................................

ToStringGeneral.tests.cpp:<line number>: PASSED:
CHECK( tab == '\t' )
CHECK( ::Catch::Detail::stringify('\t') == "'\\t'" )
with expansion:
'\t' == '\t'
"'\t'" == "'\t'"

ToStringGeneral.tests.cpp:<line number>: PASSED:
CHECK( newline == '\n' )
CHECK( ::Catch::Detail::stringify('\n') == "'\\n'" )
with expansion:
'\n' == '\n'
"'\n'" == "'\n'"

ToStringGeneral.tests.cpp:<line number>: PASSED:
CHECK( carr_return == '\r' )
CHECK( ::Catch::Detail::stringify('\r') == "'\\r'" )
with expansion:
'\r' == '\r'
"'\r'" == "'\r'"

ToStringGeneral.tests.cpp:<line number>: PASSED:
CHECK( form_feed == '\f' )
CHECK( ::Catch::Detail::stringify('\f') == "'\\f'" )
with expansion:
'\f' == '\f'
"'\f'" == "'\f'"

-------------------------------------------------------------------------------
Character pretty printing
Expand All @@ -2929,29 +2929,19 @@ ToStringGeneral.tests.cpp:<line number>
...............................................................................

ToStringGeneral.tests.cpp:<line number>: PASSED:
CHECK( space == ' ' )
CHECK( ::Catch::Detail::stringify( ' ' ) == "' '" )
with expansion:
' ' == ' '
"' '" == "' '"

ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == chars[i] )
CHECK( ::Catch::Detail::stringify( 'A' ) == "'A'" )
with expansion:
'a' == 'a'
"'A'" == "'A'"

ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == chars[i] )
CHECK( ::Catch::Detail::stringify( 'z' ) == "'z'" )
with expansion:
'z' == 'z'

ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == chars[i] )
with expansion:
'A' == 'A'

ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == chars[i] )
with expansion:
'Z' == 'Z'
"'z'" == "'z'"

-------------------------------------------------------------------------------
Character pretty printing
Expand All @@ -2961,29 +2951,19 @@ ToStringGeneral.tests.cpp:<line number>
...............................................................................

ToStringGeneral.tests.cpp:<line number>: PASSED:
CHECK( null_terminator == '\0' )
with expansion:
0 == 0

ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == i )
with expansion:
2 == 2

ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == i )
CHECK( ::Catch::Detail::stringify( '\0' ) == "0" )
with expansion:
3 == 3
"0" == "0"

ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == i )
CHECK( ::Catch::Detail::stringify( static_cast<char>(2) ) == "2" )
with expansion:
4 == 4
"2" == "2"

ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == i )
CHECK( ::Catch::Detail::stringify( static_cast<char>(5) ) == "5" )
with expansion:
5 == 5
"5" == "5"

-------------------------------------------------------------------------------
Clara::Arg supports single-arg parse the way Opt does
Expand Down Expand Up @@ -18741,5 +18721,5 @@ Misc.tests.cpp:<line number>: PASSED:

===============================================================================
test cases: 417 | 312 passed | 85 failed | 6 skipped | 14 failed as expected
assertions: 2260 | 2079 passed | 146 failed | 35 failed as expected
assertions: 2256 | 2075 passed | 146 failed | 35 failed as expected

2 changes: 1 addition & 1 deletion tests/SelfTest/Baselines/junit.sw.approved.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuitesloose text artifact
>
<testsuite name="<exe-name>" errors="17" failures="129" skipped="12" tests="2272" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<testsuite name="<exe-name>" errors="17" failures="129" skipped="12" tests="2268" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties>
<property name="random-seed" value="1"/>
<property name="filters" value="&quot;*&quot; ~[!nonportable] ~[!benchmark] ~[approvals]"/>
Expand Down
2 changes: 1 addition & 1 deletion tests/SelfTest/Baselines/junit.sw.multi.approved.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="<exe-name>" errors="17" failures="129" skipped="12" tests="2272" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<testsuite name="<exe-name>" errors="17" failures="129" skipped="12" tests="2268" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties>
<property name="random-seed" value="1"/>
<property name="filters" value="&quot;*&quot; ~[!nonportable] ~[!benchmark] ~[approvals]"/>
Expand Down
30 changes: 11 additions & 19 deletions tests/SelfTest/Baselines/tap.sw.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -697,33 +697,25 @@ ok {test-number} - lt( "A", "b" ) for: true
# CaseInsensitiveLess is case insensitive
ok {test-number} - lt( "A", "B" ) for: true
# Character pretty printing
ok {test-number} - tab == '\t' for: '\t' == '\t'
ok {test-number} - ::Catch::Detail::stringify('\t') == "'\\t'" for: "'\t'" == "'\t'"
# Character pretty printing
ok {test-number} - newline == '\n' for: '\n' == '\n'
ok {test-number} - ::Catch::Detail::stringify('\n') == "'\\n'" for: "'\n'" == "'\n'"
# Character pretty printing
ok {test-number} - carr_return == '\r' for: '\r' == '\r'
ok {test-number} - ::Catch::Detail::stringify('\r') == "'\\r'" for: "'\r'" == "'\r'"
# Character pretty printing
ok {test-number} - form_feed == '\f' for: '\f' == '\f'
ok {test-number} - ::Catch::Detail::stringify('\f') == "'\\f'" for: "'\f'" == "'\f'"
# Character pretty printing
ok {test-number} - space == ' ' for: ' ' == ' '
ok {test-number} - ::Catch::Detail::stringify( ' ' ) == "' '" for: "' '" == "' '"
# Character pretty printing
ok {test-number} - c == chars[i] for: 'a' == 'a'
ok {test-number} - ::Catch::Detail::stringify( 'A' ) == "'A'" for: "'A'" == "'A'"
# Character pretty printing
ok {test-number} - c == chars[i] for: 'z' == 'z'
ok {test-number} - ::Catch::Detail::stringify( 'z' ) == "'z'" for: "'z'" == "'z'"
# Character pretty printing
ok {test-number} - c == chars[i] for: 'A' == 'A'
ok {test-number} - ::Catch::Detail::stringify( '\0' ) == "0" for: "0" == "0"
# Character pretty printing
ok {test-number} - c == chars[i] for: 'Z' == 'Z'
ok {test-number} - ::Catch::Detail::stringify( static_cast<char>(2) ) == "2" for: "2" == "2"
# Character pretty printing
ok {test-number} - null_terminator == '\0' for: 0 == 0
# Character pretty printing
ok {test-number} - c == i for: 2 == 2
# Character pretty printing
ok {test-number} - c == i for: 3 == 3
# Character pretty printing
ok {test-number} - c == i for: 4 == 4
# Character pretty printing
ok {test-number} - c == i for: 5 == 5
ok {test-number} - ::Catch::Detail::stringify( static_cast<char>(5) ) == "5" for: "5" == "5"
# Clara::Arg supports single-arg parse the way Opt does
ok {test-number} - name.empty() for: true
# Clara::Arg supports single-arg parse the way Opt does
Expand Down Expand Up @@ -4549,5 +4541,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
ok {test-number} -
# xmlentitycheck
ok {test-number} -
1..2272
1..2268

0 comments on commit c3fd4eb

Please sign in to comment.