Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Add support for bitwise xor to the decomposer

Commit
5b8cccaf6a9f16267ac61449a65b2df77d82d886
Author
Martin Hořeňovský ·
Parents
4aefbbcd028a

Files · Download .tar.gz

Changes

 src/catch2/internal/catch_decomposer.hpp          |  4 ++++
 tests/SelfTest/Baselines/compact.sw.approved.txt  |  2 ++
 tests/SelfTest/Baselines/console.std.approved.txt |  2 +-
 tests/SelfTest/Baselines/console.sw.approved.txt  | 12 +++++++++++-
 tests/SelfTest/Baselines/junit.sw.approved.txt    |  2 +-
 tests/SelfTest/Baselines/tap.sw.approved.txt      |  6 +++++-
 tests/SelfTest/Baselines/xml.sw.approved.txt      | 20 ++++++++++++++++++--
 tests/SelfTest/UsageTests/Compilation.tests.cpp   |  5 +++++
 8 files changed, 47 insertions(+), 6 deletions(-)

diff --git a/src/catch2/internal/catch_decomposer.hpp b/src/catch2/internal/catch_decomposer.hpp
index 814824c6..260a3f78 100644
--- a/src/catch2/internal/catch_decomposer.hpp
+++ b/src/catch2/internal/catch_decomposer.hpp
@@ -216,6 +216,10 @@ namespace Catch {
         auto operator & (RhsT const& rhs) -> BinaryExpr<LhsT, RhsT const&> const {
             return { static_cast<bool>(m_lhs & rhs), m_lhs, "&", rhs };
         }
+        template <typename RhsT>
+        auto operator ^ (RhsT const& rhs) -> BinaryExpr<LhsT, RhsT const&> const {
+            return { static_cast<bool>(m_lhs ^ rhs), m_lhs, "^", rhs };
+        }
 
         template<typename RhsT>
         auto operator && ( RhsT const& ) -> BinaryExpr<LhsT, RhsT const&> const {
diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt
index c965699f..d505f9b6 100644
--- a/tests/SelfTest/Baselines/compact.sw.approved.txt
+++ b/tests/SelfTest/Baselines/compact.sw.approved.txt
@@ -248,6 +248,8 @@ Matchers.tests.cpp:<line number>: passed: "This wouldn't pass", !Predicate<std::
 Compilation.tests.cpp:<line number>: passed: lhs | rhs for: Val: 1 | Val: 2
 Compilation.tests.cpp:<line number>: passed: !(lhs & rhs) for: !(Val: 1 & Val: 2)
 Compilation.tests.cpp:<line number>: passed: HasBitOperators{ 1 } & HasBitOperators{ 1 } for: Val: 1 & Val: 1
+Compilation.tests.cpp:<line number>: passed: lhs ^ rhs for: Val: 1 ^ Val: 2
+Compilation.tests.cpp:<line number>: passed: !(lhs ^ lhs) for: !(Val: 1 ^ Val: 1)
 Tricky.tests.cpp:<line number>: passed: true
 Tricky.tests.cpp:<line number>: passed: true
 Tricky.tests.cpp:<line number>: passed: true
diff --git a/tests/SelfTest/Baselines/console.std.approved.txt b/tests/SelfTest/Baselines/console.std.approved.txt
index 9c523a54..0fb3f0b2 100644
--- a/tests/SelfTest/Baselines/console.std.approved.txt
+++ b/tests/SelfTest/Baselines/console.std.approved.txt
@@ -1381,5 +1381,5 @@ due to unexpected exception with message:
 
 ===============================================================================
 test cases:  335 |  261 passed |  70 failed |  4 failed as expected
-assertions: 1895 | 1743 passed | 131 failed | 21 failed as expected
+assertions: 1897 | 1745 passed | 131 failed | 21 failed as expected
 
diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt
index 1feae362..6818786f 100644
--- a/tests/SelfTest/Baselines/console.sw.approved.txt
+++ b/tests/SelfTest/Baselines/console.sw.approved.txt
@@ -1964,6 +1964,16 @@ Compilation.tests.cpp:<line number>: PASSED:
 with expansion:
   Val: 1 & Val: 1
 
+Compilation.tests.cpp:<line number>: PASSED:
+  REQUIRE( lhs ^ rhs )
+with expansion:
+  Val: 1 ^ Val: 2
+
+Compilation.tests.cpp:<line number>: PASSED:
+  REQUIRE_FALSE( lhs ^ lhs )
+with expansion:
+  !(Val: 1 ^ Val: 1)
+
 -------------------------------------------------------------------------------
 Assertions then sections
 -------------------------------------------------------------------------------
@@ -14795,5 +14805,5 @@ Misc.tests.cpp:<line number>: PASSED:
 
 ===============================================================================
 test cases:  335 |  245 passed |  86 failed |  4 failed as expected
-assertions: 1912 | 1743 passed | 148 failed | 21 failed as expected
+assertions: 1914 | 1745 passed | 148 failed | 21 failed as expected
 
diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt
index b2d601e9..26044c54 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="1913" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
+  <testsuite name="<exe-name>" errors="17" failures="132" tests="1915" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
     <properties>
       <property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/>
       <property name="random-seed" value="1"/>
diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt
index 9d6eedb3..f7a5aeb7 100644
--- a/tests/SelfTest/Baselines/tap.sw.approved.txt
+++ b/tests/SelfTest/Baselines/tap.sw.approved.txt
@@ -494,6 +494,10 @@ ok {test-number} - lhs | rhs for: Val: 1 | Val: 2
 ok {test-number} - !(lhs & rhs) for: !(Val: 1 & Val: 2)
 # Assertion macros support bit operators and bool conversions
 ok {test-number} - HasBitOperators{ 1 } & HasBitOperators{ 1 } for: Val: 1 & Val: 1
+# Assertion macros support bit operators and bool conversions
+ok {test-number} - lhs ^ rhs for: Val: 1 ^ Val: 2
+# Assertion macros support bit operators and bool conversions
+ok {test-number} - !(lhs ^ lhs) for: !(Val: 1 ^ Val: 1)
 # Assertions then sections
 ok {test-number} - true
 # Assertions then sections
@@ -3816,5 +3820,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
 ok {test-number} -
 # xmlentitycheck
 ok {test-number} -
-1..1904
+1..1906
 
diff --git a/tests/SelfTest/Baselines/xml.sw.approved.txt b/tests/SelfTest/Baselines/xml.sw.approved.txt
index eb2b2593..70de0b73 100644
--- a/tests/SelfTest/Baselines/xml.sw.approved.txt
+++ b/tests/SelfTest/Baselines/xml.sw.approved.txt
@@ -2208,6 +2208,22 @@ Nor would this
           Val: 1 &amp; Val: 1
         </Expanded>
       </Expression>
+      <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Compilation.tests.cpp" >
+        <Original>
+          lhs ^ rhs
+        </Original>
+        <Expanded>
+          Val: 1 ^ Val: 2
+        </Expanded>
+      </Expression>
+      <Expression success="true" type="REQUIRE_FALSE" filename="tests/<exe-name>/UsageTests/Compilation.tests.cpp" >
+        <Original>
+          !(lhs ^ lhs)
+        </Original>
+        <Expanded>
+          !(Val: 1 ^ Val: 1)
+        </Expanded>
+      </Expression>
       <OverallResult success="true"/>
     </TestCase>
     <TestCase name="Assertions then sections" tags="[Tricky]" filename="tests/<exe-name>/UsageTests/Tricky.tests.cpp" >
@@ -17759,7 +17775,7 @@ loose text artifact
       </Section>
       <OverallResult success="true"/>
     </TestCase>
-    <OverallResults successes="1743" failures="149" expectedFailures="21"/>
+    <OverallResults successes="1745" failures="149" expectedFailures="21"/>
   </Group>
-  <OverallResults successes="1743" failures="148" expectedFailures="21"/>
+  <OverallResults successes="1745" failures="148" expectedFailures="21"/>
 </Catch>
diff --git a/tests/SelfTest/UsageTests/Compilation.tests.cpp b/tests/SelfTest/UsageTests/Compilation.tests.cpp
index 4fc63fa0..9e4211ff 100644
--- a/tests/SelfTest/UsageTests/Compilation.tests.cpp
+++ b/tests/SelfTest/UsageTests/Compilation.tests.cpp
@@ -247,6 +247,9 @@ namespace {
         friend HasBitOperators operator& (HasBitOperators lhs, HasBitOperators rhs) {
             return { lhs.value & rhs.value };
         }
+        friend HasBitOperators operator^ (HasBitOperators lhs, HasBitOperators rhs) {
+            return { lhs.value ^ rhs.value };
+        }
         explicit operator bool() const {
             return !!value;
         }
@@ -263,5 +266,7 @@ TEST_CASE("Assertion macros support bit operators and bool conversions", "[compi
     REQUIRE(lhs | rhs);
     REQUIRE_FALSE(lhs & rhs);
     REQUIRE(HasBitOperators{ 1 } & HasBitOperators{ 1 });
+    REQUIRE(lhs ^ rhs);
+    REQUIRE_FALSE(lhs ^ lhs);
 }