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

PiperOrigin-RevId: 652634229
Change-Id: I5fd7eaef4db3dea3d4142e1fb5fc97e46f654358
This commit is contained in:
Abseil Team
2024-07-15 16:39:22 -07:00
committed by Copybara-Service
parent 7321f950df
commit 417158b8bc
3 changed files with 39 additions and 23 deletions

View File

@@ -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);