mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Fix a bug in UnorderedEqualsMatcher
Previously a mismatched prefix would be skipped before the actual comparison would be performed. Obviously, it is supposed to be _matching_ prefix that is skipped.
This commit is contained in:
parent
558bbe7d24
commit
be49a539e4
@ -124,7 +124,7 @@ namespace Matchers {
|
|||||||
auto lfirst = m_target.begin(), llast = m_target.end();
|
auto lfirst = m_target.begin(), llast = m_target.end();
|
||||||
auto rfirst = vec.begin(), rlast = vec.end();
|
auto rfirst = vec.begin(), rlast = vec.end();
|
||||||
// Cut common prefix to optimize checking of permuted parts
|
// Cut common prefix to optimize checking of permuted parts
|
||||||
while (lfirst != llast && *lfirst != *rfirst) {
|
while (lfirst != llast && *lfirst == *rfirst) {
|
||||||
++lfirst; ++rfirst;
|
++lfirst; ++rfirst;
|
||||||
}
|
}
|
||||||
if (lfirst == llast) {
|
if (lfirst == llast) {
|
||||||
|
@ -740,6 +740,7 @@ Decomposition.tests.cpp:<line number>: failed: truthy(false) for: Hey, its truth
|
|||||||
Matchers.tests.cpp:<line number>: failed: testStringForMatching(), Matches("this STRING contains 'abc' as a substring") for: "this string contains 'abc' as a substring" matches "this STRING contains 'abc' as a substring" case sensitively
|
Matchers.tests.cpp:<line number>: failed: testStringForMatching(), Matches("this STRING contains 'abc' as a substring") for: "this string contains 'abc' as a substring" matches "this STRING contains 'abc' as a substring" case sensitively
|
||||||
Matchers.tests.cpp:<line number>: failed: testStringForMatching(), Matches("contains 'abc' as a substring") for: "this string contains 'abc' as a substring" matches "contains 'abc' as a substring" case sensitively
|
Matchers.tests.cpp:<line number>: failed: testStringForMatching(), Matches("contains 'abc' as a substring") for: "this string contains 'abc' as a substring" matches "contains 'abc' as a substring" case sensitively
|
||||||
Matchers.tests.cpp:<line number>: failed: testStringForMatching(), Matches("this string contains 'abc' as a") for: "this string contains 'abc' as a substring" matches "this string contains 'abc' as a" case sensitively
|
Matchers.tests.cpp:<line number>: failed: testStringForMatching(), Matches("this string contains 'abc' as a") for: "this string contains 'abc' as a substring" matches "this string contains 'abc' as a" case sensitively
|
||||||
|
Matchers.tests.cpp:<line number>: passed: actual, !UnorderedEquals(expected) for: { 'a', 'b' } not UnorderedEquals: { 'c', 'b' }
|
||||||
Message.tests.cpp:<line number>: passed: with 1 message: 'this is a success'
|
Message.tests.cpp:<line number>: passed: with 1 message: 'this is a success'
|
||||||
Message.tests.cpp:<line number>: passed:
|
Message.tests.cpp:<line number>: passed:
|
||||||
BDD.tests.cpp:<line number>: passed: before == 0 for: 0 == 0
|
BDD.tests.cpp:<line number>: passed: before == 0 for: 0 == 0
|
||||||
|
@ -1096,6 +1096,6 @@ due to unexpected exception with message:
|
|||||||
Why would you throw a std::string?
|
Why would you throw a std::string?
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
test cases: 212 | 159 passed | 49 failed | 4 failed as expected
|
test cases: 213 | 160 passed | 49 failed | 4 failed as expected
|
||||||
assertions: 1227 | 1098 passed | 108 failed | 21 failed as expected
|
assertions: 1228 | 1099 passed | 108 failed | 21 failed as expected
|
||||||
|
|
||||||
|
@ -6296,6 +6296,18 @@ with expansion:
|
|||||||
"this string contains 'abc' as a substring" matches "this string contains
|
"this string contains 'abc' as a substring" matches "this string contains
|
||||||
'abc' as a" case sensitively
|
'abc' as a" case sensitively
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Regression test #1
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Matchers.tests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
Matchers.tests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
CHECK_THAT( actual, !UnorderedEquals(expected) )
|
||||||
|
with expansion:
|
||||||
|
{ 'a', 'b' } not UnorderedEquals: { 'c', 'b' }
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
SUCCEED counts as a test pass
|
SUCCEED counts as a test pass
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
@ -10822,6 +10834,6 @@ Misc.tests.cpp:<line number>:
|
|||||||
PASSED:
|
PASSED:
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
test cases: 212 | 146 passed | 62 failed | 4 failed as expected
|
test cases: 213 | 147 passed | 62 failed | 4 failed as expected
|
||||||
assertions: 1241 | 1098 passed | 122 failed | 21 failed as expected
|
assertions: 1242 | 1099 passed | 122 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="106" tests="1242" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
<testsuite name="<exe-name>" errors="17" failures="106" tests="1243" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||||
<testcase classname="<exe-name>.global" name="# A test name that starts with a #" time="{duration}"/>
|
<testcase classname="<exe-name>.global" name="# A test name that starts with a #" time="{duration}"/>
|
||||||
<testcase classname="<exe-name>.global" name="#1005: Comparing pointer to int and long (NULL can be either on various systems)" time="{duration}"/>
|
<testcase classname="<exe-name>.global" name="#1005: Comparing pointer to int and long (NULL can be either on various systems)" time="{duration}"/>
|
||||||
<testcase classname="<exe-name>.global" name="#1027" time="{duration}"/>
|
<testcase classname="<exe-name>.global" name="#1027" time="{duration}"/>
|
||||||
@ -518,6 +518,7 @@ Matchers.tests.cpp:<line number>
|
|||||||
Matchers.tests.cpp:<line number>
|
Matchers.tests.cpp:<line number>
|
||||||
</failure>
|
</failure>
|
||||||
</testcase>
|
</testcase>
|
||||||
|
<testcase classname="<exe-name>.global" name="Regression test #1" time="{duration}"/>
|
||||||
<testcase classname="<exe-name>.global" name="SUCCEED counts as a test pass" time="{duration}"/>
|
<testcase classname="<exe-name>.global" name="SUCCEED counts as a test pass" time="{duration}"/>
|
||||||
<testcase classname="<exe-name>.global" name="SUCCEED does not require an argument" time="{duration}"/>
|
<testcase classname="<exe-name>.global" name="SUCCEED does not require an argument" time="{duration}"/>
|
||||||
<testcase classname="<exe-name>.Fixture" name="Scenario: BDD tests requiring Fixtures to provide commonly-accessed data or methods/Given: No operations precede me" time="{duration}"/>
|
<testcase classname="<exe-name>.Fixture" name="Scenario: BDD tests requiring Fixtures to provide commonly-accessed data or methods/Given: No operations precede me" time="{duration}"/>
|
||||||
|
@ -6608,6 +6608,17 @@
|
|||||||
</Expression>
|
</Expression>
|
||||||
<OverallResult success="false"/>
|
<OverallResult success="false"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
|
<TestCase name="Regression test #1" tags="[matchers][vector]" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||||
|
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||||
|
<Original>
|
||||||
|
actual, !UnorderedEquals(expected)
|
||||||
|
</Original>
|
||||||
|
<Expanded>
|
||||||
|
{ 'a', 'b' } not UnorderedEquals: { 'c', 'b' }
|
||||||
|
</Expanded>
|
||||||
|
</Expression>
|
||||||
|
<OverallResult success="true"/>
|
||||||
|
</TestCase>
|
||||||
<TestCase name="SUCCEED counts as a test pass" tags="[messages]" filename="projects/<exe-name>/UsageTests/Message.tests.cpp" >
|
<TestCase name="SUCCEED counts as a test pass" tags="[messages]" filename="projects/<exe-name>/UsageTests/Message.tests.cpp" >
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
@ -11310,7 +11321,7 @@ loose text artifact
|
|||||||
</Section>
|
</Section>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<OverallResults successes="1098" failures="123" expectedFailures="21"/>
|
<OverallResults successes="1099" failures="123" expectedFailures="21"/>
|
||||||
</Group>
|
</Group>
|
||||||
<OverallResults successes="1098" failures="122" expectedFailures="21"/>
|
<OverallResults successes="1099" failures="122" expectedFailures="21"/>
|
||||||
</Catch>
|
</Catch>
|
||||||
|
@ -423,6 +423,15 @@ namespace { namespace MatchersTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Regression test #1", "[matchers][vector]") {
|
||||||
|
// At some point, UnorderedEqualsMatcher skipped
|
||||||
|
// mismatched prefixed before doing the comparison itself
|
||||||
|
std::vector<char> actual = { 'a', 'b' };
|
||||||
|
std::vector<char> expected = { 'c', 'b' };
|
||||||
|
|
||||||
|
CHECK_THAT(actual, !UnorderedEquals(expected));
|
||||||
|
}
|
||||||
|
|
||||||
} } // namespace MatchersTests
|
} } // namespace MatchersTests
|
||||||
|
|
||||||
#endif // CATCH_CONFIG_DISABLE_MATCHERS
|
#endif // CATCH_CONFIG_DISABLE_MATCHERS
|
||||||
|
Loading…
Reference in New Issue
Block a user