diff --git a/include/internal/catch_matchers_vector.h b/include/internal/catch_matchers_vector.h index 833d7dc2..1e29cc94 100644 --- a/include/internal/catch_matchers_vector.h +++ b/include/internal/catch_matchers_vector.h @@ -124,7 +124,7 @@ namespace Matchers { auto lfirst = m_target.begin(), llast = m_target.end(); auto rfirst = vec.begin(), rlast = vec.end(); // Cut common prefix to optimize checking of permuted parts - while (lfirst != llast && *lfirst != *rfirst) { + while (lfirst != llast && *lfirst == *rfirst) { ++lfirst; ++rfirst; } if (lfirst == llast) { diff --git a/projects/SelfTest/Baselines/compact.sw.approved.txt b/projects/SelfTest/Baselines/compact.sw.approved.txt index 5c19d7ad..2138d26e 100644 --- a/projects/SelfTest/Baselines/compact.sw.approved.txt +++ b/projects/SelfTest/Baselines/compact.sw.approved.txt @@ -740,6 +740,7 @@ Decomposition.tests.cpp:: failed: truthy(false) for: Hey, its truth Matchers.tests.cpp:: 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:: 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:: 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:: passed: actual, !UnorderedEquals(expected) for: { 'a', 'b' } not UnorderedEquals: { 'c', 'b' } Message.tests.cpp:: passed: with 1 message: 'this is a success' Message.tests.cpp:: passed: BDD.tests.cpp:: passed: before == 0 for: 0 == 0 diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index 4800aec0..24755c80 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -1096,6 +1096,6 @@ due to unexpected exception with message: Why would you throw a std::string? =============================================================================== -test cases: 212 | 159 passed | 49 failed | 4 failed as expected -assertions: 1227 | 1098 passed | 108 failed | 21 failed as expected +test cases: 213 | 160 passed | 49 failed | 4 failed as expected +assertions: 1228 | 1099 passed | 108 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index 08318ab0..27fa5c59 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -6296,6 +6296,18 @@ with expansion: "this string contains 'abc' as a substring" matches "this string contains 'abc' as a" case sensitively +------------------------------------------------------------------------------- +Regression test #1 +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: +PASSED: + CHECK_THAT( actual, !UnorderedEquals(expected) ) +with expansion: + { 'a', 'b' } not UnorderedEquals: { 'c', 'b' } + ------------------------------------------------------------------------------- SUCCEED counts as a test pass ------------------------------------------------------------------------------- @@ -10822,6 +10834,6 @@ Misc.tests.cpp:: PASSED: =============================================================================== -test cases: 212 | 146 passed | 62 failed | 4 failed as expected -assertions: 1241 | 1098 passed | 122 failed | 21 failed as expected +test cases: 213 | 147 passed | 62 failed | 4 failed as expected +assertions: 1242 | 1099 passed | 122 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index f47f1f9a..ad5caeb1 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -1,7 +1,7 @@ - + @@ -518,6 +518,7 @@ Matchers.tests.cpp: Matchers.tests.cpp: + diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index 7680c711..34287874 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -6608,6 +6608,17 @@ + + + + actual, !UnorderedEquals(expected) + + + { 'a', 'b' } not UnorderedEquals: { 'c', 'b' } + + + + @@ -11310,7 +11321,7 @@ loose text artifact - + - + diff --git a/projects/SelfTest/UsageTests/Matchers.tests.cpp b/projects/SelfTest/UsageTests/Matchers.tests.cpp index 71abb868..e09dad14 100644 --- a/projects/SelfTest/UsageTests/Matchers.tests.cpp +++ b/projects/SelfTest/UsageTests/Matchers.tests.cpp @@ -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 actual = { 'a', 'b' }; + std::vector expected = { 'c', 'b' }; + + CHECK_THAT(actual, !UnorderedEquals(expected)); + } + } } // namespace MatchersTests #endif // CATCH_CONFIG_DISABLE_MATCHERS