mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 13:26:10 +01:00
Add support for bitwise xor to the decomposer
This commit is contained in:
parent
4aefbbcd02
commit
5b8cccaf6a
@ -216,6 +216,10 @@ namespace Catch {
|
|||||||
auto operator & (RhsT const& rhs) -> BinaryExpr<LhsT, RhsT const&> const {
|
auto operator & (RhsT const& rhs) -> BinaryExpr<LhsT, RhsT const&> const {
|
||||||
return { static_cast<bool>(m_lhs & rhs), m_lhs, "&", rhs };
|
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>
|
template<typename RhsT>
|
||||||
auto operator && ( RhsT const& ) -> BinaryExpr<LhsT, RhsT const&> const {
|
auto operator && ( RhsT const& ) -> BinaryExpr<LhsT, RhsT const&> const {
|
||||||
|
@ -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: !(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: 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
|
Tricky.tests.cpp:<line number>: passed: true
|
||||||
Tricky.tests.cpp:<line number>: passed: true
|
Tricky.tests.cpp:<line number>: passed: true
|
||||||
|
@ -1381,5 +1381,5 @@ due to unexpected exception with message:
|
|||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
test cases: 335 | 261 passed | 70 failed | 4 failed as expected
|
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
|
||||||
|
|
||||||
|
@ -1964,6 +1964,16 @@ Compilation.tests.cpp:<line number>: PASSED:
|
|||||||
with expansion:
|
with expansion:
|
||||||
Val: 1 & Val: 1
|
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
|
Assertions then sections
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
@ -14795,5 +14805,5 @@ Misc.tests.cpp:<line number>: PASSED:
|
|||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
test cases: 335 | 245 passed | 86 failed | 4 failed as expected
|
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
|
||||||
|
|
||||||
|
@ -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="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>
|
<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"/>
|
||||||
|
@ -494,6 +494,10 @@ ok {test-number} - lhs | rhs for: Val: 1 | Val: 2
|
|||||||
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
|
# Assertion macros support bit operators and bool conversions
|
||||||
ok {test-number} - HasBitOperators{ 1 } & HasBitOperators{ 1 } for: Val: 1 & Val: 1
|
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
|
# Assertions then sections
|
||||||
ok {test-number} - true
|
ok {test-number} - true
|
||||||
# Assertions then sections
|
# Assertions then sections
|
||||||
@ -3816,5 +3820,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..1904
|
1..1906
|
||||||
|
|
||||||
|
@ -2208,6 +2208,22 @@ Nor would this
|
|||||||
Val: 1 & Val: 1
|
Val: 1 & Val: 1
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</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"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<TestCase name="Assertions then sections" tags="[Tricky]" filename="tests/<exe-name>/UsageTests/Tricky.tests.cpp" >
|
<TestCase name="Assertions then sections" tags="[Tricky]" filename="tests/<exe-name>/UsageTests/Tricky.tests.cpp" >
|
||||||
@ -17759,7 +17775,7 @@ loose text artifact
|
|||||||
</Section>
|
</Section>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<OverallResults successes="1743" failures="149" expectedFailures="21"/>
|
<OverallResults successes="1745" failures="149" expectedFailures="21"/>
|
||||||
</Group>
|
</Group>
|
||||||
<OverallResults successes="1743" failures="148" expectedFailures="21"/>
|
<OverallResults successes="1745" failures="148" expectedFailures="21"/>
|
||||||
</Catch>
|
</Catch>
|
||||||
|
@ -247,6 +247,9 @@ namespace {
|
|||||||
friend HasBitOperators operator& (HasBitOperators lhs, HasBitOperators rhs) {
|
friend HasBitOperators operator& (HasBitOperators lhs, HasBitOperators rhs) {
|
||||||
return { lhs.value & rhs.value };
|
return { lhs.value & rhs.value };
|
||||||
}
|
}
|
||||||
|
friend HasBitOperators operator^ (HasBitOperators lhs, HasBitOperators rhs) {
|
||||||
|
return { lhs.value ^ rhs.value };
|
||||||
|
}
|
||||||
explicit operator bool() const {
|
explicit operator bool() const {
|
||||||
return !!value;
|
return !!value;
|
||||||
}
|
}
|
||||||
@ -263,5 +266,7 @@ TEST_CASE("Assertion macros support bit operators and bool conversions", "[compi
|
|||||||
REQUIRE(lhs | rhs);
|
REQUIRE(lhs | rhs);
|
||||||
REQUIRE_FALSE(lhs & rhs);
|
REQUIRE_FALSE(lhs & rhs);
|
||||||
REQUIRE(HasBitOperators{ 1 } & HasBitOperators{ 1 });
|
REQUIRE(HasBitOperators{ 1 } & HasBitOperators{ 1 });
|
||||||
|
REQUIRE(lhs ^ rhs);
|
||||||
|
REQUIRE_FALSE(lhs ^ lhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user