Suppress failure of CHECKED_IF and CHECKED_ELSE
Resolves #1390
{"label": "catchorg:devel", "ref": "devel", "sha": "2cb5210caf35bf8fc29ade2e5570cc0f37537951"}
## Description
Both `CHECKED_IF` and `CHECKED_ELSE` are currently fairly obscure macros that simplify using `if`/`else` in tests.

However, entering the `else` branch fails the test in which it occurs, because they are not marked as being ok to fail (tagged with `Catch::ResultDisposition::SuppressFail` to be exact). This behaviour makes them less than useful, but with a change they should be actually usable.

Milestone 3.0, because it is a theoretically breaking change.

Make CHECKED_IF and CHECKED_ELSE "ok to fail"
diff --git a/docs/deprecations.md b/docs/deprecations.md
index c0e51b46dc..8edf2842ea 100644
--- a/docs/deprecations.md
+++ b/docs/deprecations.md
@@ -12,14 +12,6 @@ at least the next major release.
 
 ## 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
 
 The API for Catch2's console colour will be changed to take an extra
diff --git a/docs/other-macros.md b/docs/other-macros.md
index 50593faee7..f23ee6c242 100644
--- a/docs/other-macros.md
+++ b/docs/other-macros.md
@@ -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
 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:
 ```cpp
 int a = ...;
diff --git a/src/catch2/internal/catch_run_context.cpp b/src/catch2/internal/catch_run_context.cpp
index 8379a7aa02..e2719d3127 100644
--- a/src/catch2/internal/catch_run_context.cpp
+++ b/src/catch2/internal/catch_run_context.cpp
@@ -230,9 +230,11 @@ namespace Catch {
         if (result.getResultType() == ResultWas::Ok) {
             m_totals.assertions.passed++;
             m_lastAssertionPassed = true;
-        } else if (!result.isOk()) {
+        } else if (!result.succeeded()) {
             m_lastAssertionPassed = false;
-            if( m_activeTestCase->getTestCaseInfo().okToFail() )
+            if (result.isOk()) {
+            }
+            else if( m_activeTestCase->getTestCaseInfo().okToFail() )
                 m_totals.assertions.failedButOk++;
             else
                 m_totals.assertions.failed++;

diff --git a/src/catch2/catch_test_macros.hpp b/src/catch2/catch_test_macros.hpp
index ae50915026..cd33a65c26 100644
--- a/src/catch2/catch_test_macros.hpp
+++ b/src/catch2/catch_test_macros.hpp
@@ -32,8 +32,8 @@
 
   #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_CHECKED_IF( ... ) INTERNAL_CATCH_IF( "CATCH_CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
-  #define CATCH_CHECKED_ELSE( ... ) INTERNAL_CATCH_ELSE( "CATCH_CHECKED_ELSE", 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 | 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__ )
@@ -123,8 +123,8 @@
 
   #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 CHECKED_IF( ... ) INTERNAL_CATCH_IF( "CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
-  #define CHECKED_ELSE( ... ) INTERNAL_CATCH_ELSE( "CHECKED_ELSE", 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 | 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__ )
diff --git a/tests/SelfTest/Baselines/automake.sw.approved.txt b/tests/SelfTest/Baselines/automake.sw.approved.txt
index 983d976484..c4ad5b1e37 100644
--- a/tests/SelfTest/Baselines/automake.sw.approved.txt
+++ b/tests/SelfTest/Baselines/automake.sw.approved.txt
@@ -231,6 +231,9 @@ Message from section two
 :test-result: PASS Test case with one argument
 :test-result: PASS Test enum bit values
 :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: PASS The default listing implementation write to provided stream
 :test-result: FAIL This test 'should' fail but doesn't
diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt
index e757222db5..92488f5f37 100644
--- a/tests/SelfTest/Baselines/compact.sw.approved.txt
+++ b/tests/SelfTest/Baselines/compact.sw.approved.txt
@@ -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'
 Tricky.tests.cpp:<line number>: passed: 0x<hex digits> == bit30and31 for: 3221225472 (0x<hex digits>) == 3221225472
 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
 Reporters.tests.cpp:<line number>: passed: listingString, Contains("[fakeTag]"s) for: "All available tags:
    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
 Misc.tests.cpp:<line number>: passed: flag 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>: passed: flag 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
 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
@@ -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
 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.
 
diff --git a/tests/SelfTest/Baselines/console.std.approved.txt b/tests/SelfTest/Baselines/console.std.approved.txt
index f91f4b80f3..d9e8f2b8c7 100644
--- a/tests/SelfTest/Baselines/console.std.approved.txt
+++ b/tests/SelfTest/Baselines/console.std.approved.txt
@@ -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
 -------------------------------------------------------------------------------
@@ -1135,11 +1151,6 @@ checkedElse, failing
 Misc.tests.cpp:<line number>
 ...............................................................................
 
-Misc.tests.cpp:<line number>: FAILED:
-  CHECKED_ELSE( flag )
-with expansion:
-  false
-
 Misc.tests.cpp:<line number>: FAILED:
   REQUIRE( testCheckedElse( false ) )
 with expansion:
@@ -1151,11 +1162,6 @@ checkedIf, failing
 Misc.tests.cpp:<line number>
 ...............................................................................
 
-Misc.tests.cpp:<line number>: FAILED:
-  CHECKED_IF( flag )
-with expansion:
-  false
-
 Misc.tests.cpp:<line number>: FAILED:
   REQUIRE( testCheckedIf( false ) )
 with expansion:
@@ -1380,6 +1386,6 @@ due to unexpected exception with message:
   Why would you throw a std::string?
 
 ===============================================================================
-test cases:  356 |  282 passed |  70 failed |  4 failed as expected
-assertions: 2077 | 1925 passed | 131 failed | 21 failed as expected
+test cases:  359 |  283 passed |  70 failed |  6 failed as expected
+assertions: 2082 | 1930 passed | 129 failed | 23 failed as expected
 
diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt
index 5f77647a9d..7e53a539dc 100644
--- a/tests/SelfTest/Baselines/console.sw.approved.txt
+++ b/tests/SelfTest/Baselines/console.sw.approved.txt
@@ -12298,6 +12298,50 @@ CmdLine.tests.cpp:<line number>
 
 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
 -------------------------------------------------------------------------------
@@ -14176,7 +14220,7 @@ checkedElse, failing
 Misc.tests.cpp:<line number>
 ...............................................................................
 
-Misc.tests.cpp:<line number>: FAILED:
+Misc.tests.cpp:<line number>: FAILED - but was ok:
   CHECKED_ELSE( flag )
 with expansion:
   false
@@ -14208,7 +14252,7 @@ checkedIf, failing
 Misc.tests.cpp:<line number>
 ...............................................................................
 
-Misc.tests.cpp:<line number>: FAILED:
+Misc.tests.cpp:<line number>: FAILED - but was ok:
   CHECKED_IF( flag )
 with expansion:
   false
@@ -16722,6 +16766,6 @@ Misc.tests.cpp:<line number>
 Misc.tests.cpp:<line number>: PASSED:
 
 ===============================================================================
-test cases:  356 |  266 passed |  86 failed |  4 failed as expected
-assertions: 2094 | 1925 passed | 148 failed | 21 failed as expected
+test cases:  359 |  267 passed |  86 failed |  6 failed as expected
+assertions: 2099 | 1930 passed | 146 failed | 23 failed as expected
 
diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt
index 12a1456f8e..d90b164554 100644
--- a/tests/SelfTest/Baselines/junit.sw.approved.txt
+++ b/tests/SelfTest/Baselines/junit.sw.approved.txt
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <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>
       <property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/>
       <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 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="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 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"/>
@@ -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="checkedElse" 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">
 FAILED:
   REQUIRE( testCheckedElse( false ) )
@@ -1522,13 +1528,6 @@ Misc.tests.cpp:<line number>
     </testcase>
     <testcase classname="<exe-name>.global" name="checkedIf" 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">
 FAILED:
   REQUIRE( testCheckedIf( false ) )
diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
index 1f0cc5dad5..b900a55cbb 100644
--- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
+++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
@@ -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/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="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="atomic if" duration="{duration}"/>
     <testCase name="checkedElse" 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 ))">
 FAILED:
 	REQUIRE( testCheckedElse( false ) )
@@ -1604,13 +1610,6 @@ Misc.tests.cpp:<line number>
     </testCase>
     <testCase name="checkedIf" 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 ))">
 FAILED:
 	REQUIRE( testCheckedIf( false ) )
diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt
index 8bb648f5eb..a6e63f6da4 100644
--- a/tests/SelfTest/Baselines/tap.sw.approved.txt
+++ b/tests/SelfTest/Baselines/tap.sw.approved.txt
@@ -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
 # Test with special, characters "in name
 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
 ok {test-number} - 1 == 2  # TODO
 # The default listing implementation write to provided stream
@@ -3570,7 +3590,7 @@ ok {test-number} - flag for: true
 # checkedElse
 ok {test-number} - testCheckedElse( true ) for: true
 # checkedElse, failing
-not ok {test-number} - flag for: false
+ok {test-number} - flag for: false  # TODO
 # checkedElse, failing
 not ok {test-number} - testCheckedElse( false ) for: false
 # checkedIf
@@ -3578,7 +3598,7 @@ ok {test-number} - flag for: true
 # checkedIf
 ok {test-number} - testCheckedIf( true ) for: true
 # checkedIf, failing
-not ok {test-number} - flag for: false
+ok {test-number} - flag for: false  # TODO
 # checkedIf, failing
 not ok {test-number} - testCheckedIf( false ) for: false
 # classify_outliers
@@ -4180,5 +4200,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
 ok {test-number} -
 # xmlentitycheck
 ok {test-number} -
-1..2094
+1..2099
 
diff --git a/tests/SelfTest/Baselines/teamcity.sw.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.approved.txt
index e64c984fb1..2c1a8c5c29 100644
--- a/tests/SelfTest/Baselines/teamcity.sw.approved.txt
+++ b/tests/SelfTest/Baselines/teamcity.sw.approved.txt
@@ -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[testStarted name='Test with special, characters "in name']
 ##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[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']
@@ -661,13 +669,11 @@ Exception.tests.cpp:<line number>|nunexpected exception with message:|n  "unexpe
 ##teamcity[testStarted name='checkedElse']
 ##teamcity[testFinished name='checkedElse' duration="{duration}"]
 ##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']
 ##teamcity[testFinished name='checkedElse, failing' duration="{duration}"]
 ##teamcity[testStarted name='checkedIf']
 ##teamcity[testFinished name='checkedIf' duration="{duration}"]
 ##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']
 ##teamcity[testFinished name='checkedIf, failing' duration="{duration}"]
 ##teamcity[testStarted name='classify_outliers']
diff --git a/tests/SelfTest/Baselines/xml.sw.approved.txt b/tests/SelfTest/Baselines/xml.sw.approved.txt
index a624d5bdbf..4aecb91e3b 100644
--- a/tests/SelfTest/Baselines/xml.sw.approved.txt
+++ b/tests/SelfTest/Baselines/xml.sw.approved.txt
@@ -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" >
       <OverallResult success="true"/>
     </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" >
       <Expression success="false" type="CHECK_NOFAIL" filename="tests/<exe-name>/UsageTests/Message.tests.cpp" >
         <Original>
@@ -19667,9 +19726,9 @@ loose text artifact
       </Section>
       <OverallResult success="true"/>
     </TestCase>
-    <OverallResults successes="1925" failures="149" expectedFailures="21"/>
-    <OverallResultsCases successes="266" failures="86" expectedFailures="4"/>
+    <OverallResults successes="1930" failures="147" expectedFailures="23"/>
+    <OverallResultsCases successes="267" failures="86" expectedFailures="6"/>
   </Group>
-  <OverallResults successes="1925" failures="148" expectedFailures="21"/>
-  <OverallResultsCases successes="266" failures="86" expectedFailures="4"/>
+  <OverallResults successes="1930" failures="146" expectedFailures="23"/>
+  <OverallResultsCases successes="267" failures="86" expectedFailures="6"/>
 </Catch>
diff --git a/tests/SelfTest/UsageTests/Misc.tests.cpp b/tests/SelfTest/UsageTests/Misc.tests.cpp
index 277723a8b7..5dfef6b19a 100644
--- a/tests/SelfTest/UsageTests/Misc.tests.cpp
+++ b/tests/SelfTest/UsageTests/Misc.tests.cpp
@@ -182,6 +182,39 @@ TEST_CASE( "checkedElse, failing", "[failing][.]" ) {
     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" ) {
     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

{"approvaltests": {"run": "PASS", "test": "FAIL", "fix": "PASS"}, "runtests": {"run": "PASS", "test": "FAIL", "fix": "PASS"}}
{"randomtestordering": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "list::reporters::output": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "libidentitytest": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "unmatchedoutputfilter": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "checkconvenienceheaders": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "have_flag_-wmisleading-indentation": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "list::tags::output": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "list::tests::xmloutput": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "list::tags::exitcode": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "filenameastagsmatching": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "notest": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "have_flag_-wdeprecated": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "list::tests::output": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "escapespecialcharactersintestnames": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "testsinfile::invalidtestnames-2": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "have_flag_-wunreachable-code": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "noassertions": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "negativespecnohiddentests": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "have_flag_-wshadow": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "filteredsection::generatorsdontcauseinfiniteloop-2": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "versioncheck": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "have_flag_-wextra": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "list::tests::exitcode": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "have_flag_-wunused-function": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "warnaboutnotests": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "have_flag_-wmissing-noreturn": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "list::tests::quiet": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "have_flag_-wmissing-braces": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "have_flag_-wpedantic": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "testsinfile::simplespecs": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "regressioncheck-1670": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "have_flag_-wparentheses": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "have_flag_-wall": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "testsinfile::escapespecialcharacters": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "have_flag_-wold-style-cast": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "list::tags::xmloutput": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "filteredsection-2": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "list::reporters::exitcode": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "filenameastagstest": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "testsinfile::invalidtestnames-1": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "have_flag_-wvla": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "have_flag_-wundef": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "have_flag_-wunused-parameter": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "filteredsection-1": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "have_flag_-wmissing-declarations": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "tagalias": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "list::reporters::xmloutput": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "have_flag_-wstrict-aliasing": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "have_flag_-wsuggest-override": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "filteredsection::generatorsdontcauseinfiniteloop-1": {"run": "PASS", "test": "PASS", "fix": "PASS"}}
{"passed_count": 52, "failed_count": 9, "skipped_count": 0, "passed_tests": ["randomtestordering", "list::reporters::output", "libidentitytest", "unmatchedoutputfilter", "checkconvenienceheaders", "have_flag_-wmisleading-indentation", "list::tags::output", "list::tests::xmloutput", "list::tags::exitcode", "list::reporters::xmloutput", "filenameastagsmatching", "notest", "have_flag_-wdeprecated", "list::tests::output", "approvaltests", "escapespecialcharactersintestnames", "testsinfile::invalidtestnames-2", "have_flag_-wunreachable-code", "noassertions", "negativespecnohiddentests", "have_flag_-wshadow", "filteredsection::generatorsdontcauseinfiniteloop-2", "versioncheck", "have_flag_-wextra", "list::tests::exitcode", "warnaboutnotests", "have_flag_-wmissing-noreturn", "list::tests::quiet", "have_flag_-wmissing-braces", "runtests", "have_flag_-wpedantic", "testsinfile::simplespecs", "regressioncheck-1670", "have_flag_-wparentheses", "have_flag_-wall", "testsinfile::escapespecialcharacters", "have_flag_-wold-style-cast", "list::tags::xmloutput", "filteredsection-2", "list::reporters::exitcode", "filenameastagstest", "testsinfile::invalidtestnames-1", "have_flag_-wvla", "have_flag_-wundef", "have_flag_-wunused-parameter", "filteredsection-1", "have_flag_-wmissing-declarations", "tagalias", "have_flag_-wunused-function", "have_flag_-wstrict-aliasing", "have_flag_-wsuggest-override", "filteredsection::generatorsdontcauseinfiniteloop-1"], "failed_tests": ["have_flag_-wglobal-constructors", "have_flag_-wreturn-std-move", "have_flag_-wcall-to-pure-virtual-from-ctor-dtor", "have_flag_-wweak-vtables", "have_flag_-wdeprecated-register", "have_flag_-wexit-time-destructors", "have_flag_-wabsolute-value", "have_flag_-wextra-semi-stmt", "have_flag_-wcatch-value"], "skipped_tests": []}
{"passed_count": 50, "failed_count": 11, "skipped_count": 0, "passed_tests": ["randomtestordering", "list::reporters::output", "libidentitytest", "unmatchedoutputfilter", "checkconvenienceheaders", "have_flag_-wmisleading-indentation", "list::tags::output", "list::tests::xmloutput", "list::tags::exitcode", "list::reporters::xmloutput", "filenameastagsmatching", "notest", "have_flag_-wdeprecated", "list::tests::output", "escapespecialcharactersintestnames", "testsinfile::invalidtestnames-2", "have_flag_-wunreachable-code", "noassertions", "negativespecnohiddentests", "have_flag_-wshadow", "filteredsection::generatorsdontcauseinfiniteloop-2", "versioncheck", "have_flag_-wextra", "list::tests::exitcode", "warnaboutnotests", "have_flag_-wmissing-noreturn", "list::tests::quiet", "have_flag_-wmissing-braces", "have_flag_-wpedantic", "testsinfile::simplespecs", "regressioncheck-1670", "have_flag_-wparentheses", "have_flag_-wall", "testsinfile::escapespecialcharacters", "have_flag_-wold-style-cast", "list::tags::xmloutput", "filteredsection-2", "list::reporters::exitcode", "filenameastagstest", "testsinfile::invalidtestnames-1", "have_flag_-wvla", "have_flag_-wundef", "have_flag_-wunused-parameter", "filteredsection-1", "have_flag_-wmissing-declarations", "tagalias", "have_flag_-wunused-function", "have_flag_-wstrict-aliasing", "have_flag_-wsuggest-override", "filteredsection::generatorsdontcauseinfiniteloop-1"], "failed_tests": ["approvaltests", "have_flag_-wglobal-constructors", "have_flag_-wreturn-std-move", "have_flag_-wcall-to-pure-virtual-from-ctor-dtor", "have_flag_-wweak-vtables", "have_flag_-wdeprecated-register", "runtests", "have_flag_-wexit-time-destructors", "have_flag_-wabsolute-value", "have_flag_-wextra-semi-stmt", "have_flag_-wcatch-value"], "skipped_tests": []}
{"passed_count": 52, "failed_count": 9, "skipped_count": 0, "passed_tests": ["randomtestordering", "list::reporters::output", "libidentitytest", "unmatchedoutputfilter", "checkconvenienceheaders", "have_flag_-wmisleading-indentation", "list::tags::output", "list::tests::xmloutput", "list::tags::exitcode", "list::reporters::xmloutput", "filenameastagsmatching", "notest", "have_flag_-wdeprecated", "list::tests::output", "approvaltests", "escapespecialcharactersintestnames", "testsinfile::invalidtestnames-2", "have_flag_-wunreachable-code", "noassertions", "negativespecnohiddentests", "have_flag_-wshadow", "filteredsection::generatorsdontcauseinfiniteloop-2", "versioncheck", "have_flag_-wextra", "list::tests::exitcode", "warnaboutnotests", "have_flag_-wmissing-noreturn", "list::tests::quiet", "have_flag_-wmissing-braces", "runtests", "have_flag_-wpedantic", "testsinfile::simplespecs", "regressioncheck-1670", "have_flag_-wparentheses", "have_flag_-wall", "testsinfile::escapespecialcharacters", "have_flag_-wold-style-cast", "list::tags::xmloutput", "filteredsection-2", "list::reporters::exitcode", "filenameastagstest", "testsinfile::invalidtestnames-1", "have_flag_-wvla", "have_flag_-wundef", "have_flag_-wunused-parameter", "filteredsection-1", "have_flag_-wmissing-declarations", "tagalias", "have_flag_-wunused-function", "have_flag_-wstrict-aliasing", "have_flag_-wsuggest-override", "filteredsection::generatorsdontcauseinfiniteloop-1"], "failed_tests": ["have_flag_-wglobal-constructors", "have_flag_-wreturn-std-move", "have_flag_-wcall-to-pure-virtual-from-ctor-dtor", "have_flag_-wweak-vtables", "have_flag_-wdeprecated-register", "have_flag_-wexit-time-destructors", "have_flag_-wabsolute-value", "have_flag_-wextra-semi-stmt", "have_flag_-wcatch-value"], "skipped_tests": []}