Skip to content

Commit 1f643f7

Browse files
Abseil Teamcopybara-github
authored andcommitted
Make SizeIsMatcher::Impl conform to the contract of MatcherDescriberInterface.
MatcherDescriberInterface specifies that DescribeTo "should print a verb phrase", but "size ..." is not a verb phrase. Currently, ElementsAre(SizeIs(9)) is described as "has 1 element that size is equal to 9". With this change, it will be described as "has 1 element that has a size that is equal to 9". PiperOrigin-RevId: 492022324 Change-Id: I4083335f2419462464957521c1e033643b53b763
1 parent a16bfcf commit 1f643f7

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

googlemock/include/gmock/gmock-matchers.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2309,11 +2309,11 @@ class SizeIsMatcher {
23092309
: size_matcher_(MatcherCast<SizeType>(size_matcher)) {}
23102310

23112311
void DescribeTo(::std::ostream* os) const override {
2312-
*os << "size ";
2312+
*os << "has a size that ";
23132313
size_matcher_.DescribeTo(os);
23142314
}
23152315
void DescribeNegationTo(::std::ostream* os) const override {
2316-
*os << "size ";
2316+
*os << "has a size that ";
23172317
size_matcher_.DescribeNegationTo(os);
23182318
}
23192319

googlemock/test/gmock-matchers-containers_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,8 +1182,8 @@ TEST(SizeIsTest, WorksWithMinimalistCustomType) {
11821182

11831183
TEST(SizeIsTest, CanDescribeSelf) {
11841184
Matcher<vector<int>> m = SizeIs(2);
1185-
EXPECT_EQ("size is equal to 2", Describe(m));
1186-
EXPECT_EQ("size isn't equal to 2", DescribeNegation(m));
1185+
EXPECT_EQ("has a size that is equal to 2", Describe(m));
1186+
EXPECT_EQ("has a size that isn't equal to 2", DescribeNegation(m));
11871187
}
11881188

11891189
TEST(SizeIsTest, ExplainsResult) {

0 commit comments

Comments
 (0)