diff options
author | Abseil Team <absl-team@google.com> | 2024-07-15 23:39:22 (GMT) |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-07-15 23:40:10 (GMT) |
commit | 417158b8bca158426cbdc0c547fdd7d9fbd46904 (patch) | |
tree | 0f54c544e638ff7720864b76e7f4623aa8812c23 /googlemock/test | |
parent | 7321f950dfe0d481b56b1c475e38b681ff34263f (diff) | |
download | googletest-417158b8bca158426cbdc0c547fdd7d9fbd46904.zip googletest-417158b8bca158426cbdc0c547fdd7d9fbd46904.tar.gz googletest-417158b8bca158426cbdc0c547fdd7d9fbd46904.tar.bz2 |
Use matcher's description in AllOf if matcher has no explanation.
PiperOrigin-RevId: 652634229
Change-Id: I5fd7eaef4db3dea3d4142e1fb5fc97e46f654358
Diffstat (limited to 'googlemock/test')
-rw-r--r-- | googlemock/test/gmock-matchers-arithmetic_test.cc | 14 | ||||
-rw-r--r-- | googlemock/test/gmock-matchers-comparisons_test.cc | 4 |
2 files changed, 10 insertions, 8 deletions
diff --git a/googlemock/test/gmock-matchers-arithmetic_test.cc b/googlemock/test/gmock-matchers-arithmetic_test.cc index f176962..7521c0d 100644 --- a/googlemock/test/gmock-matchers-arithmetic_test.cc +++ b/googlemock/test/gmock-matchers-arithmetic_test.cc @@ -559,10 +559,9 @@ TEST_P(AllOfTestP, ExplainsResult) { Matcher<int> m; // Successful match. Both matchers need to explain. The second - // matcher doesn't give an explanation, so only the first matcher's - // explanation is printed. + // matcher doesn't give an explanation, so the matcher description is used. m = AllOf(GreaterThan(10), Lt(30)); - EXPECT_EQ("which is 15 more than 10", Explain(m, 25)); + EXPECT_EQ("which is 15 more than 10, and is < 30", Explain(m, 25)); // Successful match. Both matchers need to explain. m = AllOf(GreaterThan(10), GreaterThan(20)); @@ -572,8 +571,9 @@ TEST_P(AllOfTestP, ExplainsResult) { // Successful match. All matchers need to explain. The second // matcher doesn't given an explanation. m = AllOf(GreaterThan(10), Lt(30), GreaterThan(20)); - EXPECT_EQ("which is 15 more than 10, and which is 5 more than 20", - Explain(m, 25)); + EXPECT_EQ( + "which is 15 more than 10, and is < 30, and which is 5 more than 20", + Explain(m, 25)); // Successful match. All matchers need to explain. m = AllOf(GreaterThan(10), GreaterThan(20), GreaterThan(30)); @@ -588,10 +588,10 @@ TEST_P(AllOfTestP, ExplainsResult) { EXPECT_EQ("which is 5 less than 10", Explain(m, 5)); // Failed match. The second matcher, which failed, needs to - // explain. Since it doesn't given an explanation, nothing is + // explain. Since it doesn't given an explanation, the matcher text is // printed. m = AllOf(GreaterThan(10), Lt(30)); - EXPECT_EQ("", Explain(m, 40)); + EXPECT_EQ("which doesn't match (is < 30)", Explain(m, 40)); // Failed match. The second matcher, which failed, needs to // explain. diff --git a/googlemock/test/gmock-matchers-comparisons_test.cc b/googlemock/test/gmock-matchers-comparisons_test.cc index 5b75b45..9881155 100644 --- a/googlemock/test/gmock-matchers-comparisons_test.cc +++ b/googlemock/test/gmock-matchers-comparisons_test.cc @@ -2334,9 +2334,11 @@ TEST(ExplainMatchResultTest, AllOf_True_True) { EXPECT_EQ("which is 0 modulo 2, and which is 0 modulo 3", Explain(m, 6)); } +// Tests that when AllOf() succeeds, but matchers have no explanation, +// the matcher description is used. TEST(ExplainMatchResultTest, AllOf_True_True_2) { const Matcher<int> m = AllOf(Ge(2), Le(3)); - EXPECT_EQ("", Explain(m, 2)); + EXPECT_EQ("is >= 2, and is <= 3", Explain(m, 2)); } INSTANTIATE_GTEST_MATCHER_TEST_P(ExplainmatcherResultTest); |