Use matcher's description in AllOf if matcher has no explanation.

PiperOrigin-RevId: 655569834
Change-Id: Ia760d74d1cdde766e9719864c5e19c0159da3128
This commit is contained in:
Abseil Team
2024-07-24 08:07:22 -07:00
committed by Copybara-Service
parent 352788321f
commit 5bcb2d78a1
3 changed files with 39 additions and 23 deletions

View File

@@ -2333,9 +2333,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);