Skip to content

Commit 7fad629

Browse files
committed
Also test CHECK_NOTHROW and expand docs for SKIP
1 parent 2d51076 commit 7fad629

19 files changed

Lines changed: 194 additions & 18 deletions

docs/skipping-passing-failing.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,20 @@ TEST_CASE("failing test") {
5252
}
5353
```
5454

55+
Same applies for a `SKIP` nested inside an assertion:
56+
57+
```cpp
58+
static bool do_skip() {
59+
SKIP();
60+
return true;
61+
}
62+
63+
TEST_CASE("Another failing test") {
64+
CHECK(do_skip());
65+
}
66+
```
67+
68+
5569
### Interaction with Sections and Generators
5670

5771
Sections, nested sections as well as specific outputs from [generators](generators.md#top)

tests/SelfTest/Baselines/automake.sw.approved.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ Nor would this
155155
:test-result: PASS Exceptions matchers
156156
:test-result: FAIL Expected exceptions that don't throw or unexpected exceptions fail the test
157157
:test-result: FAIL FAIL aborts the test
158+
:test-result: XFAIL FAIL can be nested in assertion
158159
:test-result: FAIL FAIL does not require an argument
159160
:test-result: FAIL FAIL_CHECK does not abort the test
160161
:test-result: PASS Factorials are computed

tests/SelfTest/Baselines/automake.sw.multi.approved.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@
153153
:test-result: PASS Exceptions matchers
154154
:test-result: FAIL Expected exceptions that don't throw or unexpected exceptions fail the test
155155
:test-result: FAIL FAIL aborts the test
156+
:test-result: XFAIL FAIL can be nested in assertion
156157
:test-result: FAIL FAIL does not require an argument
157158
:test-result: FAIL FAIL_CHECK does not abort the test
158159
:test-result: PASS Factorials are computed

tests/SelfTest/Baselines/compact.sw.approved.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,8 @@ Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'e
641641
Exception.tests.cpp:<line number>: failed: expected exception, got none; expression was: thisDoesntThrow(), std::domain_error
642642
Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'expected exception'; expression was: thisThrows()
643643
Message.tests.cpp:<line number>: failed: explicitly with 1 message: 'This is a failure'
644+
AssertionHandler.tests.cpp:<line number>: failed: explicitly with 1 message: 'Throw a Catch::TestFailureException'
645+
AssertionHandler.tests.cpp:<line number>: failed: unexpected exception with message: '{ nested assertion failed }'; expression was: fn()
644646
Message.tests.cpp:<line number>: failed: explicitly
645647
Message.tests.cpp:<line number>: failed: explicitly with 1 message: 'This is a failure'
646648
Message.tests.cpp:<line number>: warning: 'This message appears in the output'
@@ -2867,7 +2869,7 @@ InternalBenchmark.tests.cpp:<line number>: passed: med == 18. for: 18.0 == 18.0
28672869
InternalBenchmark.tests.cpp:<line number>: passed: q3 == 23. for: 23.0 == 23.0
28682870
Misc.tests.cpp:<line number>: passed:
28692871
Misc.tests.cpp:<line number>: passed:
2870-
test cases: 430 | 313 passed | 95 failed | 6 skipped | 16 failed as expected
2871-
assertions: 2286 | 2090 passed | 157 failed | 39 failed as expected
2872+
test cases: 431 | 313 passed | 95 failed | 6 skipped | 17 failed as expected
2873+
assertions: 2288 | 2090 passed | 157 failed | 41 failed as expected
28722874

28732875

tests/SelfTest/Baselines/compact.sw.multi.approved.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,8 @@ Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'e
639639
Exception.tests.cpp:<line number>: failed: expected exception, got none; expression was: thisDoesntThrow(), std::domain_error
640640
Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'expected exception'; expression was: thisThrows()
641641
Message.tests.cpp:<line number>: failed: explicitly with 1 message: 'This is a failure'
642+
AssertionHandler.tests.cpp:<line number>: failed: explicitly with 1 message: 'Throw a Catch::TestFailureException'
643+
AssertionHandler.tests.cpp:<line number>: failed: unexpected exception with message: '{ nested assertion failed }'; expression was: fn()
642644
Message.tests.cpp:<line number>: failed: explicitly
643645
Message.tests.cpp:<line number>: failed: explicitly with 1 message: 'This is a failure'
644646
Message.tests.cpp:<line number>: warning: 'This message appears in the output'
@@ -2856,7 +2858,7 @@ InternalBenchmark.tests.cpp:<line number>: passed: med == 18. for: 18.0 == 18.0
28562858
InternalBenchmark.tests.cpp:<line number>: passed: q3 == 23. for: 23.0 == 23.0
28572859
Misc.tests.cpp:<line number>: passed:
28582860
Misc.tests.cpp:<line number>: passed:
2859-
test cases: 430 | 313 passed | 95 failed | 6 skipped | 16 failed as expected
2860-
assertions: 2286 | 2090 passed | 157 failed | 39 failed as expected
2861+
test cases: 431 | 313 passed | 95 failed | 6 skipped | 17 failed as expected
2862+
assertions: 2288 | 2090 passed | 157 failed | 41 failed as expected
28612863

28622864

tests/SelfTest/Baselines/console.std.approved.txt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,21 @@ Message.tests.cpp:<line number>: FAILED:
651651
explicitly with message:
652652
This is a failure
653653

654+
-------------------------------------------------------------------------------
655+
FAIL can be nested in assertion
656+
-------------------------------------------------------------------------------
657+
AssertionHandler.tests.cpp:<line number>
658+
...............................................................................
659+
660+
AssertionHandler.tests.cpp:<line number>: FAILED:
661+
explicitly with message:
662+
Throw a Catch::TestFailureException
663+
664+
AssertionHandler.tests.cpp:<line number>: FAILED:
665+
CHECK_NOTHROW( fn() )
666+
due to unexpected exception with message:
667+
{ nested assertion failed }
668+
654669
-------------------------------------------------------------------------------
655670
FAIL does not require an argument
656671
-------------------------------------------------------------------------------
@@ -1704,6 +1719,6 @@ due to unexpected exception with message:
17041719
Why would you throw a std::string?
17051720

17061721
===============================================================================
1707-
test cases: 430 | 331 passed | 76 failed | 7 skipped | 16 failed as expected
1708-
assertions: 2265 | 2090 passed | 136 failed | 39 failed as expected
1722+
test cases: 431 | 331 passed | 76 failed | 7 skipped | 17 failed as expected
1723+
assertions: 2267 | 2090 passed | 136 failed | 41 failed as expected
17091724

tests/SelfTest/Baselines/console.sw.approved.txt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4596,6 +4596,21 @@ Message.tests.cpp:<line number>: FAILED:
45964596
explicitly with message:
45974597
This is a failure
45984598

4599+
-------------------------------------------------------------------------------
4600+
FAIL can be nested in assertion
4601+
-------------------------------------------------------------------------------
4602+
AssertionHandler.tests.cpp:<line number>
4603+
...............................................................................
4604+
4605+
AssertionHandler.tests.cpp:<line number>: FAILED:
4606+
explicitly with message:
4607+
Throw a Catch::TestFailureException
4608+
4609+
AssertionHandler.tests.cpp:<line number>: FAILED:
4610+
CHECK_NOTHROW( fn() )
4611+
due to unexpected exception with message:
4612+
{ nested assertion failed }
4613+
45994614
-------------------------------------------------------------------------------
46004615
FAIL does not require an argument
46014616
-------------------------------------------------------------------------------
@@ -19169,6 +19184,6 @@ Misc.tests.cpp:<line number>
1916919184
Misc.tests.cpp:<line number>: PASSED:
1917019185

1917119186
===============================================================================
19172-
test cases: 430 | 313 passed | 95 failed | 6 skipped | 16 failed as expected
19173-
assertions: 2286 | 2090 passed | 157 failed | 39 failed as expected
19187+
test cases: 431 | 313 passed | 95 failed | 6 skipped | 17 failed as expected
19188+
assertions: 2288 | 2090 passed | 157 failed | 41 failed as expected
1917419189

tests/SelfTest/Baselines/console.sw.multi.approved.txt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4594,6 +4594,21 @@ Message.tests.cpp:<line number>: FAILED:
45944594
explicitly with message:
45954595
This is a failure
45964596

4597+
-------------------------------------------------------------------------------
4598+
FAIL can be nested in assertion
4599+
-------------------------------------------------------------------------------
4600+
AssertionHandler.tests.cpp:<line number>
4601+
...............................................................................
4602+
4603+
AssertionHandler.tests.cpp:<line number>: FAILED:
4604+
explicitly with message:
4605+
Throw a Catch::TestFailureException
4606+
4607+
AssertionHandler.tests.cpp:<line number>: FAILED:
4608+
CHECK_NOTHROW( fn() )
4609+
due to unexpected exception with message:
4610+
{ nested assertion failed }
4611+
45974612
-------------------------------------------------------------------------------
45984613
FAIL does not require an argument
45994614
-------------------------------------------------------------------------------
@@ -19158,6 +19173,6 @@ Misc.tests.cpp:<line number>
1915819173
Misc.tests.cpp:<line number>: PASSED:
1915919174

1916019175
===============================================================================
19161-
test cases: 430 | 313 passed | 95 failed | 6 skipped | 16 failed as expected
19162-
assertions: 2286 | 2090 passed | 157 failed | 39 failed as expected
19176+
test cases: 431 | 313 passed | 95 failed | 6 skipped | 17 failed as expected
19177+
assertions: 2288 | 2090 passed | 157 failed | 41 failed as expected
1916319178

tests/SelfTest/Baselines/junit.sw.approved.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<testsuitesloose text artifact
33
>
4-
<testsuite name="<exe-name>" errors="17" failures="140" skipped="12" tests="2298" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
4+
<testsuite name="<exe-name>" errors="17" failures="140" skipped="12" tests="2300" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
55
<properties>
66
<property name="random-seed" value="1"/>
77
<property name="filters" value="&quot;*&quot; ~[!nonportable] ~[!benchmark] ~[approvals]"/>
@@ -770,6 +770,20 @@ This is a failure
770770
at Message.tests.cpp:<line number>
771771
</failure>
772772
</testcase>
773+
<testcase classname="<exe-name>.global" name="FAIL can be nested in assertion" time="{duration}" status="run">
774+
<skipped message="TEST_CASE tagged with !mayfail"/>
775+
<failure type="FAIL">
776+
FAILED:
777+
Throw a Catch::TestFailureException
778+
at AssertionHandler.tests.cpp:<line number>
779+
</failure>
780+
<error message="fn()" type="CHECK_NOTHROW">
781+
FAILED:
782+
CHECK_NOTHROW( fn() )
783+
{ nested assertion failed }
784+
at AssertionHandler.tests.cpp:<line number>
785+
</error>
786+
</testcase>
773787
<testcase classname="<exe-name>.global" name="FAIL does not require an argument" time="{duration}" status="run">
774788
<failure type="FAIL">
775789
FAILED:

tests/SelfTest/Baselines/junit.sw.multi.approved.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<testsuites>
3-
<testsuite name="<exe-name>" errors="17" failures="140" skipped="12" tests="2298" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
3+
<testsuite name="<exe-name>" errors="17" failures="140" skipped="12" tests="2300" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
44
<properties>
55
<property name="random-seed" value="1"/>
66
<property name="filters" value="&quot;*&quot; ~[!nonportable] ~[!benchmark] ~[approvals]"/>
@@ -769,6 +769,20 @@ This is a failure
769769
at Message.tests.cpp:<line number>
770770
</failure>
771771
</testcase>
772+
<testcase classname="<exe-name>.global" name="FAIL can be nested in assertion" time="{duration}" status="run">
773+
<skipped message="TEST_CASE tagged with !mayfail"/>
774+
<failure type="FAIL">
775+
FAILED:
776+
Throw a Catch::TestFailureException
777+
at AssertionHandler.tests.cpp:<line number>
778+
</failure>
779+
<error message="fn()" type="CHECK_NOTHROW">
780+
FAILED:
781+
CHECK_NOTHROW( fn() )
782+
{ nested assertion failed }
783+
at AssertionHandler.tests.cpp:<line number>
784+
</error>
785+
</testcase>
772786
<testcase classname="<exe-name>.global" name="FAIL does not require an argument" time="{duration}" status="run">
773787
<failure type="FAIL">
774788
FAILED:

0 commit comments

Comments
 (0)