diff options
author | Abseil Team <absl-team@google.com> | 2024-05-20 14:35:58 (GMT) |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-05-20 14:36:47 (GMT) |
commit | c8393f8554419dc27b688c535b8fa4afb82146a4 (patch) | |
tree | f29529ee7094472daf16eefcdd5a6d048c67a7a7 /googlemock/test | |
parent | 33af80a883ddc33d9c0fac0a5b4578301efb18de (diff) | |
download | googletest-c8393f8554419dc27b688c535b8fa4afb82146a4.zip googletest-c8393f8554419dc27b688c535b8fa4afb82146a4.tar.gz googletest-c8393f8554419dc27b688c535b8fa4afb82146a4.tar.bz2 |
Print mismatches for UnorderedElements() of different sizes.
Changes the behavior of UnorderedElements()/UnorderedElementsAreArray() to print items-without-matchers and matchers-without-items in the case where the actual and expected are different sizes.
PiperOrigin-RevId: 635451316
Change-Id: I2181bb28a14c14cdb577af9268d403e12e942bea
Diffstat (limited to 'googlemock/test')
-rw-r--r-- | googlemock/test/gmock-matchers-containers_test.cc | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/googlemock/test/gmock-matchers-containers_test.cc b/googlemock/test/gmock-matchers-containers_test.cc index 38fd9a5..acea4ec 100644 --- a/googlemock/test/gmock-matchers-containers_test.cc +++ b/googlemock/test/gmock-matchers-containers_test.cc @@ -2014,7 +2014,14 @@ TEST_F(UnorderedElementsAreTest, FailMessageCountWrong) { StringMatchResultListener listener; EXPECT_FALSE(ExplainMatchResult(UnorderedElementsAre(1, 2, 3), v, &listener)) << listener.str(); - EXPECT_THAT(listener.str(), Eq("which has 1 element")); + EXPECT_THAT(listener.str(), + Eq("which has 1 element\n" + "where the following matchers don't match any elements:\n" + "matcher #0: is equal to 1,\n" + "matcher #1: is equal to 2,\n" + "matcher #2: is equal to 3\n" + "and where the following elements don't match any matchers:\n" + "element #0: 4")); } TEST_F(UnorderedElementsAreTest, FailMessageCountWrongZero) { @@ -2022,7 +2029,11 @@ TEST_F(UnorderedElementsAreTest, FailMessageCountWrongZero) { StringMatchResultListener listener; EXPECT_FALSE(ExplainMatchResult(UnorderedElementsAre(1, 2, 3), v, &listener)) << listener.str(); - EXPECT_THAT(listener.str(), Eq("")); + EXPECT_THAT(listener.str(), + Eq("where the following matchers don't match any elements:\n" + "matcher #0: is equal to 1,\n" + "matcher #1: is equal to 2,\n" + "matcher #2: is equal to 3")); } TEST_F(UnorderedElementsAreTest, FailMessageUnmatchedMatchers) { @@ -2438,7 +2449,7 @@ TEST(UnorderedPointwiseTest, RejectsWrongSize) { const double lhs[2] = {1, 2}; const int rhs[1] = {0}; EXPECT_THAT(lhs, Not(UnorderedPointwise(Gt(), rhs))); - EXPECT_EQ("which has 2 elements", + EXPECT_EQ("which has 2 elements\n", Explain(UnorderedPointwise(Gt(), rhs), lhs)); const int rhs2[3] = {0, 1, 2}; |