Suppress failure of CHECKED_IF and CHECKED_ELSE (#2187)

Resolves #1390

Co-authored-by: Martin Hořeňovský <martin.horenovsky@gmail.com>
This commit is contained in:
Jozef Grajciar 2021-05-10 21:42:47 +02:00 committed by GitHub
parent 313071e8fe
commit eb911aa995
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 246 additions and 71 deletions

View File

@ -19,14 +19,6 @@ command line interface instead of parsing C++ code with regular expressions.
## Planned changes ## Planned changes
### `CHECKED_IF` and `CHECKED_ELSE`
To make the `CHECKED_IF` and `CHECKED_ELSE` macros more useful, they will
be marked as "OK to fail" (`Catch::ResultDisposition::SuppressFail` flag
will be added), which means that their failure will not fail the test,
making the `else` actually useful.
### Console Colour API ### Console Colour API
The API for Catch2's console colour will be changed to take an extra The API for Catch2's console colour will be changed to take an extra

View File

@ -15,6 +15,8 @@ stringification machinery to the _expr_ and records the result. As with
evaluates to `true`. `CHECKED_ELSE( expr )` work similarly, but the block evaluates to `true`. `CHECKED_ELSE( expr )` work similarly, but the block
is entered only if the _expr_ evaluated to `false`. is entered only if the _expr_ evaluated to `false`.
> `CHECKED_X` macros were changed to not count as failure in Catch2 X.Y.Z.
Example: Example:
```cpp ```cpp
int a = ...; int a = ...;

View File

@ -32,8 +32,8 @@
#define CATCH_CHECK( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) #define CATCH_CHECK( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
#define CATCH_CHECK_FALSE( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) #define CATCH_CHECK_FALSE( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, __VA_ARGS__ )
#define CATCH_CHECKED_IF( ... ) INTERNAL_CATCH_IF( "CATCH_CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) #define CATCH_CHECKED_IF( ... ) INTERNAL_CATCH_IF( "CATCH_CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ )
#define CATCH_CHECKED_ELSE( ... ) INTERNAL_CATCH_ELSE( "CATCH_CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) #define CATCH_CHECKED_ELSE( ... ) INTERNAL_CATCH_ELSE( "CATCH_CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ )
#define CATCH_CHECK_NOFAIL( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ ) #define CATCH_CHECK_NOFAIL( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ )
#define CATCH_CHECK_THROWS( ... ) INTERNAL_CATCH_THROWS( "CATCH_CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) #define CATCH_CHECK_THROWS( ... ) INTERNAL_CATCH_THROWS( "CATCH_CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
@ -123,8 +123,8 @@
#define CHECK( ... ) INTERNAL_CATCH_TEST( "CHECK", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) #define CHECK( ... ) INTERNAL_CATCH_TEST( "CHECK", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
#define CHECK_FALSE( ... ) INTERNAL_CATCH_TEST( "CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) #define CHECK_FALSE( ... ) INTERNAL_CATCH_TEST( "CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, __VA_ARGS__ )
#define CHECKED_IF( ... ) INTERNAL_CATCH_IF( "CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) #define CHECKED_IF( ... ) INTERNAL_CATCH_IF( "CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ )
#define CHECKED_ELSE( ... ) INTERNAL_CATCH_ELSE( "CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) #define CHECKED_ELSE( ... ) INTERNAL_CATCH_ELSE( "CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ )
#define CHECK_NOFAIL( ... ) INTERNAL_CATCH_TEST( "CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ ) #define CHECK_NOFAIL( ... ) INTERNAL_CATCH_TEST( "CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ )
#define CHECK_THROWS( ... ) INTERNAL_CATCH_THROWS( "CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) #define CHECK_THROWS( ... ) INTERNAL_CATCH_THROWS( "CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )

View File

@ -230,9 +230,11 @@ namespace Catch {
if (result.getResultType() == ResultWas::Ok) { if (result.getResultType() == ResultWas::Ok) {
m_totals.assertions.passed++; m_totals.assertions.passed++;
m_lastAssertionPassed = true; m_lastAssertionPassed = true;
} else if (!result.isOk()) { } else if (!result.succeeded()) {
m_lastAssertionPassed = false; m_lastAssertionPassed = false;
if( m_activeTestCase->getTestCaseInfo().okToFail() ) if (result.isOk()) {
}
else if( m_activeTestCase->getTestCaseInfo().okToFail() )
m_totals.assertions.failedButOk++; m_totals.assertions.failedButOk++;
else else
m_totals.assertions.failed++; m_totals.assertions.failed++;

View File

@ -231,6 +231,9 @@ Message from section two
:test-result: PASS Test case with one argument :test-result: PASS Test case with one argument
:test-result: PASS Test enum bit values :test-result: PASS Test enum bit values
:test-result: PASS Test with special, characters "in name :test-result: PASS Test with special, characters "in name
:test-result: PASS Testing checked-if
:test-result: XFAIL Testing checked-if 2
:test-result: XFAIL Testing checked-if 3
:test-result: FAIL The NO_FAIL macro reports a failure but does not fail the test :test-result: FAIL The NO_FAIL macro reports a failure but does not fail the test
:test-result: PASS The default listing implementation write to provided stream :test-result: PASS The default listing implementation write to provided stream
:test-result: FAIL This test 'should' fail but doesn't :test-result: FAIL This test 'should' fail but doesn't

View File

@ -1714,6 +1714,16 @@ Misc.tests.cpp:<line number>: passed: v.capacity() >= V for: 15 >= 15
VariadicMacros.tests.cpp:<line number>: passed: with 1 message: 'no assertions' VariadicMacros.tests.cpp:<line number>: passed: with 1 message: 'no assertions'
Tricky.tests.cpp:<line number>: passed: 0x<hex digits> == bit30and31 for: 3221225472 (0x<hex digits>) == 3221225472 Tricky.tests.cpp:<line number>: passed: 0x<hex digits> == bit30and31 for: 3221225472 (0x<hex digits>) == 3221225472
CmdLine.tests.cpp:<line number>: passed: CmdLine.tests.cpp:<line number>: passed:
Misc.tests.cpp:<line number>: passed: true
Misc.tests.cpp:<line number>: passed:
Misc.tests.cpp:<line number>: failed - but was ok: false
Misc.tests.cpp:<line number>: passed: true
Misc.tests.cpp:<line number>: failed - but was ok: false
Misc.tests.cpp:<line number>: passed:
Misc.tests.cpp:<line number>: passed: true
Misc.tests.cpp:<line number>: failed: explicitly
Misc.tests.cpp:<line number>: failed - but was ok: false
Misc.tests.cpp:<line number>: failed: explicitly
Message.tests.cpp:<line number>: failed - but was ok: 1 == 2 Message.tests.cpp:<line number>: failed - but was ok: 1 == 2
Reporters.tests.cpp:<line number>: passed: listingString, Contains("[fakeTag]"s) for: "All available tags: Reporters.tests.cpp:<line number>: passed: listingString, Contains("[fakeTag]"s) for: "All available tags:
1 [fakeTag] 1 [fakeTag]
@ -1996,11 +2006,11 @@ InternalBenchmark.tests.cpp:<line number>: passed: called == 1 for: 1 == 1
Tricky.tests.cpp:<line number>: passed: obj.prop != 0 for: 0x<hex digits> != 0 Tricky.tests.cpp:<line number>: passed: obj.prop != 0 for: 0x<hex digits> != 0
Misc.tests.cpp:<line number>: passed: flag for: true Misc.tests.cpp:<line number>: passed: flag for: true
Misc.tests.cpp:<line number>: passed: testCheckedElse( true ) for: true Misc.tests.cpp:<line number>: passed: testCheckedElse( true ) for: true
Misc.tests.cpp:<line number>: failed: flag for: false Misc.tests.cpp:<line number>: failed - but was ok: flag for: false
Misc.tests.cpp:<line number>: failed: testCheckedElse( false ) for: false Misc.tests.cpp:<line number>: failed: testCheckedElse( false ) for: false
Misc.tests.cpp:<line number>: passed: flag for: true Misc.tests.cpp:<line number>: passed: flag for: true
Misc.tests.cpp:<line number>: passed: testCheckedIf( true ) for: true Misc.tests.cpp:<line number>: passed: testCheckedIf( true ) for: true
Misc.tests.cpp:<line number>: failed: flag for: false Misc.tests.cpp:<line number>: failed - but was ok: flag for: false
Misc.tests.cpp:<line number>: failed: testCheckedIf( false ) for: false Misc.tests.cpp:<line number>: failed: testCheckedIf( false ) for: false
InternalBenchmark.tests.cpp:<line number>: passed: o.samples_seen == static_cast<int>(x.size()) for: 6 == 6 InternalBenchmark.tests.cpp:<line number>: passed: o.samples_seen == static_cast<int>(x.size()) for: 6 == 6
InternalBenchmark.tests.cpp:<line number>: passed: o.low_severe == los for: 0 == 0 InternalBenchmark.tests.cpp:<line number>: passed: o.low_severe == los for: 0 == 0
@ -2342,5 +2352,5 @@ 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 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:
Misc.tests.cpp:<line number>: passed: Misc.tests.cpp:<line number>: passed:
Failed 86 test cases, failed 148 assertions. Failed 86 test cases, failed 146 assertions.

View File

@ -922,6 +922,22 @@ with expansion:
} }
" "
-------------------------------------------------------------------------------
Testing checked-if 2
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
Misc.tests.cpp:<line number>: FAILED:
-------------------------------------------------------------------------------
Testing checked-if 3
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
Misc.tests.cpp:<line number>: FAILED:
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Thrown string literals are translated Thrown string literals are translated
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@ -1135,11 +1151,6 @@ checkedElse, failing
Misc.tests.cpp:<line number> Misc.tests.cpp:<line number>
............................................................................... ...............................................................................
Misc.tests.cpp:<line number>: FAILED:
CHECKED_ELSE( flag )
with expansion:
false
Misc.tests.cpp:<line number>: FAILED: Misc.tests.cpp:<line number>: FAILED:
REQUIRE( testCheckedElse( false ) ) REQUIRE( testCheckedElse( false ) )
with expansion: with expansion:
@ -1151,11 +1162,6 @@ checkedIf, failing
Misc.tests.cpp:<line number> Misc.tests.cpp:<line number>
............................................................................... ...............................................................................
Misc.tests.cpp:<line number>: FAILED:
CHECKED_IF( flag )
with expansion:
false
Misc.tests.cpp:<line number>: FAILED: Misc.tests.cpp:<line number>: FAILED:
REQUIRE( testCheckedIf( false ) ) REQUIRE( testCheckedIf( false ) )
with expansion: with expansion:
@ -1380,6 +1386,6 @@ due to unexpected exception with message:
Why would you throw a std::string? Why would you throw a std::string?
=============================================================================== ===============================================================================
test cases: 356 | 282 passed | 70 failed | 4 failed as expected test cases: 359 | 283 passed | 70 failed | 6 failed as expected
assertions: 2077 | 1925 passed | 131 failed | 21 failed as expected assertions: 2082 | 1930 passed | 129 failed | 23 failed as expected

View File

@ -12298,6 +12298,50 @@ CmdLine.tests.cpp:<line number>
CmdLine.tests.cpp:<line number>: PASSED: CmdLine.tests.cpp:<line number>: PASSED:
-------------------------------------------------------------------------------
Testing checked-if
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
Misc.tests.cpp:<line number>: PASSED:
CHECKED_IF( true )
Misc.tests.cpp:<line number>: PASSED:
Misc.tests.cpp:<line number>: FAILED - but was ok:
CHECKED_IF( false )
Misc.tests.cpp:<line number>: PASSED:
CHECKED_ELSE( true )
Misc.tests.cpp:<line number>: FAILED - but was ok:
CHECKED_ELSE( false )
Misc.tests.cpp:<line number>: PASSED:
-------------------------------------------------------------------------------
Testing checked-if 2
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
Misc.tests.cpp:<line number>: PASSED:
CHECKED_IF( true )
Misc.tests.cpp:<line number>: FAILED:
-------------------------------------------------------------------------------
Testing checked-if 3
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
Misc.tests.cpp:<line number>: FAILED - but was ok:
CHECKED_ELSE( false )
Misc.tests.cpp:<line number>: FAILED:
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
The NO_FAIL macro reports a failure but does not fail the test The NO_FAIL macro reports a failure but does not fail the test
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@ -14176,7 +14220,7 @@ checkedElse, failing
Misc.tests.cpp:<line number> Misc.tests.cpp:<line number>
............................................................................... ...............................................................................
Misc.tests.cpp:<line number>: FAILED: Misc.tests.cpp:<line number>: FAILED - but was ok:
CHECKED_ELSE( flag ) CHECKED_ELSE( flag )
with expansion: with expansion:
false false
@ -14208,7 +14252,7 @@ checkedIf, failing
Misc.tests.cpp:<line number> Misc.tests.cpp:<line number>
............................................................................... ...............................................................................
Misc.tests.cpp:<line number>: FAILED: Misc.tests.cpp:<line number>: FAILED - but was ok:
CHECKED_IF( flag ) CHECKED_IF( flag )
with expansion: with expansion:
false false
@ -16722,6 +16766,6 @@ Misc.tests.cpp:<line number>
Misc.tests.cpp:<line number>: PASSED: Misc.tests.cpp:<line number>: PASSED:
=============================================================================== ===============================================================================
test cases: 356 | 266 passed | 86 failed | 4 failed as expected test cases: 359 | 267 passed | 86 failed | 6 failed as expected
assertions: 2094 | 1925 passed | 148 failed | 21 failed as expected assertions: 2099 | 1930 passed | 146 failed | 23 failed as expected

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<testsuitesloose text artifact <testsuitesloose text artifact
> >
<testsuite name="<exe-name>" errors="17" failures="132" tests="2095" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> <testsuite name="<exe-name>" errors="17" failures="130" tests="2100" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties> <properties>
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/> <property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/>
<property name="random-seed" value="1"/> <property name="random-seed" value="1"/>
@ -1276,6 +1276,19 @@ Misc.tests.cpp:<line number>
<testcase classname="<exe-name>.global" name="Test case with one argument" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Test case with one argument" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Test enum bit values" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Test enum bit values" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Test with special, characters &quot;in name" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Test with special, characters &quot;in name" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Testing checked-if" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Testing checked-if 2" time="{duration}" status="run">
<failure type="FAIL">
FAILED:
Misc.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Testing checked-if 3" time="{duration}" status="run">
<failure type="FAIL">
FAILED:
Misc.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="The NO_FAIL macro reports a failure but does not fail the test" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="The NO_FAIL macro reports a failure but does not fail the test" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="The default listing implementation write to provided stream/Listing tags" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="The default listing implementation write to provided stream/Listing tags" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="The default listing implementation write to provided stream/Listing reporters" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="The default listing implementation write to provided stream/Listing reporters" time="{duration}" status="run"/>
@ -1505,13 +1518,6 @@ Exception.tests.cpp:<line number>
<testcase classname="<exe-name>.global" name="boolean member" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="boolean member" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="checkedElse" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="checkedElse" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="checkedElse, failing" time="{duration}" status="run"> <testcase classname="<exe-name>.global" name="checkedElse, failing" time="{duration}" status="run">
<failure message="flag" type="CHECKED_ELSE">
FAILED:
CHECKED_ELSE( flag )
with expansion:
false
Misc.tests.cpp:<line number>
</failure>
<failure message="testCheckedElse( false )" type="REQUIRE"> <failure message="testCheckedElse( false )" type="REQUIRE">
FAILED: FAILED:
REQUIRE( testCheckedElse( false ) ) REQUIRE( testCheckedElse( false ) )
@ -1522,13 +1528,6 @@ Misc.tests.cpp:<line number>
</testcase> </testcase>
<testcase classname="<exe-name>.global" name="checkedIf" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="checkedIf" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="checkedIf, failing" time="{duration}" status="run"> <testcase classname="<exe-name>.global" name="checkedIf, failing" time="{duration}" status="run">
<failure message="flag" type="CHECKED_IF">
FAILED:
CHECKED_IF( flag )
with expansion:
false
Misc.tests.cpp:<line number>
</failure>
<failure message="testCheckedIf( false )" type="REQUIRE"> <failure message="testCheckedIf( false )" type="REQUIRE">
FAILED: FAILED:
REQUIRE( testCheckedIf( false ) ) REQUIRE( testCheckedIf( false ) )

View File

@ -1583,17 +1583,23 @@ Misc.tests.cpp:<line number>
<testCase name="TemplateTestSig: vectors can be sized and resized - std::string,15/resizing smaller changes size but not capacity/We can use the 'swap trick' to reset the capacity" duration="{duration}"/> <testCase name="TemplateTestSig: vectors can be sized and resized - std::string,15/resizing smaller changes size but not capacity/We can use the 'swap trick' to reset the capacity" duration="{duration}"/>
<testCase name="TemplateTestSig: vectors can be sized and resized - std::string,15/reserving bigger changes capacity but not size" duration="{duration}"/> <testCase name="TemplateTestSig: vectors can be sized and resized - std::string,15/reserving bigger changes capacity but not size" duration="{duration}"/>
<testCase name="TemplateTestSig: vectors can be sized and resized - std::string,15/reserving smaller does not change size or capacity" duration="{duration}"/> <testCase name="TemplateTestSig: vectors can be sized and resized - std::string,15/reserving smaller does not change size or capacity" duration="{duration}"/>
<testCase name="Testing checked-if" duration="{duration}"/>
<testCase name="Testing checked-if 2" duration="{duration}">
<skipped message="FAIL()">
FAILED:
Misc.tests.cpp:<line number>
</skipped>
</testCase>
<testCase name="Testing checked-if 3" duration="{duration}">
<skipped message="FAIL()">
FAILED:
Misc.tests.cpp:<line number>
</skipped>
</testCase>
<testCase name="This test 'should' fail but doesn't" duration="{duration}"/> <testCase name="This test 'should' fail but doesn't" duration="{duration}"/>
<testCase name="atomic if" duration="{duration}"/> <testCase name="atomic if" duration="{duration}"/>
<testCase name="checkedElse" duration="{duration}"/> <testCase name="checkedElse" duration="{duration}"/>
<testCase name="checkedElse, failing" duration="{duration}"> <testCase name="checkedElse, failing" duration="{duration}">
<failure message="CHECKED_ELSE(flag)">
FAILED:
CHECKED_ELSE( flag )
with expansion:
false
Misc.tests.cpp:<line number>
</failure>
<failure message="REQUIRE(testCheckedElse( false ))"> <failure message="REQUIRE(testCheckedElse( false ))">
FAILED: FAILED:
REQUIRE( testCheckedElse( false ) ) REQUIRE( testCheckedElse( false ) )
@ -1604,13 +1610,6 @@ Misc.tests.cpp:<line number>
</testCase> </testCase>
<testCase name="checkedIf" duration="{duration}"/> <testCase name="checkedIf" duration="{duration}"/>
<testCase name="checkedIf, failing" duration="{duration}"> <testCase name="checkedIf, failing" duration="{duration}">
<failure message="CHECKED_IF(flag)">
FAILED:
CHECKED_IF( flag )
with expansion:
false
Misc.tests.cpp:<line number>
</failure>
<failure message="REQUIRE(testCheckedIf( false ))"> <failure message="REQUIRE(testCheckedIf( false ))">
FAILED: FAILED:
REQUIRE( testCheckedIf( false ) ) REQUIRE( testCheckedIf( false ) )

View File

@ -3073,6 +3073,26 @@ ok {test-number} - with 1 message: 'no assertions'
ok {test-number} - 0x<hex digits> == bit30and31 for: 3221225472 (0x<hex digits>) == 3221225472 ok {test-number} - 0x<hex digits> == bit30and31 for: 3221225472 (0x<hex digits>) == 3221225472
# Test with special, characters "in name # Test with special, characters "in name
ok {test-number} - ok {test-number} -
# Testing checked-if
ok {test-number} - true
# Testing checked-if
ok {test-number} -
# Testing checked-if
ok {test-number} - false # TODO
# Testing checked-if
ok {test-number} - true
# Testing checked-if
ok {test-number} - false # TODO
# Testing checked-if
ok {test-number} -
# Testing checked-if 2
ok {test-number} - true
# Testing checked-if 2
not ok {test-number} - explicitly
# Testing checked-if 3
ok {test-number} - false # TODO
# Testing checked-if 3
not ok {test-number} - explicitly
# The NO_FAIL macro reports a failure but does not fail the test # The NO_FAIL macro reports a failure but does not fail the test
ok {test-number} - 1 == 2 # TODO ok {test-number} - 1 == 2 # TODO
# The default listing implementation write to provided stream # The default listing implementation write to provided stream
@ -3570,7 +3590,7 @@ ok {test-number} - flag for: true
# checkedElse # checkedElse
ok {test-number} - testCheckedElse( true ) for: true ok {test-number} - testCheckedElse( true ) for: true
# checkedElse, failing # checkedElse, failing
not ok {test-number} - flag for: false ok {test-number} - flag for: false # TODO
# checkedElse, failing # checkedElse, failing
not ok {test-number} - testCheckedElse( false ) for: false not ok {test-number} - testCheckedElse( false ) for: false
# checkedIf # checkedIf
@ -3578,7 +3598,7 @@ ok {test-number} - flag for: true
# checkedIf # checkedIf
ok {test-number} - testCheckedIf( true ) for: true ok {test-number} - testCheckedIf( true ) for: true
# checkedIf, failing # checkedIf, failing
not ok {test-number} - flag for: false ok {test-number} - flag for: false # TODO
# checkedIf, failing # checkedIf, failing
not ok {test-number} - testCheckedIf( false ) for: false not ok {test-number} - testCheckedIf( false ) for: false
# classify_outliers # classify_outliers
@ -4180,5 +4200,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
ok {test-number} - ok {test-number} -
# xmlentitycheck # xmlentitycheck
ok {test-number} - ok {test-number} -
1..2094 1..2099

View File

@ -563,6 +563,14 @@ Misc.tests.cpp:<line number>|nexpression failed|n CHECK( s1 == s2 )|nwith expan
##teamcity[testFinished name='Test enum bit values' duration="{duration}"] ##teamcity[testFinished name='Test enum bit values' duration="{duration}"]
##teamcity[testStarted name='Test with special, characters "in name'] ##teamcity[testStarted name='Test with special, characters "in name']
##teamcity[testFinished name='Test with special, characters "in name' duration="{duration}"] ##teamcity[testFinished name='Test with special, characters "in name' duration="{duration}"]
##teamcity[testStarted name='Testing checked-if']
##teamcity[testFinished name='Testing checked-if' duration="{duration}"]
##teamcity[testStarted name='Testing checked-if 2']
Misc.tests.cpp:<line number>|nexplicit failure- failure ignore as test marked as |'ok to fail|'|n']
##teamcity[testFinished name='Testing checked-if 2' duration="{duration}"]
##teamcity[testStarted name='Testing checked-if 3']
Misc.tests.cpp:<line number>|nexplicit failure- failure ignore as test marked as |'ok to fail|'|n']
##teamcity[testFinished name='Testing checked-if 3' duration="{duration}"]
##teamcity[testStarted name='The NO_FAIL macro reports a failure but does not fail the test'] ##teamcity[testStarted name='The NO_FAIL macro reports a failure but does not fail the test']
##teamcity[testFinished name='The NO_FAIL macro reports a failure but does not fail the test' duration="{duration}"] ##teamcity[testFinished name='The NO_FAIL macro reports a failure but does not fail the test' duration="{duration}"]
##teamcity[testStarted name='The default listing implementation write to provided stream'] ##teamcity[testStarted name='The default listing implementation write to provided stream']
@ -661,13 +669,11 @@ Exception.tests.cpp:<line number>|nunexpected exception with message:|n "unexpe
##teamcity[testStarted name='checkedElse'] ##teamcity[testStarted name='checkedElse']
##teamcity[testFinished name='checkedElse' duration="{duration}"] ##teamcity[testFinished name='checkedElse' duration="{duration}"]
##teamcity[testStarted name='checkedElse, failing'] ##teamcity[testStarted name='checkedElse, failing']
Misc.tests.cpp:<line number>|nexpression failed|n CHECKED_ELSE( flag )|nwith expansion:|n false|n']
Misc.tests.cpp:<line number>|nexpression failed|n REQUIRE( testCheckedElse( false ) )|nwith expansion:|n false|n'] Misc.tests.cpp:<line number>|nexpression failed|n REQUIRE( testCheckedElse( false ) )|nwith expansion:|n false|n']
##teamcity[testFinished name='checkedElse, failing' duration="{duration}"] ##teamcity[testFinished name='checkedElse, failing' duration="{duration}"]
##teamcity[testStarted name='checkedIf'] ##teamcity[testStarted name='checkedIf']
##teamcity[testFinished name='checkedIf' duration="{duration}"] ##teamcity[testFinished name='checkedIf' duration="{duration}"]
##teamcity[testStarted name='checkedIf, failing'] ##teamcity[testStarted name='checkedIf, failing']
Misc.tests.cpp:<line number>|nexpression failed|n CHECKED_IF( flag )|nwith expansion:|n false|n']
Misc.tests.cpp:<line number>|nexpression failed|n REQUIRE( testCheckedIf( false ) )|nwith expansion:|n false|n'] Misc.tests.cpp:<line number>|nexpression failed|n REQUIRE( testCheckedIf( false ) )|nwith expansion:|n false|n']
##teamcity[testFinished name='checkedIf, failing' duration="{duration}"] ##teamcity[testFinished name='checkedIf, failing' duration="{duration}"]
##teamcity[testStarted name='classify_outliers'] ##teamcity[testStarted name='classify_outliers']

View File

@ -14425,6 +14425,65 @@ Message from section two
<TestCase name="Test with special, characters &quot;in name" tags="[cli][regression]" filename="tests/<exe-name>/IntrospectiveTests/CmdLine.tests.cpp" > <TestCase name="Test with special, characters &quot;in name" tags="[cli][regression]" filename="tests/<exe-name>/IntrospectiveTests/CmdLine.tests.cpp" >
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<TestCase name="Testing checked-if" tags="[checked-if]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Expression success="true" type="CHECKED_IF" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Original>
true
</Original>
<Expanded>
true
</Expanded>
</Expression>
<Expression success="false" type="CHECKED_IF" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Original>
false
</Original>
<Expanded>
false
</Expanded>
</Expression>
<Expression success="true" type="CHECKED_ELSE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Original>
true
</Original>
<Expanded>
true
</Expanded>
</Expression>
<Expression success="false" type="CHECKED_ELSE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Original>
false
</Original>
<Expanded>
false
</Expanded>
</Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="Testing checked-if 2" tags="[!shouldfail][checked-if]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Expression success="true" type="CHECKED_IF" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Original>
true
</Original>
<Expanded>
true
</Expanded>
</Expression>
<Failure filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" />
<OverallResult success="true"/>
</TestCase>
<TestCase name="Testing checked-if 3" tags="[!shouldfail][checked-if]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Expression success="false" type="CHECKED_ELSE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Original>
false
</Original>
<Expanded>
false
</Expanded>
</Expression>
<Failure filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" />
<OverallResult success="true"/>
</TestCase>
<TestCase name="The NO_FAIL macro reports a failure but does not fail the test" tags="[messages]" filename="tests/<exe-name>/UsageTests/Message.tests.cpp" > <TestCase name="The NO_FAIL macro reports a failure but does not fail the test" tags="[messages]" filename="tests/<exe-name>/UsageTests/Message.tests.cpp" >
<Expression success="false" type="CHECK_NOFAIL" filename="tests/<exe-name>/UsageTests/Message.tests.cpp" > <Expression success="false" type="CHECK_NOFAIL" filename="tests/<exe-name>/UsageTests/Message.tests.cpp" >
<Original> <Original>
@ -19667,9 +19726,9 @@ loose text artifact
</Section> </Section>
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<OverallResults successes="1925" failures="149" expectedFailures="21"/> <OverallResults successes="1930" failures="147" expectedFailures="23"/>
<OverallResultsCases successes="266" failures="86" expectedFailures="4"/> <OverallResultsCases successes="267" failures="86" expectedFailures="6"/>
</Group> </Group>
<OverallResults successes="1925" failures="148" expectedFailures="21"/> <OverallResults successes="1930" failures="146" expectedFailures="23"/>
<OverallResultsCases successes="266" failures="86" expectedFailures="4"/> <OverallResultsCases successes="267" failures="86" expectedFailures="6"/>
</Catch> </Catch>

View File

@ -182,6 +182,39 @@ TEST_CASE( "checkedElse, failing", "[failing][.]" ) {
REQUIRE( testCheckedElse( false ) ); REQUIRE( testCheckedElse( false ) );
} }
TEST_CASE("Testing checked-if", "[checked-if]") {
CHECKED_IF(true) {
SUCCEED();
}
CHECKED_IF(false) {
FAIL();
}
CHECKED_ELSE(true) {
FAIL();
}
CHECKED_ELSE(false) {
SUCCEED();
}
}
TEST_CASE("Testing checked-if 2", "[checked-if][!shouldfail]") {
CHECKED_IF(true) {
FAIL();
}
// If the checked if is not entered, this passes and the test
// fails, because of the [!shouldfail] tag.
SUCCEED();
}
TEST_CASE("Testing checked-if 3", "[checked-if][!shouldfail]") {
CHECKED_ELSE(false) {
FAIL();
}
// If the checked false is not entered, this passes and the test
// fails, because of the [!shouldfail] tag.
SUCCEED();
}
TEST_CASE( "xmlentitycheck" ) { TEST_CASE( "xmlentitycheck" ) {
SECTION( "embedded xml: <test>it should be possible to embed xml characters, such as <, \" or &, or even whole <xml>documents</xml> within an attribute</test>" ) { SECTION( "embedded xml: <test>it should be possible to embed xml characters, such as <, \" or &, or even whole <xml>documents</xml> within an attribute</test>" ) {
SUCCEED(); // We need this here to stop it failing due to no tests SUCCEED(); // We need this here to stop it failing due to no tests