Skip to content

Commit

Permalink
Add test for multiple streaming parts in UNSCOPED_INFO
Browse files Browse the repository at this point in the history
  • Loading branch information
horenmar committed Sep 17, 2023
1 parent 9267259 commit 9c541ca
Show file tree
Hide file tree
Showing 18 changed files with 139 additions and 18 deletions.
1 change: 1 addition & 0 deletions tests/SelfTest/Baselines/automake.sw.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ Nor would this
:test-result: PASS Hashers with same seed produce same hash
:test-result: PASS Hashing different test cases produces different result
:test-result: PASS Hashing test case produces same hash across multiple calls
:test-result: FAIL INFO and UNSCOPED_INFO can stream multiple arguments
:test-result: FAIL INFO and WARN do not abort tests
:test-result: FAIL INFO gets logged on failure
:test-result: FAIL INFO gets logged on failure, even if captured before successful assertions
Expand Down
1 change: 1 addition & 0 deletions tests/SelfTest/Baselines/automake.sw.multi.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
:test-result: PASS Hashers with same seed produce same hash
:test-result: PASS Hashing different test cases produces different result
:test-result: PASS Hashing test case produces same hash across multiple calls
:test-result: FAIL INFO and UNSCOPED_INFO can stream multiple arguments
:test-result: FAIL INFO and WARN do not abort tests
:test-result: FAIL INFO gets logged on failure
:test-result: FAIL INFO gets logged on failure, even if captured before successful assertions
Expand Down
5 changes: 3 additions & 2 deletions tests/SelfTest/Baselines/compact.sw.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,7 @@ TestCaseInfoHasher.tests.cpp:<line number>: passed: h( dummy1 ) != h( dummy2 ) f
TestCaseInfoHasher.tests.cpp:<line number>: passed: h( dummy ) == h( dummy ) for: 3422778688 (0x<hex digits>)
==
3422778688 (0x<hex digits>)
Message.tests.cpp:<line number>: failed: explicitly with 3 messages: 'This info has multiple parts.' and 'This unscoped info has multiple parts.' and 'Show infos!'
Message.tests.cpp:<line number>: warning: 'this is a message' with 1 message: 'this is a warning'
Message.tests.cpp:<line number>: failed: a == 1 for: 2 == 1 with 2 messages: 'this message should be logged' and 'so should this'
Message.tests.cpp:<line number>: passed: a == 2 for: 2 == 2 with 1 message: 'this message may be logged later'
Expand Down Expand Up @@ -2543,7 +2544,7 @@ InternalBenchmark.tests.cpp:<line number>: passed: med == 18. for: 18.0 == 18.0
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: 412 | 308 passed | 84 failed | 6 skipped | 14 failed as expected
assertions: 2229 | 2049 passed | 145 failed | 35 failed as expected
test cases: 413 | 308 passed | 85 failed | 6 skipped | 14 failed as expected
assertions: 2230 | 2049 passed | 146 failed | 35 failed as expected


5 changes: 3 additions & 2 deletions tests/SelfTest/Baselines/compact.sw.multi.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,7 @@ TestCaseInfoHasher.tests.cpp:<line number>: passed: h( dummy1 ) != h( dummy2 ) f
TestCaseInfoHasher.tests.cpp:<line number>: passed: h( dummy ) == h( dummy ) for: 3422778688 (0x<hex digits>)
==
3422778688 (0x<hex digits>)
Message.tests.cpp:<line number>: failed: explicitly with 3 messages: 'This info has multiple parts.' and 'This unscoped info has multiple parts.' and 'Show infos!'
Message.tests.cpp:<line number>: warning: 'this is a message' with 1 message: 'this is a warning'
Message.tests.cpp:<line number>: failed: a == 1 for: 2 == 1 with 2 messages: 'this message should be logged' and 'so should this'
Message.tests.cpp:<line number>: passed: a == 2 for: 2 == 2 with 1 message: 'this message may be logged later'
Expand Down Expand Up @@ -2532,7 +2533,7 @@ InternalBenchmark.tests.cpp:<line number>: passed: med == 18. for: 18.0 == 18.0
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: 412 | 308 passed | 84 failed | 6 skipped | 14 failed as expected
assertions: 2229 | 2049 passed | 145 failed | 35 failed as expected
test cases: 413 | 308 passed | 85 failed | 6 skipped | 14 failed as expected
assertions: 2230 | 2049 passed | 146 failed | 35 failed as expected


16 changes: 14 additions & 2 deletions tests/SelfTest/Baselines/console.std.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,18 @@ explicitly with message:
Message.tests.cpp:<line number>: warning:
This message appears in the output

-------------------------------------------------------------------------------
INFO and UNSCOPED_INFO can stream multiple arguments
-------------------------------------------------------------------------------
Message.tests.cpp:<line number>
...............................................................................

Message.tests.cpp:<line number>: FAILED:
explicitly with messages:
This info has multiple parts.
This unscoped info has multiple parts.
Show infos!

-------------------------------------------------------------------------------
INFO and WARN do not abort tests
-------------------------------------------------------------------------------
Expand Down Expand Up @@ -1576,6 +1588,6 @@ due to unexpected exception with message:
Why would you throw a std::string?

===============================================================================
test cases: 412 | 322 passed | 69 failed | 7 skipped | 14 failed as expected
assertions: 2212 | 2049 passed | 128 failed | 35 failed as expected
test cases: 413 | 322 passed | 70 failed | 7 skipped | 14 failed as expected
assertions: 2213 | 2049 passed | 129 failed | 35 failed as expected

16 changes: 14 additions & 2 deletions tests/SelfTest/Baselines/console.sw.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6982,6 +6982,18 @@ with expansion:
==
3422778688 (0x<hex digits>)

-------------------------------------------------------------------------------
INFO and UNSCOPED_INFO can stream multiple arguments
-------------------------------------------------------------------------------
Message.tests.cpp:<line number>
...............................................................................

Message.tests.cpp:<line number>: FAILED:
explicitly with messages:
This info has multiple parts.
This unscoped info has multiple parts.
Show infos!

-------------------------------------------------------------------------------
INFO and WARN do not abort tests
-------------------------------------------------------------------------------
Expand Down Expand Up @@ -18271,6 +18283,6 @@ Misc.tests.cpp:<line number>
Misc.tests.cpp:<line number>: PASSED:

===============================================================================
test cases: 412 | 308 passed | 84 failed | 6 skipped | 14 failed as expected
assertions: 2229 | 2049 passed | 145 failed | 35 failed as expected
test cases: 413 | 308 passed | 85 failed | 6 skipped | 14 failed as expected
assertions: 2230 | 2049 passed | 146 failed | 35 failed as expected

16 changes: 14 additions & 2 deletions tests/SelfTest/Baselines/console.sw.multi.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6980,6 +6980,18 @@ with expansion:
==
3422778688 (0x<hex digits>)

-------------------------------------------------------------------------------
INFO and UNSCOPED_INFO can stream multiple arguments
-------------------------------------------------------------------------------
Message.tests.cpp:<line number>
...............................................................................

Message.tests.cpp:<line number>: FAILED:
explicitly with messages:
This info has multiple parts.
This unscoped info has multiple parts.
Show infos!

-------------------------------------------------------------------------------
INFO and WARN do not abort tests
-------------------------------------------------------------------------------
Expand Down Expand Up @@ -18260,6 +18272,6 @@ Misc.tests.cpp:<line number>
Misc.tests.cpp:<line number>: PASSED:

===============================================================================
test cases: 412 | 308 passed | 84 failed | 6 skipped | 14 failed as expected
assertions: 2229 | 2049 passed | 145 failed | 35 failed as expected
test cases: 413 | 308 passed | 85 failed | 6 skipped | 14 failed as expected
assertions: 2230 | 2049 passed | 146 failed | 35 failed as expected

11 changes: 10 additions & 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="128" skipped="12" tests="2241" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<testsuite name="<exe-name>" errors="17" failures="129" skipped="12" tests="2242" 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 Expand Up @@ -752,6 +752,15 @@ at Message.tests.cpp:<line number>
<testcase classname="<exe-name>.global" name="Hashing different test cases produces different result/Different classname" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Hashing different test cases produces different result/Different tags" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Hashing test case produces same hash across multiple calls" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="INFO and UNSCOPED_INFO can stream multiple arguments" time="{duration}" status="run">
<failure type="FAIL">
FAILED:
Show infos!
This info has multiple parts.
This unscoped info has multiple parts.
at Message.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="INFO and WARN do not abort tests" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="INFO gets logged on failure" time="{duration}" status="run">
<failure message="a == 1" type="REQUIRE">
Expand Down
11 changes: 10 additions & 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="128" skipped="12" tests="2241" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<testsuite name="<exe-name>" errors="17" failures="129" skipped="12" tests="2242" 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 Expand Up @@ -751,6 +751,15 @@ at Message.tests.cpp:<line number>
<testcase classname="<exe-name>.global" name="Hashing different test cases produces different result/Different classname" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Hashing different test cases produces different result/Different tags" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Hashing test case produces same hash across multiple calls" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="INFO and UNSCOPED_INFO can stream multiple arguments" time="{duration}" status="run">
<failure type="FAIL">
FAILED:
Show infos!
This info has multiple parts.
This unscoped info has multiple parts.
at Message.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="INFO and WARN do not abort tests" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="INFO gets logged on failure" time="{duration}" status="run">
<failure message="a == 1" type="REQUIRE">
Expand Down
9 changes: 9 additions & 0 deletions tests/SelfTest/Baselines/sonarqube.sw.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1477,6 +1477,15 @@ at Message.tests.cpp:<line number>
<failure message="FAIL_CHECK()">
FAILED:
This is a failure
at Message.tests.cpp:<line number>
</failure>
</testCase>
<testCase name="INFO and UNSCOPED_INFO can stream multiple arguments" duration="{duration}">
<failure message="FAIL()">
FAILED:
Show infos!
This info has multiple parts.
This unscoped info has multiple parts.
at Message.tests.cpp:<line number>
</failure>
</testCase>
Expand Down
9 changes: 9 additions & 0 deletions tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,15 @@ at Message.tests.cpp:<line number>
<failure message="FAIL_CHECK()">
FAILED:
This is a failure
at Message.tests.cpp:<line number>
</failure>
</testCase>
<testCase name="INFO and UNSCOPED_INFO can stream multiple arguments" duration="{duration}">
<failure message="FAIL()">
FAILED:
Show infos!
This info has multiple parts.
This unscoped info has multiple parts.
at Message.tests.cpp:<line number>
</failure>
</testCase>
Expand Down
4 changes: 3 additions & 1 deletion tests/SelfTest/Baselines/tap.sw.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1796,6 +1796,8 @@ ok {test-number} - h( dummy1 ) != h( dummy2 ) for: 2673152918 (0x<hex digits>) !
ok {test-number} - h( dummy1 ) != h( dummy2 ) for: 2074929312 (0x<hex digits>) != 3429949824 (0x<hex digits>)
# Hashing test case produces same hash across multiple calls
ok {test-number} - h( dummy ) == h( dummy ) for: 3422778688 (0x<hex digits>) == 3422778688 (0x<hex digits>)
# INFO and UNSCOPED_INFO can stream multiple arguments
not ok {test-number} - explicitly with 3 messages: 'This info has multiple parts.' and 'This unscoped info has multiple parts.' and 'Show infos!'
# INFO and WARN do not abort tests
warning {test-number} - 'this is a message' with 1 message: 'this is a warning'
# INFO gets logged on failure
Expand Down Expand Up @@ -4487,5 +4489,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
ok {test-number} -
# xmlentitycheck
ok {test-number} -
1..2241
1..2242

4 changes: 3 additions & 1 deletion tests/SelfTest/Baselines/tap.sw.multi.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1794,6 +1794,8 @@ ok {test-number} - h( dummy1 ) != h( dummy2 ) for: 2673152918 (0x<hex digits>) !
ok {test-number} - h( dummy1 ) != h( dummy2 ) for: 2074929312 (0x<hex digits>) != 3429949824 (0x<hex digits>)
# Hashing test case produces same hash across multiple calls
ok {test-number} - h( dummy ) == h( dummy ) for: 3422778688 (0x<hex digits>) == 3422778688 (0x<hex digits>)
# INFO and UNSCOPED_INFO can stream multiple arguments
not ok {test-number} - explicitly with 3 messages: 'This info has multiple parts.' and 'This unscoped info has multiple parts.' and 'Show infos!'
# INFO and WARN do not abort tests
warning {test-number} - 'this is a message' with 1 message: 'this is a warning'
# INFO gets logged on failure
Expand Down Expand Up @@ -4476,5 +4478,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
ok {test-number} -
# xmlentitycheck
ok {test-number} -
1..2241
1..2242

3 changes: 3 additions & 0 deletions tests/SelfTest/Baselines/teamcity.sw.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,9 @@
##teamcity[testFinished name='Hashing different test cases produces different result' duration="{duration}"]
##teamcity[testStarted name='Hashing test case produces same hash across multiple calls']
##teamcity[testFinished name='Hashing test case produces same hash across multiple calls' duration="{duration}"]
##teamcity[testStarted name='INFO and UNSCOPED_INFO can stream multiple arguments']
##teamcity[testFailed name='INFO and UNSCOPED_INFO can stream multiple arguments' message='Message.tests.cpp:<line number>|n...............................................................................|n|nMessage.tests.cpp:<line number>|nexplicit failure with messages:|n "This info has multiple parts."|n "This unscoped info has multiple parts."|n "Show infos!"']
##teamcity[testFinished name='INFO and UNSCOPED_INFO can stream multiple arguments' duration="{duration}"]
##teamcity[testStarted name='INFO and WARN do not abort tests']
##teamcity[testFinished name='INFO and WARN do not abort tests' duration="{duration}"]
##teamcity[testStarted name='INFO gets logged on failure']
Expand Down
3 changes: 3 additions & 0 deletions tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,9 @@
##teamcity[testFinished name='Hashing different test cases produces different result' duration="{duration}"]
##teamcity[testStarted name='Hashing test case produces same hash across multiple calls']
##teamcity[testFinished name='Hashing test case produces same hash across multiple calls' duration="{duration}"]
##teamcity[testStarted name='INFO and UNSCOPED_INFO can stream multiple arguments']
##teamcity[testFailed name='INFO and UNSCOPED_INFO can stream multiple arguments' message='Message.tests.cpp:<line number>|n...............................................................................|n|nMessage.tests.cpp:<line number>|nexplicit failure with messages:|n "This info has multiple parts."|n "This unscoped info has multiple parts."|n "Show infos!"']
##teamcity[testFinished name='INFO and UNSCOPED_INFO can stream multiple arguments' duration="{duration}"]
##teamcity[testStarted name='INFO and WARN do not abort tests']
##teamcity[testFinished name='INFO and WARN do not abort tests' duration="{duration}"]
##teamcity[testStarted name='INFO gets logged on failure']
Expand Down
16 changes: 14 additions & 2 deletions tests/SelfTest/Baselines/xml.sw.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8371,6 +8371,18 @@ C
</Expression>
<OverallResult success="true" skips="0"/>
</TestCase>
<TestCase name="INFO and UNSCOPED_INFO can stream multiple arguments" tags="[.][failing][info][messages]" filename="tests/<exe-name>/UsageTests/Message.tests.cpp" >
<Info filename="tests/<exe-name>/UsageTests/Message.tests.cpp" >
This info has multiple parts.
</Info>
<Info filename="tests/<exe-name>/UsageTests/Message.tests.cpp" >
This unscoped info has multiple parts.
</Info>
<Failure filename="tests/<exe-name>/UsageTests/Message.tests.cpp" >
Show infos!
</Failure>
<OverallResult success="false" skips="0"/>
</TestCase>
<TestCase name="INFO and WARN do not abort tests" tags="[.][messages]" filename="tests/<exe-name>/UsageTests/Message.tests.cpp" >
<Info filename="tests/<exe-name>/UsageTests/Message.tests.cpp" >
this is a message
Expand Down Expand Up @@ -21256,6 +21268,6 @@ b1!
</Section>
<OverallResult success="true" skips="0"/>
</TestCase>
<OverallResults successes="2049" failures="145" expectedFailures="35" skips="12"/>
<OverallResultsCases successes="308" failures="84" expectedFailures="14" skips="6"/>
<OverallResults successes="2049" failures="146" expectedFailures="35" skips="12"/>
<OverallResultsCases successes="308" failures="85" expectedFailures="14" skips="6"/>
</Catch2TestRun>
16 changes: 14 additions & 2 deletions tests/SelfTest/Baselines/xml.sw.multi.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8371,6 +8371,18 @@ C
</Expression>
<OverallResult success="true" skips="0"/>
</TestCase>
<TestCase name="INFO and UNSCOPED_INFO can stream multiple arguments" tags="[.][failing][info][messages]" filename="tests/<exe-name>/UsageTests/Message.tests.cpp" >
<Info filename="tests/<exe-name>/UsageTests/Message.tests.cpp" >
This info has multiple parts.
</Info>
<Info filename="tests/<exe-name>/UsageTests/Message.tests.cpp" >
This unscoped info has multiple parts.
</Info>
<Failure filename="tests/<exe-name>/UsageTests/Message.tests.cpp" >
Show infos!
</Failure>
<OverallResult success="false" skips="0"/>
</TestCase>
<TestCase name="INFO and WARN do not abort tests" tags="[.][messages]" filename="tests/<exe-name>/UsageTests/Message.tests.cpp" >
<Info filename="tests/<exe-name>/UsageTests/Message.tests.cpp" >
this is a message
Expand Down Expand Up @@ -21255,6 +21267,6 @@ b1!
</Section>
<OverallResult success="true" skips="0"/>
</TestCase>
<OverallResults successes="2049" failures="145" expectedFailures="35" skips="12"/>
<OverallResultsCases successes="308" failures="84" expectedFailures="14" skips="6"/>
<OverallResults successes="2049" failures="146" expectedFailures="35" skips="12"/>
<OverallResultsCases successes="308" failures="85" expectedFailures="14" skips="6"/>
</Catch2TestRun>
11 changes: 11 additions & 0 deletions tests/SelfTest/UsageTests/Message.tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,14 @@ TEST_CASE("CAPTURE parses string and character constants", "[messages][capture]"
#ifdef _MSC_VER
#pragma warning(pop)
#endif

TEST_CASE( "INFO and UNSCOPED_INFO can stream multiple arguments",
"[messages][info][.failing]" ) {
INFO( "This info"
<< " has multiple"
<< " parts." );
UNSCOPED_INFO( "This unscoped info"
<< " has multiple"
<< " parts." );
FAIL( "Show infos!" );
}

0 comments on commit 9c541ca

Please sign in to comment.