Skip to content

Commit 129dedd

Browse files
author
zhanyong.wan
committed
Improves matcher messages across the board.
git-svn-id: http://googlemock.googlecode.com/svn/trunk@279 8415998a-534a-0410-bf83-d39667b30386
1 parent 3828e64 commit 129dedd

7 files changed

+504
-245
lines changed

include/gmock/gmock-generated-matchers.h

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
// This file was GENERATED by a script. DO NOT EDIT BY HAND!!!
1+
// This file was GENERATED by command:
2+
// pump.py gmock-generated-matchers.h.pump
3+
// DO NOT EDIT BY HAND!!!
24

35
// Copyright 2008, Google Inc.
46
// All rights reserved.
@@ -231,15 +233,28 @@ class ArgsMatcherImpl : public MatcherInterface<ArgsTuple> {
231233

232234
virtual bool MatchAndExplain(ArgsTuple args,
233235
MatchResultListener* listener) const {
234-
return inner_matcher_.MatchAndExplain(GetSelectedArgs(args), listener);
236+
const SelectedArgs& selected_args = GetSelectedArgs(args);
237+
if (!listener->IsInterested())
238+
return inner_matcher_.Matches(selected_args);
239+
240+
PrintIndices(listener->stream());
241+
*listener << "are " << PrintToString(selected_args);
242+
243+
StringMatchResultListener inner_listener;
244+
const bool match = inner_matcher_.MatchAndExplain(selected_args,
245+
&inner_listener);
246+
PrintIfNotEmpty(inner_listener.str(), listener->stream());
247+
return match;
235248
}
236249

237250
virtual void DescribeTo(::std::ostream* os) const {
251+
*os << "are a tuple ";
238252
PrintIndices(os);
239253
inner_matcher_.DescribeTo(os);
240254
}
241255

242256
virtual void DescribeNegationTo(::std::ostream* os) const {
257+
*os << "are a tuple ";
243258
PrintIndices(os);
244259
inner_matcher_.DescribeNegationTo(os);
245260
}
@@ -252,7 +267,7 @@ class ArgsMatcherImpl : public MatcherInterface<ArgsTuple> {
252267

253268
// Prints the indices of the selected fields.
254269
static void PrintIndices(::std::ostream* os) {
255-
*os << "are a tuple whose fields (";
270+
*os << "whose fields (";
256271
const int indices[10] = { k0, k1, k2, k3, k4, k5, k6, k7, k8, k9 };
257272
for (int i = 0; i < 10; i++) {
258273
if (indices[i] < 0)

include/gmock/gmock-generated-matchers.h.pump

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,28 @@ class ArgsMatcherImpl : public MatcherInterface<ArgsTuple> {
118118

119119
virtual bool MatchAndExplain(ArgsTuple args,
120120
MatchResultListener* listener) const {
121-
return inner_matcher_.MatchAndExplain(GetSelectedArgs(args), listener);
121+
const SelectedArgs& selected_args = GetSelectedArgs(args);
122+
if (!listener->IsInterested())
123+
return inner_matcher_.Matches(selected_args);
124+
125+
PrintIndices(listener->stream());
126+
*listener << "are " << PrintToString(selected_args);
127+
128+
StringMatchResultListener inner_listener;
129+
const bool match = inner_matcher_.MatchAndExplain(selected_args,
130+
&inner_listener);
131+
PrintIfNotEmpty(inner_listener.str(), listener->stream());
132+
return match;
122133
}
123134

124135
virtual void DescribeTo(::std::ostream* os) const {
136+
*os << "are a tuple ";
125137
PrintIndices(os);
126138
inner_matcher_.DescribeTo(os);
127139
}
128140

129141
virtual void DescribeNegationTo(::std::ostream* os) const {
142+
*os << "are a tuple ";
130143
PrintIndices(os);
131144
inner_matcher_.DescribeNegationTo(os);
132145
}
@@ -138,7 +151,7 @@ class ArgsMatcherImpl : public MatcherInterface<ArgsTuple> {
138151

139152
// Prints the indices of the selected fields.
140153
static void PrintIndices(::std::ostream* os) {
141-
*os << "are a tuple whose fields (";
154+
*os << "whose fields (";
142155
const int indices[$n] = { $ks };
143156
for (int i = 0; i < $n; i++) {
144157
if (indices[i] < 0)

0 commit comments

Comments
 (0)