blob: 90f3750e9fd06799b74993079cd04e2cb83ec086 [file] [log] [blame]
zhanyong.wanb1c7f932010-03-24 17:35:11 +00001// This file was GENERATED by command:
2// pump.py gmock-generated-matchers.h.pump
3// DO NOT EDIT BY HAND!!!
shiqiane35fdd92008-12-10 05:08:54 +00004
5// Copyright 2008, Google Inc.
6// All rights reserved.
7//
8// Redistribution and use in source and binary forms, with or without
9// modification, are permitted provided that the following conditions are
10// met:
11//
12// * Redistributions of source code must retain the above copyright
13// notice, this list of conditions and the following disclaimer.
14// * Redistributions in binary form must reproduce the above
15// copyright notice, this list of conditions and the following disclaimer
16// in the documentation and/or other materials provided with the
17// distribution.
18// * Neither the name of Google Inc. nor the names of its
19// contributors may be used to endorse or promote products derived from
20// this software without specific prior written permission.
21//
22// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
34// Google Mock - a framework for writing C++ mock classes.
35//
36// This file implements some commonly used variadic matchers.
37
38#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
39#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
40
41#include <sstream>
42#include <string>
43#include <vector>
44#include <gmock/gmock-matchers.h>
45
46namespace testing {
47namespace internal {
48
zhanyong.wan2661c682009-06-09 05:42:12 +000049// The type of the i-th (0-based) field of Tuple.
50#define GMOCK_FIELD_TYPE_(Tuple, i) \
51 typename ::std::tr1::tuple_element<i, Tuple>::type
52
53// TupleFields<Tuple, k0, ..., kn> is for selecting fields from a
54// tuple of type Tuple. It has two members:
55//
56// type: a tuple type whose i-th field is the ki-th field of Tuple.
57// GetSelectedFields(t): returns fields k0, ..., and kn of t as a tuple.
58//
59// For example, in class TupleFields<tuple<bool, char, int>, 2, 0>, we have:
60//
61// type is tuple<int, bool>, and
62// GetSelectedFields(make_tuple(true, 'a', 42)) is (42, true).
63
64template <class Tuple, int k0 = -1, int k1 = -1, int k2 = -1, int k3 = -1,
65 int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
66 int k9 = -1>
67class TupleFields;
68
69// This generic version is used when there are 10 selectors.
70template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
71 int k7, int k8, int k9>
72class TupleFields {
73 public:
74 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
75 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
76 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
77 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
78 GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8),
79 GMOCK_FIELD_TYPE_(Tuple, k9)> type;
80 static type GetSelectedFields(const Tuple& t) {
81 using ::std::tr1::get;
82 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
83 get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t), get<k9>(t));
84 }
85};
86
87// The following specialization is used for 0 ~ 9 selectors.
88
89template <class Tuple>
90class TupleFields<Tuple, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
91 public:
92 typedef ::std::tr1::tuple<> type;
zhanyong.wan32de5f52009-12-23 00:13:23 +000093 static type GetSelectedFields(const Tuple& /* t */) {
zhanyong.wan2661c682009-06-09 05:42:12 +000094 using ::std::tr1::get;
95 return type();
96 }
97};
98
99template <class Tuple, int k0>
100class TupleFields<Tuple, k0, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
101 public:
102 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0)> type;
103 static type GetSelectedFields(const Tuple& t) {
104 using ::std::tr1::get;
105 return type(get<k0>(t));
106 }
107};
108
109template <class Tuple, int k0, int k1>
110class TupleFields<Tuple, k0, k1, -1, -1, -1, -1, -1, -1, -1, -1> {
111 public:
112 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
113 GMOCK_FIELD_TYPE_(Tuple, k1)> type;
114 static type GetSelectedFields(const Tuple& t) {
115 using ::std::tr1::get;
116 return type(get<k0>(t), get<k1>(t));
117 }
118};
119
120template <class Tuple, int k0, int k1, int k2>
121class TupleFields<Tuple, k0, k1, k2, -1, -1, -1, -1, -1, -1, -1> {
122 public:
123 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
124 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2)> type;
125 static type GetSelectedFields(const Tuple& t) {
126 using ::std::tr1::get;
127 return type(get<k0>(t), get<k1>(t), get<k2>(t));
128 }
129};
130
131template <class Tuple, int k0, int k1, int k2, int k3>
132class TupleFields<Tuple, k0, k1, k2, k3, -1, -1, -1, -1, -1, -1> {
133 public:
134 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
135 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
136 GMOCK_FIELD_TYPE_(Tuple, k3)> type;
137 static type GetSelectedFields(const Tuple& t) {
138 using ::std::tr1::get;
139 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t));
140 }
141};
142
143template <class Tuple, int k0, int k1, int k2, int k3, int k4>
144class TupleFields<Tuple, k0, k1, k2, k3, k4, -1, -1, -1, -1, -1> {
145 public:
146 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
147 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
148 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4)> type;
149 static type GetSelectedFields(const Tuple& t) {
150 using ::std::tr1::get;
151 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t));
152 }
153};
154
155template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5>
156class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, -1, -1, -1, -1> {
157 public:
158 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
159 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
160 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
161 GMOCK_FIELD_TYPE_(Tuple, k5)> type;
162 static type GetSelectedFields(const Tuple& t) {
163 using ::std::tr1::get;
164 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
165 get<k5>(t));
166 }
167};
168
169template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6>
170class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, -1, -1, -1> {
171 public:
172 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
173 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
174 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
175 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6)> type;
176 static type GetSelectedFields(const Tuple& t) {
177 using ::std::tr1::get;
178 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
179 get<k5>(t), get<k6>(t));
180 }
181};
182
183template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
184 int k7>
185class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, -1, -1> {
186 public:
187 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
188 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
189 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
190 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
191 GMOCK_FIELD_TYPE_(Tuple, k7)> type;
192 static type GetSelectedFields(const Tuple& t) {
193 using ::std::tr1::get;
194 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
195 get<k5>(t), get<k6>(t), get<k7>(t));
196 }
197};
198
199template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
200 int k7, int k8>
201class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, k8, -1> {
202 public:
203 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
204 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
205 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
206 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
207 GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8)> type;
208 static type GetSelectedFields(const Tuple& t) {
209 using ::std::tr1::get;
210 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
211 get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t));
212 }
213};
214
215#undef GMOCK_FIELD_TYPE_
216
217// Implements the Args() matcher.
218template <class ArgsTuple, int k0 = -1, int k1 = -1, int k2 = -1, int k3 = -1,
219 int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
220 int k9 = -1>
221class ArgsMatcherImpl : public MatcherInterface<ArgsTuple> {
222 public:
223 // ArgsTuple may have top-level const or reference modifiers.
zhanyong.wan02f71062010-05-10 17:14:29 +0000224 typedef GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(ArgsTuple)) RawArgsTuple;
zhanyong.wan2661c682009-06-09 05:42:12 +0000225 typedef typename internal::TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5,
226 k6, k7, k8, k9>::type SelectedArgs;
227 typedef Matcher<const SelectedArgs&> MonomorphicInnerMatcher;
228
229 template <typename InnerMatcher>
230 explicit ArgsMatcherImpl(const InnerMatcher& inner_matcher)
231 : inner_matcher_(SafeMatcherCast<const SelectedArgs&>(inner_matcher)) {}
232
zhanyong.wan82113312010-01-08 21:55:40 +0000233 virtual bool MatchAndExplain(ArgsTuple args,
234 MatchResultListener* listener) const {
zhanyong.wanb1c7f932010-03-24 17:35:11 +0000235 const SelectedArgs& selected_args = GetSelectedArgs(args);
236 if (!listener->IsInterested())
237 return inner_matcher_.Matches(selected_args);
238
239 PrintIndices(listener->stream());
240 *listener << "are " << PrintToString(selected_args);
241
242 StringMatchResultListener inner_listener;
243 const bool match = inner_matcher_.MatchAndExplain(selected_args,
244 &inner_listener);
245 PrintIfNotEmpty(inner_listener.str(), listener->stream());
246 return match;
zhanyong.wan2661c682009-06-09 05:42:12 +0000247 }
248
249 virtual void DescribeTo(::std::ostream* os) const {
zhanyong.wanb1c7f932010-03-24 17:35:11 +0000250 *os << "are a tuple ";
zhanyong.wan2661c682009-06-09 05:42:12 +0000251 PrintIndices(os);
252 inner_matcher_.DescribeTo(os);
253 }
254
255 virtual void DescribeNegationTo(::std::ostream* os) const {
zhanyong.wanb1c7f932010-03-24 17:35:11 +0000256 *os << "are a tuple ";
zhanyong.wan2661c682009-06-09 05:42:12 +0000257 PrintIndices(os);
258 inner_matcher_.DescribeNegationTo(os);
259 }
260
zhanyong.wan2661c682009-06-09 05:42:12 +0000261 private:
262 static SelectedArgs GetSelectedArgs(ArgsTuple args) {
263 return TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5, k6, k7, k8,
264 k9>::GetSelectedFields(args);
265 }
266
267 // Prints the indices of the selected fields.
268 static void PrintIndices(::std::ostream* os) {
zhanyong.wanb1c7f932010-03-24 17:35:11 +0000269 *os << "whose fields (";
zhanyong.wan2661c682009-06-09 05:42:12 +0000270 const int indices[10] = { k0, k1, k2, k3, k4, k5, k6, k7, k8, k9 };
271 for (int i = 0; i < 10; i++) {
272 if (indices[i] < 0)
273 break;
274
275 if (i >= 1)
276 *os << ", ";
277
278 *os << "#" << indices[i];
279 }
280 *os << ") ";
281 }
282
283 const MonomorphicInnerMatcher inner_matcher_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000284
285 GTEST_DISALLOW_ASSIGN_(ArgsMatcherImpl);
zhanyong.wan2661c682009-06-09 05:42:12 +0000286};
287
288template <class InnerMatcher, int k0 = -1, int k1 = -1, int k2 = -1,
289 int k3 = -1, int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1,
290 int k8 = -1, int k9 = -1>
291class ArgsMatcher {
292 public:
293 explicit ArgsMatcher(const InnerMatcher& inner_matcher)
294 : inner_matcher_(inner_matcher) {}
295
296 template <typename ArgsTuple>
297 operator Matcher<ArgsTuple>() const {
298 return MakeMatcher(new ArgsMatcherImpl<ArgsTuple, k0, k1, k2, k3, k4, k5,
299 k6, k7, k8, k9>(inner_matcher_));
300 }
301
zhanyong.wan32de5f52009-12-23 00:13:23 +0000302 private:
zhanyong.wan2661c682009-06-09 05:42:12 +0000303 const InnerMatcher inner_matcher_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000304
305 GTEST_DISALLOW_ASSIGN_(ArgsMatcher);
zhanyong.wan2661c682009-06-09 05:42:12 +0000306};
307
zhanyong.wan1afe1c72009-07-21 23:26:31 +0000308// Implements ElementsAre() of 1-10 arguments.
shiqiane35fdd92008-12-10 05:08:54 +0000309
310template <typename T1>
311class ElementsAreMatcher1 {
312 public:
313 explicit ElementsAreMatcher1(const T1& e1) : e1_(e1) {}
314
315 template <typename Container>
316 operator Matcher<Container>() const {
zhanyong.wan02f71062010-05-10 17:14:29 +0000317 typedef GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(Container))
zhanyong.wane0d051e2009-02-19 00:33:37 +0000318 RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000319 typedef typename internal::StlContainerView<RawContainer>::type::value_type
320 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000321
zhanyong.wan95b12332009-09-25 18:55:50 +0000322 // Nokia's Symbian Compiler has a nasty bug where the object put
323 // in a one-element local array is not destructed when the array
324 // goes out of scope. This leads to obvious badness as we've
325 // added the linked_ptr in it to our other linked_ptrs list.
326 // Hence we implement ElementsAreMatcher1 specially to avoid using
327 // a local array.
328 const Matcher<const Element&> matcher =
329 MatcherCast<const Element&>(e1_);
330 return MakeMatcher(new ElementsAreMatcherImpl<Container>(&matcher, 1));
shiqiane35fdd92008-12-10 05:08:54 +0000331 }
332
333 private:
334 const T1& e1_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000335
336 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher1);
shiqiane35fdd92008-12-10 05:08:54 +0000337};
338
339template <typename T1, typename T2>
340class ElementsAreMatcher2 {
341 public:
342 ElementsAreMatcher2(const T1& e1, const T2& e2) : e1_(e1), e2_(e2) {}
343
344 template <typename Container>
345 operator Matcher<Container>() const {
zhanyong.wan02f71062010-05-10 17:14:29 +0000346 typedef GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(Container))
zhanyong.wane0d051e2009-02-19 00:33:37 +0000347 RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000348 typedef typename internal::StlContainerView<RawContainer>::type::value_type
349 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000350
351 const Matcher<const Element&> matchers[] = {
352 MatcherCast<const Element&>(e1_),
353 MatcherCast<const Element&>(e2_),
354 };
355
356 return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 2));
357 }
358
359 private:
360 const T1& e1_;
361 const T2& e2_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000362
363 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher2);
shiqiane35fdd92008-12-10 05:08:54 +0000364};
365
366template <typename T1, typename T2, typename T3>
367class ElementsAreMatcher3 {
368 public:
369 ElementsAreMatcher3(const T1& e1, const T2& e2, const T3& e3) : e1_(e1),
370 e2_(e2), e3_(e3) {}
371
372 template <typename Container>
373 operator Matcher<Container>() const {
zhanyong.wan02f71062010-05-10 17:14:29 +0000374 typedef GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(Container))
zhanyong.wane0d051e2009-02-19 00:33:37 +0000375 RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000376 typedef typename internal::StlContainerView<RawContainer>::type::value_type
377 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000378
379 const Matcher<const Element&> matchers[] = {
380 MatcherCast<const Element&>(e1_),
381 MatcherCast<const Element&>(e2_),
382 MatcherCast<const Element&>(e3_),
383 };
384
385 return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 3));
386 }
387
388 private:
389 const T1& e1_;
390 const T2& e2_;
391 const T3& e3_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000392
393 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher3);
shiqiane35fdd92008-12-10 05:08:54 +0000394};
395
396template <typename T1, typename T2, typename T3, typename T4>
397class ElementsAreMatcher4 {
398 public:
399 ElementsAreMatcher4(const T1& e1, const T2& e2, const T3& e3,
400 const T4& e4) : e1_(e1), e2_(e2), e3_(e3), e4_(e4) {}
401
402 template <typename Container>
403 operator Matcher<Container>() const {
zhanyong.wan02f71062010-05-10 17:14:29 +0000404 typedef GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(Container))
zhanyong.wane0d051e2009-02-19 00:33:37 +0000405 RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000406 typedef typename internal::StlContainerView<RawContainer>::type::value_type
407 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000408
409 const Matcher<const Element&> matchers[] = {
410 MatcherCast<const Element&>(e1_),
411 MatcherCast<const Element&>(e2_),
412 MatcherCast<const Element&>(e3_),
413 MatcherCast<const Element&>(e4_),
414 };
415
416 return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 4));
417 }
418
419 private:
420 const T1& e1_;
421 const T2& e2_;
422 const T3& e3_;
423 const T4& e4_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000424
425 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher4);
shiqiane35fdd92008-12-10 05:08:54 +0000426};
427
428template <typename T1, typename T2, typename T3, typename T4, typename T5>
429class ElementsAreMatcher5 {
430 public:
431 ElementsAreMatcher5(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
432 const T5& e5) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5) {}
433
434 template <typename Container>
435 operator Matcher<Container>() const {
zhanyong.wan02f71062010-05-10 17:14:29 +0000436 typedef GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(Container))
zhanyong.wane0d051e2009-02-19 00:33:37 +0000437 RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000438 typedef typename internal::StlContainerView<RawContainer>::type::value_type
439 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000440
441 const Matcher<const Element&> matchers[] = {
442 MatcherCast<const Element&>(e1_),
443 MatcherCast<const Element&>(e2_),
444 MatcherCast<const Element&>(e3_),
445 MatcherCast<const Element&>(e4_),
446 MatcherCast<const Element&>(e5_),
447 };
448
449 return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 5));
450 }
451
452 private:
453 const T1& e1_;
454 const T2& e2_;
455 const T3& e3_;
456 const T4& e4_;
457 const T5& e5_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000458
459 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher5);
shiqiane35fdd92008-12-10 05:08:54 +0000460};
461
462template <typename T1, typename T2, typename T3, typename T4, typename T5,
463 typename T6>
464class ElementsAreMatcher6 {
465 public:
466 ElementsAreMatcher6(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
467 const T5& e5, const T6& e6) : e1_(e1), e2_(e2), e3_(e3), e4_(e4),
468 e5_(e5), e6_(e6) {}
469
470 template <typename Container>
471 operator Matcher<Container>() const {
zhanyong.wan02f71062010-05-10 17:14:29 +0000472 typedef GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(Container))
zhanyong.wane0d051e2009-02-19 00:33:37 +0000473 RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000474 typedef typename internal::StlContainerView<RawContainer>::type::value_type
475 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000476
477 const Matcher<const Element&> matchers[] = {
478 MatcherCast<const Element&>(e1_),
479 MatcherCast<const Element&>(e2_),
480 MatcherCast<const Element&>(e3_),
481 MatcherCast<const Element&>(e4_),
482 MatcherCast<const Element&>(e5_),
483 MatcherCast<const Element&>(e6_),
484 };
485
486 return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 6));
487 }
488
489 private:
490 const T1& e1_;
491 const T2& e2_;
492 const T3& e3_;
493 const T4& e4_;
494 const T5& e5_;
495 const T6& e6_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000496
497 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher6);
shiqiane35fdd92008-12-10 05:08:54 +0000498};
499
500template <typename T1, typename T2, typename T3, typename T4, typename T5,
501 typename T6, typename T7>
502class ElementsAreMatcher7 {
503 public:
504 ElementsAreMatcher7(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
505 const T5& e5, const T6& e6, const T7& e7) : e1_(e1), e2_(e2), e3_(e3),
506 e4_(e4), e5_(e5), e6_(e6), e7_(e7) {}
507
508 template <typename Container>
509 operator Matcher<Container>() const {
zhanyong.wan02f71062010-05-10 17:14:29 +0000510 typedef GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(Container))
zhanyong.wane0d051e2009-02-19 00:33:37 +0000511 RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000512 typedef typename internal::StlContainerView<RawContainer>::type::value_type
513 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000514
515 const Matcher<const Element&> matchers[] = {
516 MatcherCast<const Element&>(e1_),
517 MatcherCast<const Element&>(e2_),
518 MatcherCast<const Element&>(e3_),
519 MatcherCast<const Element&>(e4_),
520 MatcherCast<const Element&>(e5_),
521 MatcherCast<const Element&>(e6_),
522 MatcherCast<const Element&>(e7_),
523 };
524
525 return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 7));
526 }
527
528 private:
529 const T1& e1_;
530 const T2& e2_;
531 const T3& e3_;
532 const T4& e4_;
533 const T5& e5_;
534 const T6& e6_;
535 const T7& e7_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000536
537 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher7);
shiqiane35fdd92008-12-10 05:08:54 +0000538};
539
540template <typename T1, typename T2, typename T3, typename T4, typename T5,
541 typename T6, typename T7, typename T8>
542class ElementsAreMatcher8 {
543 public:
544 ElementsAreMatcher8(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
545 const T5& e5, const T6& e6, const T7& e7, const T8& e8) : e1_(e1),
546 e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6), e7_(e7), e8_(e8) {}
547
548 template <typename Container>
549 operator Matcher<Container>() const {
zhanyong.wan02f71062010-05-10 17:14:29 +0000550 typedef GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(Container))
zhanyong.wane0d051e2009-02-19 00:33:37 +0000551 RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000552 typedef typename internal::StlContainerView<RawContainer>::type::value_type
553 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000554
555 const Matcher<const Element&> matchers[] = {
556 MatcherCast<const Element&>(e1_),
557 MatcherCast<const Element&>(e2_),
558 MatcherCast<const Element&>(e3_),
559 MatcherCast<const Element&>(e4_),
560 MatcherCast<const Element&>(e5_),
561 MatcherCast<const Element&>(e6_),
562 MatcherCast<const Element&>(e7_),
563 MatcherCast<const Element&>(e8_),
564 };
565
566 return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 8));
567 }
568
569 private:
570 const T1& e1_;
571 const T2& e2_;
572 const T3& e3_;
573 const T4& e4_;
574 const T5& e5_;
575 const T6& e6_;
576 const T7& e7_;
577 const T8& e8_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000578
579 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher8);
shiqiane35fdd92008-12-10 05:08:54 +0000580};
581
582template <typename T1, typename T2, typename T3, typename T4, typename T5,
583 typename T6, typename T7, typename T8, typename T9>
584class ElementsAreMatcher9 {
585 public:
586 ElementsAreMatcher9(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
587 const T5& e5, const T6& e6, const T7& e7, const T8& e8,
588 const T9& e9) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6),
589 e7_(e7), e8_(e8), e9_(e9) {}
590
591 template <typename Container>
592 operator Matcher<Container>() const {
zhanyong.wan02f71062010-05-10 17:14:29 +0000593 typedef GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(Container))
zhanyong.wane0d051e2009-02-19 00:33:37 +0000594 RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000595 typedef typename internal::StlContainerView<RawContainer>::type::value_type
596 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000597
598 const Matcher<const Element&> matchers[] = {
599 MatcherCast<const Element&>(e1_),
600 MatcherCast<const Element&>(e2_),
601 MatcherCast<const Element&>(e3_),
602 MatcherCast<const Element&>(e4_),
603 MatcherCast<const Element&>(e5_),
604 MatcherCast<const Element&>(e6_),
605 MatcherCast<const Element&>(e7_),
606 MatcherCast<const Element&>(e8_),
607 MatcherCast<const Element&>(e9_),
608 };
609
610 return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 9));
611 }
612
613 private:
614 const T1& e1_;
615 const T2& e2_;
616 const T3& e3_;
617 const T4& e4_;
618 const T5& e5_;
619 const T6& e6_;
620 const T7& e7_;
621 const T8& e8_;
622 const T9& e9_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000623
624 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher9);
shiqiane35fdd92008-12-10 05:08:54 +0000625};
626
627template <typename T1, typename T2, typename T3, typename T4, typename T5,
628 typename T6, typename T7, typename T8, typename T9, typename T10>
629class ElementsAreMatcher10 {
630 public:
631 ElementsAreMatcher10(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
632 const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,
633 const T10& e10) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6),
634 e7_(e7), e8_(e8), e9_(e9), e10_(e10) {}
635
636 template <typename Container>
637 operator Matcher<Container>() const {
zhanyong.wan02f71062010-05-10 17:14:29 +0000638 typedef GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(Container))
zhanyong.wane0d051e2009-02-19 00:33:37 +0000639 RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000640 typedef typename internal::StlContainerView<RawContainer>::type::value_type
641 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000642
643 const Matcher<const Element&> matchers[] = {
644 MatcherCast<const Element&>(e1_),
645 MatcherCast<const Element&>(e2_),
646 MatcherCast<const Element&>(e3_),
647 MatcherCast<const Element&>(e4_),
648 MatcherCast<const Element&>(e5_),
649 MatcherCast<const Element&>(e6_),
650 MatcherCast<const Element&>(e7_),
651 MatcherCast<const Element&>(e8_),
652 MatcherCast<const Element&>(e9_),
653 MatcherCast<const Element&>(e10_),
654 };
655
656 return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 10));
657 }
658
659 private:
660 const T1& e1_;
661 const T2& e2_;
662 const T3& e3_;
663 const T4& e4_;
664 const T5& e5_;
665 const T6& e6_;
666 const T7& e7_;
667 const T8& e8_;
668 const T9& e9_;
669 const T10& e10_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000670
671 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher10);
shiqiane35fdd92008-12-10 05:08:54 +0000672};
673
shiqiane35fdd92008-12-10 05:08:54 +0000674} // namespace internal
675
zhanyong.wan2661c682009-06-09 05:42:12 +0000676// Args<N1, N2, ..., Nk>(a_matcher) matches a tuple if the selected
677// fields of it matches a_matcher. C++ doesn't support default
678// arguments for function templates, so we have to overload it.
679template <typename InnerMatcher>
680inline internal::ArgsMatcher<InnerMatcher>
681Args(const InnerMatcher& matcher) {
682 return internal::ArgsMatcher<InnerMatcher>(matcher);
683}
684
685template <int k1, typename InnerMatcher>
686inline internal::ArgsMatcher<InnerMatcher, k1>
687Args(const InnerMatcher& matcher) {
688 return internal::ArgsMatcher<InnerMatcher, k1>(matcher);
689}
690
691template <int k1, int k2, typename InnerMatcher>
692inline internal::ArgsMatcher<InnerMatcher, k1, k2>
693Args(const InnerMatcher& matcher) {
694 return internal::ArgsMatcher<InnerMatcher, k1, k2>(matcher);
695}
696
697template <int k1, int k2, int k3, typename InnerMatcher>
698inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3>
699Args(const InnerMatcher& matcher) {
700 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3>(matcher);
701}
702
703template <int k1, int k2, int k3, int k4, typename InnerMatcher>
704inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>
705Args(const InnerMatcher& matcher) {
706 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>(matcher);
707}
708
709template <int k1, int k2, int k3, int k4, int k5, typename InnerMatcher>
710inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>
711Args(const InnerMatcher& matcher) {
712 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>(matcher);
713}
714
715template <int k1, int k2, int k3, int k4, int k5, int k6, typename InnerMatcher>
716inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>
717Args(const InnerMatcher& matcher) {
718 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>(matcher);
719}
720
721template <int k1, int k2, int k3, int k4, int k5, int k6, int k7,
722 typename InnerMatcher>
723inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7>
724Args(const InnerMatcher& matcher) {
725 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6,
726 k7>(matcher);
727}
728
729template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
730 typename InnerMatcher>
731inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8>
732Args(const InnerMatcher& matcher) {
733 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7,
734 k8>(matcher);
735}
736
737template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
738 int k9, typename InnerMatcher>
739inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9>
740Args(const InnerMatcher& matcher) {
741 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
742 k9>(matcher);
743}
744
745template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
746 int k9, int k10, typename InnerMatcher>
747inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9,
748 k10>
749Args(const InnerMatcher& matcher) {
750 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
751 k9, k10>(matcher);
752}
753
shiqiane35fdd92008-12-10 05:08:54 +0000754// ElementsAre(e0, e1, ..., e_n) matches an STL-style container with
755// (n + 1) elements, where the i-th element in the container must
756// match the i-th argument in the list. Each argument of
757// ElementsAre() can be either a value or a matcher. We support up to
758// 10 arguments.
759//
760// NOTE: Since ElementsAre() cares about the order of the elements, it
761// must not be used with containers whose elements's order is
762// undefined (e.g. hash_map).
763
764inline internal::ElementsAreMatcher0 ElementsAre() {
765 return internal::ElementsAreMatcher0();
766}
767
768template <typename T1>
769inline internal::ElementsAreMatcher1<T1> ElementsAre(const T1& e1) {
770 return internal::ElementsAreMatcher1<T1>(e1);
771}
772
773template <typename T1, typename T2>
774inline internal::ElementsAreMatcher2<T1, T2> ElementsAre(const T1& e1,
775 const T2& e2) {
776 return internal::ElementsAreMatcher2<T1, T2>(e1, e2);
777}
778
779template <typename T1, typename T2, typename T3>
780inline internal::ElementsAreMatcher3<T1, T2, T3> ElementsAre(const T1& e1,
781 const T2& e2, const T3& e3) {
782 return internal::ElementsAreMatcher3<T1, T2, T3>(e1, e2, e3);
783}
784
785template <typename T1, typename T2, typename T3, typename T4>
786inline internal::ElementsAreMatcher4<T1, T2, T3, T4> ElementsAre(const T1& e1,
787 const T2& e2, const T3& e3, const T4& e4) {
788 return internal::ElementsAreMatcher4<T1, T2, T3, T4>(e1, e2, e3, e4);
789}
790
791template <typename T1, typename T2, typename T3, typename T4, typename T5>
792inline internal::ElementsAreMatcher5<T1, T2, T3, T4,
793 T5> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
794 const T5& e5) {
795 return internal::ElementsAreMatcher5<T1, T2, T3, T4, T5>(e1, e2, e3, e4, e5);
796}
797
798template <typename T1, typename T2, typename T3, typename T4, typename T5,
799 typename T6>
800inline internal::ElementsAreMatcher6<T1, T2, T3, T4, T5,
801 T6> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
802 const T5& e5, const T6& e6) {
803 return internal::ElementsAreMatcher6<T1, T2, T3, T4, T5, T6>(e1, e2, e3, e4,
804 e5, e6);
805}
806
807template <typename T1, typename T2, typename T3, typename T4, typename T5,
808 typename T6, typename T7>
809inline internal::ElementsAreMatcher7<T1, T2, T3, T4, T5, T6,
810 T7> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
811 const T5& e5, const T6& e6, const T7& e7) {
812 return internal::ElementsAreMatcher7<T1, T2, T3, T4, T5, T6, T7>(e1, e2, e3,
813 e4, e5, e6, e7);
814}
815
816template <typename T1, typename T2, typename T3, typename T4, typename T5,
817 typename T6, typename T7, typename T8>
818inline internal::ElementsAreMatcher8<T1, T2, T3, T4, T5, T6, T7,
819 T8> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
820 const T5& e5, const T6& e6, const T7& e7, const T8& e8) {
821 return internal::ElementsAreMatcher8<T1, T2, T3, T4, T5, T6, T7, T8>(e1, e2,
822 e3, e4, e5, e6, e7, e8);
823}
824
825template <typename T1, typename T2, typename T3, typename T4, typename T5,
826 typename T6, typename T7, typename T8, typename T9>
827inline internal::ElementsAreMatcher9<T1, T2, T3, T4, T5, T6, T7, T8,
828 T9> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
829 const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9) {
830 return internal::ElementsAreMatcher9<T1, T2, T3, T4, T5, T6, T7, T8, T9>(e1,
831 e2, e3, e4, e5, e6, e7, e8, e9);
832}
833
834template <typename T1, typename T2, typename T3, typename T4, typename T5,
835 typename T6, typename T7, typename T8, typename T9, typename T10>
836inline internal::ElementsAreMatcher10<T1, T2, T3, T4, T5, T6, T7, T8, T9,
837 T10> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
838 const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,
839 const T10& e10) {
840 return internal::ElementsAreMatcher10<T1, T2, T3, T4, T5, T6, T7, T8, T9,
841 T10>(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10);
842}
843
844// ElementsAreArray(array) and ElementAreArray(array, count) are like
845// ElementsAre(), except that they take an array of values or
846// matchers. The former form infers the size of 'array', which must
847// be a static C-style array. In the latter form, 'array' can either
848// be a static array or a pointer to a dynamically created array.
849
850template <typename T>
851inline internal::ElementsAreArrayMatcher<T> ElementsAreArray(
852 const T* first, size_t count) {
853 return internal::ElementsAreArrayMatcher<T>(first, count);
854}
855
856template <typename T, size_t N>
857inline internal::ElementsAreArrayMatcher<T>
858ElementsAreArray(const T (&array)[N]) {
859 return internal::ElementsAreArrayMatcher<T>(array, N);
860}
861
862} // namespace testing
863
zhanyong.wance198ff2009-02-12 01:34:27 +0000864// The MATCHER* family of macros can be used in a namespace scope to
zhanyong.wan82113312010-01-08 21:55:40 +0000865// define custom matchers easily.
866//
867// Basic Usage
868// ===========
869//
870// The syntax
zhanyong.wance198ff2009-02-12 01:34:27 +0000871//
872// MATCHER(name, description_string) { statements; }
873//
zhanyong.wan82113312010-01-08 21:55:40 +0000874// defines a matcher with the given name that executes the statements,
875// which must return a bool to indicate if the match succeeds. Inside
876// the statements, you can refer to the value being matched by 'arg',
877// and refer to its type by 'arg_type'.
zhanyong.wan4a5330d2009-02-19 00:36:44 +0000878//
879// The description string documents what the matcher does, and is used
880// to generate the failure message when the match fails. Since a
881// MATCHER() is usually defined in a header file shared by multiple
882// C++ source files, we require the description to be a C-string
883// literal to avoid possible side effects. It can be empty, in which
884// case we'll use the sequence of words in the matcher name as the
885// description.
886//
887// For example:
zhanyong.wance198ff2009-02-12 01:34:27 +0000888//
889// MATCHER(IsEven, "") { return (arg % 2) == 0; }
890//
891// allows you to write
892//
893// // Expects mock_foo.Bar(n) to be called where n is even.
894// EXPECT_CALL(mock_foo, Bar(IsEven()));
895//
896// or,
897//
898// // Verifies that the value of some_expression is even.
899// EXPECT_THAT(some_expression, IsEven());
900//
901// If the above assertion fails, it will print something like:
902//
903// Value of: some_expression
904// Expected: is even
905// Actual: 7
906//
907// where the description "is even" is automatically calculated from the
908// matcher name IsEven.
909//
zhanyong.wan82113312010-01-08 21:55:40 +0000910// Argument Type
911// =============
912//
zhanyong.wance198ff2009-02-12 01:34:27 +0000913// Note that the type of the value being matched (arg_type) is
914// determined by the context in which you use the matcher and is
915// supplied to you by the compiler, so you don't need to worry about
916// declaring it (nor can you). This allows the matcher to be
917// polymorphic. For example, IsEven() can be used to match any type
918// where the value of "(arg % 2) == 0" can be implicitly converted to
919// a bool. In the "Bar(IsEven())" example above, if method Bar()
920// takes an int, 'arg_type' will be int; if it takes an unsigned long,
921// 'arg_type' will be unsigned long; and so on.
922//
zhanyong.wan82113312010-01-08 21:55:40 +0000923// Parameterizing Matchers
924// =======================
925//
zhanyong.wance198ff2009-02-12 01:34:27 +0000926// Sometimes you'll want to parameterize the matcher. For that you
927// can use another macro:
928//
929// MATCHER_P(name, param_name, description_string) { statements; }
930//
931// For example:
932//
933// MATCHER_P(HasAbsoluteValue, value, "") { return abs(arg) == value; }
934//
935// will allow you to write:
936//
937// EXPECT_THAT(Blah("a"), HasAbsoluteValue(n));
938//
939// which may lead to this message (assuming n is 10):
940//
941// Value of: Blah("a")
942// Expected: has absolute value 10
943// Actual: -9
944//
945// Note that both the matcher description and its parameter are
946// printed, making the message human-friendly.
947//
948// In the matcher definition body, you can write 'foo_type' to
949// reference the type of a parameter named 'foo'. For example, in the
950// body of MATCHER_P(HasAbsoluteValue, value) above, you can write
951// 'value_type' to refer to the type of 'value'.
952//
953// We also provide MATCHER_P2, MATCHER_P3, ..., up to MATCHER_P10 to
954// support multi-parameter matchers.
955//
zhanyong.wan82113312010-01-08 21:55:40 +0000956// Describing Parameterized Matchers
957// =================================
958//
zhanyong.wan4a5330d2009-02-19 00:36:44 +0000959// When defining a parameterized matcher, you can use Python-style
960// interpolations in the description string to refer to the parameter
961// values. We support the following syntax currently:
962//
963// %% a single '%' character
964// %(*)s all parameters of the matcher printed as a tuple
965// %(foo)s value of the matcher parameter named 'foo'
966//
967// For example,
968//
969// MATCHER_P2(InClosedRange, low, hi, "is in range [%(low)s, %(hi)s]") {
970// return low <= arg && arg <= hi;
971// }
972// ...
973// EXPECT_THAT(3, InClosedRange(4, 6));
974//
975// would generate a failure that contains the message:
976//
977// Expected: is in range [4, 6]
978//
979// If you specify "" as the description, the failure message will
980// contain the sequence of words in the matcher name followed by the
981// parameter values printed as a tuple. For example,
982//
983// MATCHER_P2(InClosedRange, low, hi, "") { ... }
984// ...
985// EXPECT_THAT(3, InClosedRange(4, 6));
986//
987// would generate a failure that contains the text:
988//
989// Expected: in closed range (4, 6)
990//
zhanyong.wan82113312010-01-08 21:55:40 +0000991// Types of Matcher Parameters
992// ===========================
993//
zhanyong.wance198ff2009-02-12 01:34:27 +0000994// For the purpose of typing, you can view
995//
996// MATCHER_Pk(Foo, p1, ..., pk, description_string) { ... }
997//
998// as shorthand for
999//
1000// template <typename p1_type, ..., typename pk_type>
1001// FooMatcherPk<p1_type, ..., pk_type>
1002// Foo(p1_type p1, ..., pk_type pk) { ... }
1003//
1004// When you write Foo(v1, ..., vk), the compiler infers the types of
1005// the parameters v1, ..., and vk for you. If you are not happy with
1006// the result of the type inference, you can specify the types by
1007// explicitly instantiating the template, as in Foo<long, bool>(5,
1008// false). As said earlier, you don't get to (or need to) specify
1009// 'arg_type' as that's determined by the context in which the matcher
1010// is used. You can assign the result of expression Foo(p1, ..., pk)
1011// to a variable of type FooMatcherPk<p1_type, ..., pk_type>. This
1012// can be useful when composing matchers.
1013//
1014// While you can instantiate a matcher template with reference types,
1015// passing the parameters by pointer usually makes your code more
1016// readable. If, however, you still want to pass a parameter by
1017// reference, be aware that in the failure message generated by the
1018// matcher you will see the value of the referenced object but not its
1019// address.
1020//
zhanyong.wan82113312010-01-08 21:55:40 +00001021// Explaining Match Results
1022// ========================
1023//
1024// Sometimes the matcher description alone isn't enough to explain why
1025// the match has failed or succeeded. For example, when expecting a
1026// long string, it can be very helpful to also print the diff between
1027// the expected string and the actual one. To achieve that, you can
1028// optionally stream additional information to a special variable
1029// named result_listener, whose type is a pointer to class
1030// MatchResultListener:
1031//
1032// MATCHER_P(EqualsLongString, str, "") {
1033// if (arg == str) return true;
1034//
1035// *result_listener << "the difference: "
1036/// << DiffStrings(str, arg);
1037// return false;
1038// }
1039//
1040// Overloading Matchers
1041// ====================
1042//
zhanyong.wance198ff2009-02-12 01:34:27 +00001043// You can overload matchers with different numbers of parameters:
1044//
1045// MATCHER_P(Blah, a, description_string1) { ... }
1046// MATCHER_P2(Blah, a, b, description_string2) { ... }
1047//
zhanyong.wan82113312010-01-08 21:55:40 +00001048// Caveats
1049// =======
zhanyong.wance198ff2009-02-12 01:34:27 +00001050//
zhanyong.wan82113312010-01-08 21:55:40 +00001051// When defining a new matcher, you should also consider implementing
1052// MatcherInterface or using MakePolymorphicMatcher(). These
1053// approaches require more work than the MATCHER* macros, but also
1054// give you more control on the types of the value being matched and
1055// the matcher parameters, which may leads to better compiler error
1056// messages when the matcher is used wrong. They also allow
1057// overloading matchers based on parameter types (as opposed to just
1058// based on the number of parameters).
zhanyong.wance198ff2009-02-12 01:34:27 +00001059//
1060// MATCHER*() can only be used in a namespace scope. The reason is
1061// that C++ doesn't yet allow function-local types to be used to
1062// instantiate templates. The up-coming C++0x standard will fix this.
1063// Once that's done, we'll consider supporting using MATCHER*() inside
1064// a function.
1065//
zhanyong.wan82113312010-01-08 21:55:40 +00001066// More Information
1067// ================
zhanyong.wance198ff2009-02-12 01:34:27 +00001068//
1069// To learn more about using these macros, please search for 'MATCHER'
1070// on http://code.google.com/p/googlemock/wiki/CookBook.
1071
1072#define MATCHER(name, description)\
1073 class name##Matcher {\
1074 public:\
1075 template <typename arg_type>\
1076 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1077 public:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001078 gmock_Impl(const ::testing::internal::Interpolations& gmock_interp)\
1079 : gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001080 virtual bool MatchAndExplain(\
1081 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001082 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1083 const ::testing::internal::Strings& gmock_printed_params = \
1084 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1085 ::std::tr1::tuple<>());\
1086 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1087 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001088 }\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001089 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001090 private:\
1091 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001092 };\
1093 template <typename arg_type>\
1094 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001095 return ::testing::Matcher<arg_type>(\
1096 new gmock_Impl<arg_type>(gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001097 }\
1098 name##Matcher() {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001099 const char* gmock_param_names[] = { NULL };\
1100 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1101 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001102 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001103 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001104 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001105 GTEST_DISALLOW_ASSIGN_(name##Matcher);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001106 };\
1107 inline name##Matcher name() {\
1108 return name##Matcher();\
1109 }\
1110 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001111 bool name##Matcher::gmock_Impl<arg_type>::MatchAndExplain(\
1112 arg_type arg,\
1113 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1114 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001115
1116#define MATCHER_P(name, p0, description)\
1117 template <typename p0##_type>\
1118 class name##MatcherP {\
1119 public:\
1120 template <typename arg_type>\
1121 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1122 public:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001123 explicit gmock_Impl(p0##_type gmock_p0, \
1124 const ::testing::internal::Interpolations& gmock_interp)\
1125 : p0(gmock_p0), gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001126 virtual bool MatchAndExplain(\
1127 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001128 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1129 const ::testing::internal::Strings& gmock_printed_params = \
1130 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1131 ::std::tr1::tuple<p0##_type>(p0));\
1132 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1133 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001134 }\
1135 p0##_type p0;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001136 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001137 private:\
1138 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001139 };\
1140 template <typename arg_type>\
1141 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001142 return ::testing::Matcher<arg_type>(\
1143 new gmock_Impl<arg_type>(p0, gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001144 }\
1145 name##MatcherP(p0##_type gmock_p0) : p0(gmock_p0) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001146 const char* gmock_param_names[] = { #p0, NULL };\
1147 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1148 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001149 }\
1150 p0##_type p0;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001151 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001152 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001153 GTEST_DISALLOW_ASSIGN_(name##MatcherP);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001154 };\
1155 template <typename p0##_type>\
1156 inline name##MatcherP<p0##_type> name(p0##_type p0) {\
1157 return name##MatcherP<p0##_type>(p0);\
1158 }\
1159 template <typename p0##_type>\
1160 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001161 bool name##MatcherP<p0##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1162 arg_type arg,\
1163 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1164 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001165
1166#define MATCHER_P2(name, p0, p1, description)\
1167 template <typename p0##_type, typename p1##_type>\
1168 class name##MatcherP2 {\
1169 public:\
1170 template <typename arg_type>\
1171 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1172 public:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001173 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, \
1174 const ::testing::internal::Interpolations& gmock_interp)\
1175 : p0(gmock_p0), p1(gmock_p1), gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001176 virtual bool MatchAndExplain(\
1177 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001178 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1179 const ::testing::internal::Strings& gmock_printed_params = \
1180 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1181 ::std::tr1::tuple<p0##_type, p1##_type>(p0, p1));\
1182 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1183 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001184 }\
1185 p0##_type p0;\
1186 p1##_type p1;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001187 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001188 private:\
1189 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001190 };\
1191 template <typename arg_type>\
1192 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001193 return ::testing::Matcher<arg_type>(\
1194 new gmock_Impl<arg_type>(p0, p1, gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001195 }\
1196 name##MatcherP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
1197 p1(gmock_p1) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001198 const char* gmock_param_names[] = { #p0, #p1, NULL };\
1199 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1200 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001201 }\
1202 p0##_type p0;\
1203 p1##_type p1;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001204 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001205 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001206 GTEST_DISALLOW_ASSIGN_(name##MatcherP2);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001207 };\
1208 template <typename p0##_type, typename p1##_type>\
1209 inline name##MatcherP2<p0##_type, p1##_type> name(p0##_type p0, \
1210 p1##_type p1) {\
1211 return name##MatcherP2<p0##_type, p1##_type>(p0, p1);\
1212 }\
1213 template <typename p0##_type, typename p1##_type>\
1214 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001215 bool name##MatcherP2<p0##_type, \
1216 p1##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1217 arg_type arg,\
1218 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1219 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001220
1221#define MATCHER_P3(name, p0, p1, p2, description)\
1222 template <typename p0##_type, typename p1##_type, typename p2##_type>\
1223 class name##MatcherP3 {\
1224 public:\
1225 template <typename arg_type>\
1226 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1227 public:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001228 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1229 const ::testing::internal::Interpolations& gmock_interp)\
1230 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1231 gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001232 virtual bool MatchAndExplain(\
1233 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001234 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1235 const ::testing::internal::Strings& gmock_printed_params = \
1236 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1237 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type>(p0, p1, \
1238 p2));\
1239 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1240 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001241 }\
1242 p0##_type p0;\
1243 p1##_type p1;\
1244 p2##_type p2;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001245 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001246 private:\
1247 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001248 };\
1249 template <typename arg_type>\
1250 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001251 return ::testing::Matcher<arg_type>(\
1252 new gmock_Impl<arg_type>(p0, p1, p2, gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001253 }\
1254 name##MatcherP3(p0##_type gmock_p0, p1##_type gmock_p1, \
1255 p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001256 const char* gmock_param_names[] = { #p0, #p1, #p2, NULL };\
1257 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1258 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001259 }\
1260 p0##_type p0;\
1261 p1##_type p1;\
1262 p2##_type p2;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001263 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001264 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001265 GTEST_DISALLOW_ASSIGN_(name##MatcherP3);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001266 };\
1267 template <typename p0##_type, typename p1##_type, typename p2##_type>\
1268 inline name##MatcherP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0, \
1269 p1##_type p1, p2##_type p2) {\
1270 return name##MatcherP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\
1271 }\
1272 template <typename p0##_type, typename p1##_type, typename p2##_type>\
1273 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001274 bool name##MatcherP3<p0##_type, p1##_type, \
1275 p2##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1276 arg_type arg,\
1277 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1278 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001279
1280#define MATCHER_P4(name, p0, p1, p2, p3, description)\
1281 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1282 typename p3##_type>\
1283 class name##MatcherP4 {\
1284 public:\
1285 template <typename arg_type>\
1286 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1287 public:\
1288 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001289 p3##_type gmock_p3, \
1290 const ::testing::internal::Interpolations& gmock_interp)\
1291 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1292 gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001293 virtual bool MatchAndExplain(\
1294 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001295 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1296 const ::testing::internal::Strings& gmock_printed_params = \
1297 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1298 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, \
1299 p3##_type>(p0, p1, p2, p3));\
1300 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1301 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001302 }\
1303 p0##_type p0;\
1304 p1##_type p1;\
1305 p2##_type p2;\
1306 p3##_type p3;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001307 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001308 private:\
1309 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001310 };\
1311 template <typename arg_type>\
1312 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001313 return ::testing::Matcher<arg_type>(\
1314 new gmock_Impl<arg_type>(p0, p1, p2, p3, gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001315 }\
1316 name##MatcherP4(p0##_type gmock_p0, p1##_type gmock_p1, \
1317 p2##_type gmock_p2, p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), \
1318 p2(gmock_p2), p3(gmock_p3) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001319 const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, NULL };\
1320 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1321 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001322 }\
1323 p0##_type p0;\
1324 p1##_type p1;\
1325 p2##_type p2;\
1326 p3##_type p3;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001327 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001328 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001329 GTEST_DISALLOW_ASSIGN_(name##MatcherP4);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001330 };\
1331 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1332 typename p3##_type>\
1333 inline name##MatcherP4<p0##_type, p1##_type, p2##_type, \
1334 p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
1335 p3##_type p3) {\
1336 return name##MatcherP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, \
1337 p1, p2, p3);\
1338 }\
1339 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1340 typename p3##_type>\
1341 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001342 bool name##MatcherP4<p0##_type, p1##_type, p2##_type, \
1343 p3##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1344 arg_type arg,\
1345 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1346 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001347
1348#define MATCHER_P5(name, p0, p1, p2, p3, p4, description)\
1349 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1350 typename p3##_type, typename p4##_type>\
1351 class name##MatcherP5 {\
1352 public:\
1353 template <typename arg_type>\
1354 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1355 public:\
1356 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001357 p3##_type gmock_p3, p4##_type gmock_p4, \
1358 const ::testing::internal::Interpolations& gmock_interp)\
1359 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1360 p4(gmock_p4), gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001361 virtual bool MatchAndExplain(\
1362 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001363 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1364 const ::testing::internal::Strings& gmock_printed_params = \
1365 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1366 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1367 p4##_type>(p0, p1, p2, p3, p4));\
1368 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1369 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001370 }\
1371 p0##_type p0;\
1372 p1##_type p1;\
1373 p2##_type p2;\
1374 p3##_type p3;\
1375 p4##_type p4;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001376 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001377 private:\
1378 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001379 };\
1380 template <typename arg_type>\
1381 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001382 return ::testing::Matcher<arg_type>(\
1383 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001384 }\
1385 name##MatcherP5(p0##_type gmock_p0, p1##_type gmock_p1, \
1386 p2##_type gmock_p2, p3##_type gmock_p3, \
1387 p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1388 p3(gmock_p3), p4(gmock_p4) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001389 const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, NULL };\
1390 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1391 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001392 }\
1393 p0##_type p0;\
1394 p1##_type p1;\
1395 p2##_type p2;\
1396 p3##_type p3;\
1397 p4##_type p4;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001398 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001399 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001400 GTEST_DISALLOW_ASSIGN_(name##MatcherP5);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001401 };\
1402 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1403 typename p3##_type, typename p4##_type>\
1404 inline name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1405 p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
1406 p4##_type p4) {\
1407 return name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1408 p4##_type>(p0, p1, p2, p3, p4);\
1409 }\
1410 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1411 typename p3##_type, typename p4##_type>\
1412 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001413 bool name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1414 p4##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1415 arg_type arg,\
1416 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1417 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001418
1419#define MATCHER_P6(name, p0, p1, p2, p3, p4, p5, description)\
1420 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1421 typename p3##_type, typename p4##_type, typename p5##_type>\
1422 class name##MatcherP6 {\
1423 public:\
1424 template <typename arg_type>\
1425 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1426 public:\
1427 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001428 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
1429 const ::testing::internal::Interpolations& gmock_interp)\
1430 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1431 p4(gmock_p4), p5(gmock_p5), gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001432 virtual bool MatchAndExplain(\
1433 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001434 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1435 const ::testing::internal::Strings& gmock_printed_params = \
1436 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1437 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1438 p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5));\
1439 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1440 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001441 }\
1442 p0##_type p0;\
1443 p1##_type p1;\
1444 p2##_type p2;\
1445 p3##_type p3;\
1446 p4##_type p4;\
1447 p5##_type p5;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001448 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001449 private:\
1450 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001451 };\
1452 template <typename arg_type>\
1453 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001454 return ::testing::Matcher<arg_type>(\
1455 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001456 }\
1457 name##MatcherP6(p0##_type gmock_p0, p1##_type gmock_p1, \
1458 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1459 p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1460 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001461 const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, #p5, NULL };\
1462 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1463 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001464 }\
1465 p0##_type p0;\
1466 p1##_type p1;\
1467 p2##_type p2;\
1468 p3##_type p3;\
1469 p4##_type p4;\
1470 p5##_type p5;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001471 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001472 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001473 GTEST_DISALLOW_ASSIGN_(name##MatcherP6);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001474 };\
1475 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1476 typename p3##_type, typename p4##_type, typename p5##_type>\
1477 inline name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
1478 p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
1479 p3##_type p3, p4##_type p4, p5##_type p5) {\
1480 return name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
1481 p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\
1482 }\
1483 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1484 typename p3##_type, typename p4##_type, typename p5##_type>\
1485 template <typename arg_type>\
1486 bool name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00001487 p5##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1488 arg_type arg,\
1489 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1490 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001491
1492#define MATCHER_P7(name, p0, p1, p2, p3, p4, p5, p6, description)\
1493 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1494 typename p3##_type, typename p4##_type, typename p5##_type, \
1495 typename p6##_type>\
1496 class name##MatcherP7 {\
1497 public:\
1498 template <typename arg_type>\
1499 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1500 public:\
1501 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1502 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001503 p6##_type gmock_p6, \
1504 const ::testing::internal::Interpolations& gmock_interp)\
1505 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1506 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
1507 gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001508 virtual bool MatchAndExplain(\
1509 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001510 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1511 const ::testing::internal::Strings& gmock_printed_params = \
1512 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1513 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1514 p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, \
1515 p6));\
1516 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1517 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001518 }\
1519 p0##_type p0;\
1520 p1##_type p1;\
1521 p2##_type p2;\
1522 p3##_type p3;\
1523 p4##_type p4;\
1524 p5##_type p5;\
1525 p6##_type p6;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001526 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001527 private:\
1528 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001529 };\
1530 template <typename arg_type>\
1531 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001532 return ::testing::Matcher<arg_type>(\
1533 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001534 }\
1535 name##MatcherP7(p0##_type gmock_p0, p1##_type gmock_p1, \
1536 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1537 p5##_type gmock_p5, p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), \
1538 p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), \
1539 p6(gmock_p6) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001540 const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, #p5, #p6, \
1541 NULL };\
1542 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1543 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001544 }\
1545 p0##_type p0;\
1546 p1##_type p1;\
1547 p2##_type p2;\
1548 p3##_type p3;\
1549 p4##_type p4;\
1550 p5##_type p5;\
1551 p6##_type p6;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001552 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001553 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001554 GTEST_DISALLOW_ASSIGN_(name##MatcherP7);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001555 };\
1556 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1557 typename p3##_type, typename p4##_type, typename p5##_type, \
1558 typename p6##_type>\
1559 inline name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
1560 p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \
1561 p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
1562 p6##_type p6) {\
1563 return name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
1564 p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\
1565 }\
1566 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1567 typename p3##_type, typename p4##_type, typename p5##_type, \
1568 typename p6##_type>\
1569 template <typename arg_type>\
1570 bool name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00001571 p5##_type, p6##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1572 arg_type arg,\
1573 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1574 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001575
1576#define MATCHER_P8(name, p0, p1, p2, p3, p4, p5, p6, p7, description)\
1577 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1578 typename p3##_type, typename p4##_type, typename p5##_type, \
1579 typename p6##_type, typename p7##_type>\
1580 class name##MatcherP8 {\
1581 public:\
1582 template <typename arg_type>\
1583 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1584 public:\
1585 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1586 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001587 p6##_type gmock_p6, p7##_type gmock_p7, \
1588 const ::testing::internal::Interpolations& gmock_interp)\
1589 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1590 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
1591 gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001592 virtual bool MatchAndExplain(\
1593 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001594 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1595 const ::testing::internal::Strings& gmock_printed_params = \
1596 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1597 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1598 p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, \
1599 p3, p4, p5, p6, p7));\
1600 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1601 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001602 }\
1603 p0##_type p0;\
1604 p1##_type p1;\
1605 p2##_type p2;\
1606 p3##_type p3;\
1607 p4##_type p4;\
1608 p5##_type p5;\
1609 p6##_type p6;\
1610 p7##_type p7;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001611 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001612 private:\
1613 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001614 };\
1615 template <typename arg_type>\
1616 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001617 return ::testing::Matcher<arg_type>(\
1618 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, \
1619 gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001620 }\
1621 name##MatcherP8(p0##_type gmock_p0, p1##_type gmock_p1, \
1622 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1623 p5##_type gmock_p5, p6##_type gmock_p6, \
1624 p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1625 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
1626 p7(gmock_p7) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001627 const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, #p5, #p6, \
1628 #p7, NULL };\
1629 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1630 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001631 }\
1632 p0##_type p0;\
1633 p1##_type p1;\
1634 p2##_type p2;\
1635 p3##_type p3;\
1636 p4##_type p4;\
1637 p5##_type p5;\
1638 p6##_type p6;\
1639 p7##_type p7;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001640 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001641 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001642 GTEST_DISALLOW_ASSIGN_(name##MatcherP8);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001643 };\
1644 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1645 typename p3##_type, typename p4##_type, typename p5##_type, \
1646 typename p6##_type, typename p7##_type>\
1647 inline name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
1648 p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \
1649 p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
1650 p6##_type p6, p7##_type p7) {\
1651 return name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
1652 p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5, \
1653 p6, p7);\
1654 }\
1655 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1656 typename p3##_type, typename p4##_type, typename p5##_type, \
1657 typename p6##_type, typename p7##_type>\
1658 template <typename arg_type>\
1659 bool name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00001660 p5##_type, p6##_type, \
1661 p7##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1662 arg_type arg,\
1663 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1664 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001665
1666#define MATCHER_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, description)\
1667 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1668 typename p3##_type, typename p4##_type, typename p5##_type, \
1669 typename p6##_type, typename p7##_type, typename p8##_type>\
1670 class name##MatcherP9 {\
1671 public:\
1672 template <typename arg_type>\
1673 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1674 public:\
1675 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1676 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001677 p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
1678 const ::testing::internal::Interpolations& gmock_interp)\
1679 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1680 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
1681 p8(gmock_p8), gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001682 virtual bool MatchAndExplain(\
1683 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001684 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1685 const ::testing::internal::Strings& gmock_printed_params = \
1686 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1687 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1688 p4##_type, p5##_type, p6##_type, p7##_type, \
1689 p8##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8));\
1690 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1691 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001692 }\
1693 p0##_type p0;\
1694 p1##_type p1;\
1695 p2##_type p2;\
1696 p3##_type p3;\
1697 p4##_type p4;\
1698 p5##_type p5;\
1699 p6##_type p6;\
1700 p7##_type p7;\
1701 p8##_type p8;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001702 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001703 private:\
1704 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001705 };\
1706 template <typename arg_type>\
1707 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001708 return ::testing::Matcher<arg_type>(\
1709 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, \
1710 gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001711 }\
1712 name##MatcherP9(p0##_type gmock_p0, p1##_type gmock_p1, \
1713 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1714 p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
1715 p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1716 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
1717 p8(gmock_p8) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001718 const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, #p5, #p6, \
1719 #p7, #p8, NULL };\
1720 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1721 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001722 }\
1723 p0##_type p0;\
1724 p1##_type p1;\
1725 p2##_type p2;\
1726 p3##_type p3;\
1727 p4##_type p4;\
1728 p5##_type p5;\
1729 p6##_type p6;\
1730 p7##_type p7;\
1731 p8##_type p8;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001732 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001733 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001734 GTEST_DISALLOW_ASSIGN_(name##MatcherP9);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001735 };\
1736 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1737 typename p3##_type, typename p4##_type, typename p5##_type, \
1738 typename p6##_type, typename p7##_type, typename p8##_type>\
1739 inline name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \
1740 p4##_type, p5##_type, p6##_type, p7##_type, \
1741 p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
1742 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \
1743 p8##_type p8) {\
1744 return name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \
1745 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type>(p0, p1, p2, \
1746 p3, p4, p5, p6, p7, p8);\
1747 }\
1748 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1749 typename p3##_type, typename p4##_type, typename p5##_type, \
1750 typename p6##_type, typename p7##_type, typename p8##_type>\
1751 template <typename arg_type>\
1752 bool name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00001753 p5##_type, p6##_type, p7##_type, \
1754 p8##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1755 arg_type arg,\
1756 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1757 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001758
1759#define MATCHER_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, description)\
1760 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1761 typename p3##_type, typename p4##_type, typename p5##_type, \
1762 typename p6##_type, typename p7##_type, typename p8##_type, \
1763 typename p9##_type>\
1764 class name##MatcherP10 {\
1765 public:\
1766 template <typename arg_type>\
1767 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1768 public:\
1769 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1770 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
1771 p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001772 p9##_type gmock_p9, \
1773 const ::testing::internal::Interpolations& gmock_interp)\
1774 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1775 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
1776 p8(gmock_p8), p9(gmock_p9), gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001777 virtual bool MatchAndExplain(\
1778 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001779 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1780 const ::testing::internal::Strings& gmock_printed_params = \
1781 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1782 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1783 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
1784 p9##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9));\
1785 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1786 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001787 }\
1788 p0##_type p0;\
1789 p1##_type p1;\
1790 p2##_type p2;\
1791 p3##_type p3;\
1792 p4##_type p4;\
1793 p5##_type p5;\
1794 p6##_type p6;\
1795 p7##_type p7;\
1796 p8##_type p8;\
1797 p9##_type p9;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001798 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001799 private:\
1800 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001801 };\
1802 template <typename arg_type>\
1803 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001804 return ::testing::Matcher<arg_type>(\
1805 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, \
1806 gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001807 }\
1808 name##MatcherP10(p0##_type gmock_p0, p1##_type gmock_p1, \
1809 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1810 p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
1811 p8##_type gmock_p8, p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), \
1812 p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
1813 p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001814 const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, #p5, #p6, \
1815 #p7, #p8, #p9, NULL };\
1816 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1817 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001818 }\
1819 p0##_type p0;\
1820 p1##_type p1;\
1821 p2##_type p2;\
1822 p3##_type p3;\
1823 p4##_type p4;\
1824 p5##_type p5;\
1825 p6##_type p6;\
1826 p7##_type p7;\
1827 p8##_type p8;\
1828 p9##_type p9;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001829 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001830 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001831 GTEST_DISALLOW_ASSIGN_(name##MatcherP10);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001832 };\
1833 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1834 typename p3##_type, typename p4##_type, typename p5##_type, \
1835 typename p6##_type, typename p7##_type, typename p8##_type, \
1836 typename p9##_type>\
1837 inline name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
1838 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
1839 p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
1840 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
1841 p9##_type p9) {\
1842 return name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
1843 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>(p0, \
1844 p1, p2, p3, p4, p5, p6, p7, p8, p9);\
1845 }\
1846 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1847 typename p3##_type, typename p4##_type, typename p5##_type, \
1848 typename p6##_type, typename p7##_type, typename p8##_type, \
1849 typename p9##_type>\
1850 template <typename arg_type>\
1851 bool name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00001852 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
1853 p9##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1854 arg_type arg,\
1855 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1856 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001857
shiqiane35fdd92008-12-10 05:08:54 +00001858#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_