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
5c9f09e94a32ab47f16bf8353a708e226fccf645- Author
- Martin Hořeňovský ·
- Parents
f4fc2dab2c5b
Changes
include/internal/catch_decomposer.h | 4 ++++ projects/SelfTest/Baselines/compact.sw.approved.txt | 2 ++ projects/SelfTest/Baselines/console.std.approved.txt | 2 +- projects/SelfTest/Baselines/console.sw.approved.txt | 12 +++++++++++- projects/SelfTest/Baselines/junit.sw.approved.txt | 2 +- projects/SelfTest/Baselines/xml.sw.approved.txt | 20 ++++++++++++++++++-- projects/SelfTest/UsageTests/Compilation.tests.cpp | 5 +++++ 7 files changed, 42 insertions(+), 5 deletions(-) diff --git a/include/internal/catch_decomposer.h b/include/internal/catch_decomposer.h index af1cbcfb..9320c4dd 100644 --- a/include/internal/catch_decomposer.h +++ b/include/internal/catch_decomposer.h @@ -208,6 +208,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/projects/SelfTest/Baselines/compact.sw.approved.txt b/projects/SelfTest/Baselines/compact.sw.approved.txt index 08390525..3ac244ee 100644 --- a/projects/SelfTest/Baselines/compact.sw.approved.txt +++ b/projects/SelfTest/Baselines/compact.sw.approved.txt @@ -247,6 +247,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/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index 0b403c42..1cb3970e 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -1381,5 +1381,5 @@ due to unexpected exception with message: =============================================================================== test cases: 310 | 236 passed | 70 failed | 4 failed as expected -assertions: 1699 | 1547 passed | 131 failed | 21 failed as expected +assertions: 1701 | 1549 passed | 131 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index bcf66625..9ac146f9 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -1955,6 +1955,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 ------------------------------------------------------------------------------- @@ -13564,5 +13574,5 @@ Misc.tests.cpp:<line number>: PASSED: =============================================================================== test cases: 310 | 220 passed | 86 failed | 4 failed as expected -assertions: 1716 | 1547 passed | 148 failed | 21 failed as expected +assertions: 1718 | 1549 passed | 148 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index 47341280..603e4d0b 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/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="1717" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> + <testsuite name="<exe-name>" errors="17" failures="132" tests="1719" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> <properties> <property name="filters" value="~[!nonportable]~[!benchmark]~[approvals]"/> <property name="random-seed" value="1"/> diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index a2eb1eed..ddbdb595 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -2202,6 +2202,22 @@ Nor would this Val: 1 & Val: 1 </Expanded> </Expression> + <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Compilation.tests.cpp" > + <Original> + lhs ^ rhs + </Original> + <Expanded> + Val: 1 ^ Val: 2 + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE_FALSE" filename="projects/<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="projects/<exe-name>/UsageTests/Tricky.tests.cpp" > @@ -16239,7 +16255,7 @@ loose text artifact </Section> <OverallResult success="true"/> </TestCase> - <OverallResults successes="1547" failures="149" expectedFailures="21"/> + <OverallResults successes="1549" failures="149" expectedFailures="21"/> </Group> - <OverallResults successes="1547" failures="148" expectedFailures="21"/> + <OverallResults successes="1549" failures="148" expectedFailures="21"/> </Catch> diff --git a/projects/SelfTest/UsageTests/Compilation.tests.cpp b/projects/SelfTest/UsageTests/Compilation.tests.cpp index 7ec17448..850d5f9b 100644 --- a/projects/SelfTest/UsageTests/Compilation.tests.cpp +++ b/projects/SelfTest/UsageTests/Compilation.tests.cpp @@ -244,6 +244,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; } @@ -260,5 +263,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); }