blob: b4c85715a88425e043ed1677e7744c39172f7135 [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
jgm38513a82012-11-15 15:50:36 +000041#include <iterator>
shiqiane35fdd92008-12-10 05:08:54 +000042#include <sstream>
43#include <string>
44#include <vector>
zhanyong.wan53e08c42010-09-14 05:38:21 +000045#include "gmock/gmock-matchers.h"
shiqiane35fdd92008-12-10 05:08:54 +000046
47namespace testing {
48namespace internal {
49
zhanyong.wan2661c682009-06-09 05:42:12 +000050// The type of the i-th (0-based) field of Tuple.
51#define GMOCK_FIELD_TYPE_(Tuple, i) \
52 typename ::std::tr1::tuple_element<i, Tuple>::type
53
54// TupleFields<Tuple, k0, ..., kn> is for selecting fields from a
55// tuple of type Tuple. It has two members:
56//
57// type: a tuple type whose i-th field is the ki-th field of Tuple.
58// GetSelectedFields(t): returns fields k0, ..., and kn of t as a tuple.
59//
60// For example, in class TupleFields<tuple<bool, char, int>, 2, 0>, we have:
61//
62// type is tuple<int, bool>, and
63// GetSelectedFields(make_tuple(true, 'a', 42)) is (42, true).
64
65template <class Tuple, int k0 = -1, int k1 = -1, int k2 = -1, int k3 = -1,
66 int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
67 int k9 = -1>
68class TupleFields;
69
70// This generic version is used when there are 10 selectors.
71template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
72 int k7, int k8, int k9>
73class TupleFields {
74 public:
75 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
76 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
77 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
78 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
79 GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8),
80 GMOCK_FIELD_TYPE_(Tuple, k9)> type;
81 static type GetSelectedFields(const Tuple& t) {
82 using ::std::tr1::get;
83 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
84 get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t), get<k9>(t));
85 }
86};
87
88// The following specialization is used for 0 ~ 9 selectors.
89
90template <class Tuple>
91class TupleFields<Tuple, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
92 public:
93 typedef ::std::tr1::tuple<> type;
zhanyong.wan32de5f52009-12-23 00:13:23 +000094 static type GetSelectedFields(const Tuple& /* t */) {
zhanyong.wan2661c682009-06-09 05:42:12 +000095 using ::std::tr1::get;
96 return type();
97 }
98};
99
100template <class Tuple, int k0>
101class TupleFields<Tuple, k0, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
102 public:
103 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0)> type;
104 static type GetSelectedFields(const Tuple& t) {
105 using ::std::tr1::get;
106 return type(get<k0>(t));
107 }
108};
109
110template <class Tuple, int k0, int k1>
111class TupleFields<Tuple, k0, k1, -1, -1, -1, -1, -1, -1, -1, -1> {
112 public:
113 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
114 GMOCK_FIELD_TYPE_(Tuple, k1)> type;
115 static type GetSelectedFields(const Tuple& t) {
116 using ::std::tr1::get;
117 return type(get<k0>(t), get<k1>(t));
118 }
119};
120
121template <class Tuple, int k0, int k1, int k2>
122class TupleFields<Tuple, k0, k1, k2, -1, -1, -1, -1, -1, -1, -1> {
123 public:
124 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
125 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2)> type;
126 static type GetSelectedFields(const Tuple& t) {
127 using ::std::tr1::get;
128 return type(get<k0>(t), get<k1>(t), get<k2>(t));
129 }
130};
131
132template <class Tuple, int k0, int k1, int k2, int k3>
133class TupleFields<Tuple, k0, k1, k2, k3, -1, -1, -1, -1, -1, -1> {
134 public:
135 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
136 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
137 GMOCK_FIELD_TYPE_(Tuple, k3)> type;
138 static type GetSelectedFields(const Tuple& t) {
139 using ::std::tr1::get;
140 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t));
141 }
142};
143
144template <class Tuple, int k0, int k1, int k2, int k3, int k4>
145class TupleFields<Tuple, k0, k1, k2, k3, k4, -1, -1, -1, -1, -1> {
146 public:
147 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
148 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
149 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4)> type;
150 static type GetSelectedFields(const Tuple& t) {
151 using ::std::tr1::get;
152 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t));
153 }
154};
155
156template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5>
157class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, -1, -1, -1, -1> {
158 public:
159 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
160 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
161 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
162 GMOCK_FIELD_TYPE_(Tuple, k5)> type;
163 static type GetSelectedFields(const Tuple& t) {
164 using ::std::tr1::get;
165 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
166 get<k5>(t));
167 }
168};
169
170template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6>
171class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, -1, -1, -1> {
172 public:
173 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
174 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
175 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
176 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6)> type;
177 static type GetSelectedFields(const Tuple& t) {
178 using ::std::tr1::get;
179 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
180 get<k5>(t), get<k6>(t));
181 }
182};
183
184template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
185 int k7>
186class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, -1, -1> {
187 public:
188 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
189 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
190 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
191 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
192 GMOCK_FIELD_TYPE_(Tuple, k7)> type;
193 static type GetSelectedFields(const Tuple& t) {
194 using ::std::tr1::get;
195 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
196 get<k5>(t), get<k6>(t), get<k7>(t));
197 }
198};
199
200template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
201 int k7, int k8>
202class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, k8, -1> {
203 public:
204 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
205 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
206 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
207 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
208 GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8)> type;
209 static type GetSelectedFields(const Tuple& t) {
210 using ::std::tr1::get;
211 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
212 get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t));
213 }
214};
215
216#undef GMOCK_FIELD_TYPE_
217
218// Implements the Args() matcher.
219template <class ArgsTuple, int k0 = -1, int k1 = -1, int k2 = -1, int k3 = -1,
220 int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
221 int k9 = -1>
222class ArgsMatcherImpl : public MatcherInterface<ArgsTuple> {
223 public:
224 // ArgsTuple may have top-level const or reference modifiers.
zhanyong.wanab5b77c2010-05-17 19:32:48 +0000225 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(ArgsTuple) RawArgsTuple;
zhanyong.wan2661c682009-06-09 05:42:12 +0000226 typedef typename internal::TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5,
227 k6, k7, k8, k9>::type SelectedArgs;
228 typedef Matcher<const SelectedArgs&> MonomorphicInnerMatcher;
229
230 template <typename InnerMatcher>
231 explicit ArgsMatcherImpl(const InnerMatcher& inner_matcher)
232 : inner_matcher_(SafeMatcherCast<const SelectedArgs&>(inner_matcher)) {}
233
zhanyong.wan82113312010-01-08 21:55:40 +0000234 virtual bool MatchAndExplain(ArgsTuple args,
235 MatchResultListener* listener) const {
zhanyong.wanb1c7f932010-03-24 17:35:11 +0000236 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;
zhanyong.wan2661c682009-06-09 05:42:12 +0000248 }
249
250 virtual void DescribeTo(::std::ostream* os) const {
zhanyong.wanb1c7f932010-03-24 17:35:11 +0000251 *os << "are a tuple ";
zhanyong.wan2661c682009-06-09 05:42:12 +0000252 PrintIndices(os);
253 inner_matcher_.DescribeTo(os);
254 }
255
256 virtual void DescribeNegationTo(::std::ostream* os) const {
zhanyong.wanb1c7f932010-03-24 17:35:11 +0000257 *os << "are a tuple ";
zhanyong.wan2661c682009-06-09 05:42:12 +0000258 PrintIndices(os);
259 inner_matcher_.DescribeNegationTo(os);
260 }
261
zhanyong.wan2661c682009-06-09 05:42:12 +0000262 private:
263 static SelectedArgs GetSelectedArgs(ArgsTuple args) {
264 return TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5, k6, k7, k8,
265 k9>::GetSelectedFields(args);
266 }
267
268 // Prints the indices of the selected fields.
269 static void PrintIndices(::std::ostream* os) {
zhanyong.wanb1c7f932010-03-24 17:35:11 +0000270 *os << "whose fields (";
zhanyong.wan2661c682009-06-09 05:42:12 +0000271 const int indices[10] = { k0, k1, k2, k3, k4, k5, k6, k7, k8, k9 };
272 for (int i = 0; i < 10; i++) {
273 if (indices[i] < 0)
274 break;
275
276 if (i >= 1)
277 *os << ", ";
278
279 *os << "#" << indices[i];
280 }
281 *os << ") ";
282 }
283
284 const MonomorphicInnerMatcher inner_matcher_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000285
286 GTEST_DISALLOW_ASSIGN_(ArgsMatcherImpl);
zhanyong.wan2661c682009-06-09 05:42:12 +0000287};
288
289template <class InnerMatcher, int k0 = -1, int k1 = -1, int k2 = -1,
290 int k3 = -1, int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1,
291 int k8 = -1, int k9 = -1>
292class ArgsMatcher {
293 public:
294 explicit ArgsMatcher(const InnerMatcher& inner_matcher)
295 : inner_matcher_(inner_matcher) {}
296
297 template <typename ArgsTuple>
298 operator Matcher<ArgsTuple>() const {
299 return MakeMatcher(new ArgsMatcherImpl<ArgsTuple, k0, k1, k2, k3, k4, k5,
300 k6, k7, k8, k9>(inner_matcher_));
301 }
302
zhanyong.wan32de5f52009-12-23 00:13:23 +0000303 private:
zhanyong.wan2661c682009-06-09 05:42:12 +0000304 const InnerMatcher inner_matcher_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000305
306 GTEST_DISALLOW_ASSIGN_(ArgsMatcher);
zhanyong.wan2661c682009-06-09 05:42:12 +0000307};
308
jgm79a367e2012-04-10 16:02:11 +0000309// A set of metafunctions for computing the result type of AllOf.
310// AllOf(m1, ..., mN) returns
311// AllOfResultN<decltype(m1), ..., decltype(mN)>::type.
312
313// Although AllOf isn't defined for one argument, AllOfResult1 is defined
314// to simplify the implementation.
315template <typename M1>
316struct AllOfResult1 {
317 typedef M1 type;
318};
319
320template <typename M1, typename M2>
321struct AllOfResult2 {
322 typedef BothOfMatcher<
323 typename AllOfResult1<M1>::type,
324 typename AllOfResult1<M2>::type
325 > type;
326};
327
328template <typename M1, typename M2, typename M3>
329struct AllOfResult3 {
330 typedef BothOfMatcher<
331 typename AllOfResult1<M1>::type,
332 typename AllOfResult2<M2, M3>::type
333 > type;
334};
335
336template <typename M1, typename M2, typename M3, typename M4>
337struct AllOfResult4 {
338 typedef BothOfMatcher<
339 typename AllOfResult2<M1, M2>::type,
340 typename AllOfResult2<M3, M4>::type
341 > type;
342};
343
344template <typename M1, typename M2, typename M3, typename M4, typename M5>
345struct AllOfResult5 {
346 typedef BothOfMatcher<
347 typename AllOfResult2<M1, M2>::type,
348 typename AllOfResult3<M3, M4, M5>::type
349 > type;
350};
351
352template <typename M1, typename M2, typename M3, typename M4, typename M5,
353 typename M6>
354struct AllOfResult6 {
355 typedef BothOfMatcher<
356 typename AllOfResult3<M1, M2, M3>::type,
357 typename AllOfResult3<M4, M5, M6>::type
358 > type;
359};
360
361template <typename M1, typename M2, typename M3, typename M4, typename M5,
362 typename M6, typename M7>
363struct AllOfResult7 {
364 typedef BothOfMatcher<
365 typename AllOfResult3<M1, M2, M3>::type,
366 typename AllOfResult4<M4, M5, M6, M7>::type
367 > type;
368};
369
370template <typename M1, typename M2, typename M3, typename M4, typename M5,
371 typename M6, typename M7, typename M8>
372struct AllOfResult8 {
373 typedef BothOfMatcher<
374 typename AllOfResult4<M1, M2, M3, M4>::type,
375 typename AllOfResult4<M5, M6, M7, M8>::type
376 > type;
377};
378
379template <typename M1, typename M2, typename M3, typename M4, typename M5,
380 typename M6, typename M7, typename M8, typename M9>
381struct AllOfResult9 {
382 typedef BothOfMatcher<
383 typename AllOfResult4<M1, M2, M3, M4>::type,
384 typename AllOfResult5<M5, M6, M7, M8, M9>::type
385 > type;
386};
387
388template <typename M1, typename M2, typename M3, typename M4, typename M5,
389 typename M6, typename M7, typename M8, typename M9, typename M10>
390struct AllOfResult10 {
391 typedef BothOfMatcher<
392 typename AllOfResult5<M1, M2, M3, M4, M5>::type,
393 typename AllOfResult5<M6, M7, M8, M9, M10>::type
394 > type;
395};
396
397// A set of metafunctions for computing the result type of AnyOf.
398// AnyOf(m1, ..., mN) returns
399// AnyOfResultN<decltype(m1), ..., decltype(mN)>::type.
400
401// Although AnyOf isn't defined for one argument, AnyOfResult1 is defined
402// to simplify the implementation.
403template <typename M1>
404struct AnyOfResult1 {
405 typedef M1 type;
406};
407
408template <typename M1, typename M2>
409struct AnyOfResult2 {
410 typedef EitherOfMatcher<
411 typename AnyOfResult1<M1>::type,
412 typename AnyOfResult1<M2>::type
413 > type;
414};
415
416template <typename M1, typename M2, typename M3>
417struct AnyOfResult3 {
418 typedef EitherOfMatcher<
419 typename AnyOfResult1<M1>::type,
420 typename AnyOfResult2<M2, M3>::type
421 > type;
422};
423
424template <typename M1, typename M2, typename M3, typename M4>
425struct AnyOfResult4 {
426 typedef EitherOfMatcher<
427 typename AnyOfResult2<M1, M2>::type,
428 typename AnyOfResult2<M3, M4>::type
429 > type;
430};
431
432template <typename M1, typename M2, typename M3, typename M4, typename M5>
433struct AnyOfResult5 {
434 typedef EitherOfMatcher<
435 typename AnyOfResult2<M1, M2>::type,
436 typename AnyOfResult3<M3, M4, M5>::type
437 > type;
438};
439
440template <typename M1, typename M2, typename M3, typename M4, typename M5,
441 typename M6>
442struct AnyOfResult6 {
443 typedef EitherOfMatcher<
444 typename AnyOfResult3<M1, M2, M3>::type,
445 typename AnyOfResult3<M4, M5, M6>::type
446 > type;
447};
448
449template <typename M1, typename M2, typename M3, typename M4, typename M5,
450 typename M6, typename M7>
451struct AnyOfResult7 {
452 typedef EitherOfMatcher<
453 typename AnyOfResult3<M1, M2, M3>::type,
454 typename AnyOfResult4<M4, M5, M6, M7>::type
455 > type;
456};
457
458template <typename M1, typename M2, typename M3, typename M4, typename M5,
459 typename M6, typename M7, typename M8>
460struct AnyOfResult8 {
461 typedef EitherOfMatcher<
462 typename AnyOfResult4<M1, M2, M3, M4>::type,
463 typename AnyOfResult4<M5, M6, M7, M8>::type
464 > type;
465};
466
467template <typename M1, typename M2, typename M3, typename M4, typename M5,
468 typename M6, typename M7, typename M8, typename M9>
469struct AnyOfResult9 {
470 typedef EitherOfMatcher<
471 typename AnyOfResult4<M1, M2, M3, M4>::type,
472 typename AnyOfResult5<M5, M6, M7, M8, M9>::type
473 > type;
474};
475
476template <typename M1, typename M2, typename M3, typename M4, typename M5,
477 typename M6, typename M7, typename M8, typename M9, typename M10>
478struct AnyOfResult10 {
479 typedef EitherOfMatcher<
480 typename AnyOfResult5<M1, M2, M3, M4, M5>::type,
481 typename AnyOfResult5<M6, M7, M8, M9, M10>::type
482 > type;
483};
484
shiqiane35fdd92008-12-10 05:08:54 +0000485} // namespace internal
486
zhanyong.wan2661c682009-06-09 05:42:12 +0000487// Args<N1, N2, ..., Nk>(a_matcher) matches a tuple if the selected
488// fields of it matches a_matcher. C++ doesn't support default
489// arguments for function templates, so we have to overload it.
490template <typename InnerMatcher>
491inline internal::ArgsMatcher<InnerMatcher>
492Args(const InnerMatcher& matcher) {
493 return internal::ArgsMatcher<InnerMatcher>(matcher);
494}
495
496template <int k1, typename InnerMatcher>
497inline internal::ArgsMatcher<InnerMatcher, k1>
498Args(const InnerMatcher& matcher) {
499 return internal::ArgsMatcher<InnerMatcher, k1>(matcher);
500}
501
502template <int k1, int k2, typename InnerMatcher>
503inline internal::ArgsMatcher<InnerMatcher, k1, k2>
504Args(const InnerMatcher& matcher) {
505 return internal::ArgsMatcher<InnerMatcher, k1, k2>(matcher);
506}
507
508template <int k1, int k2, int k3, typename InnerMatcher>
509inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3>
510Args(const InnerMatcher& matcher) {
511 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3>(matcher);
512}
513
514template <int k1, int k2, int k3, int k4, typename InnerMatcher>
515inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>
516Args(const InnerMatcher& matcher) {
517 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>(matcher);
518}
519
520template <int k1, int k2, int k3, int k4, int k5, typename InnerMatcher>
521inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>
522Args(const InnerMatcher& matcher) {
523 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>(matcher);
524}
525
526template <int k1, int k2, int k3, int k4, int k5, int k6, typename InnerMatcher>
527inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>
528Args(const InnerMatcher& matcher) {
529 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>(matcher);
530}
531
532template <int k1, int k2, int k3, int k4, int k5, int k6, int k7,
533 typename InnerMatcher>
534inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7>
535Args(const InnerMatcher& matcher) {
536 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6,
537 k7>(matcher);
538}
539
540template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
541 typename InnerMatcher>
542inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8>
543Args(const InnerMatcher& matcher) {
544 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7,
545 k8>(matcher);
546}
547
548template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
549 int k9, typename InnerMatcher>
550inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9>
551Args(const InnerMatcher& matcher) {
552 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
553 k9>(matcher);
554}
555
556template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
557 int k9, int k10, typename InnerMatcher>
558inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9,
559 k10>
560Args(const InnerMatcher& matcher) {
561 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
562 k9, k10>(matcher);
563}
564
zhanyong.wanfb25d532013-07-28 08:24:00 +0000565// ElementsAre(e_1, e_2, ... e_n) matches an STL-style container with
566// n elements, where the i-th element in the container must
shiqiane35fdd92008-12-10 05:08:54 +0000567// match the i-th argument in the list. Each argument of
568// ElementsAre() can be either a value or a matcher. We support up to
569// 10 arguments.
570//
zhanyong.wanfb25d532013-07-28 08:24:00 +0000571// The use of DecayArray in the implementation allows ElementsAre()
572// to accept string literals, whose type is const char[N], but we
573// want to treat them as const char*.
574//
shiqiane35fdd92008-12-10 05:08:54 +0000575// NOTE: Since ElementsAre() cares about the order of the elements, it
576// must not be used with containers whose elements's order is
577// undefined (e.g. hash_map).
578
zhanyong.wanfb25d532013-07-28 08:24:00 +0000579inline internal::ElementsAreMatcher<
580 std::tr1::tuple<> >
581ElementsAre() {
582 typedef std::tr1::tuple<> Args;
583 return internal::ElementsAreMatcher<Args>(Args());
shiqiane35fdd92008-12-10 05:08:54 +0000584}
585
586template <typename T1>
zhanyong.wanfb25d532013-07-28 08:24:00 +0000587inline internal::ElementsAreMatcher<
588 std::tr1::tuple<
589 typename internal::DecayArray<T1>::type> >
590ElementsAre(const T1& e1) {
591 typedef std::tr1::tuple<
592 typename internal::DecayArray<T1>::type> Args;
593 return internal::ElementsAreMatcher<Args>(Args(e1));
shiqiane35fdd92008-12-10 05:08:54 +0000594}
595
596template <typename T1, typename T2>
zhanyong.wanfb25d532013-07-28 08:24:00 +0000597inline internal::ElementsAreMatcher<
598 std::tr1::tuple<
599 typename internal::DecayArray<T1>::type,
600 typename internal::DecayArray<T2>::type> >
601ElementsAre(const T1& e1, const T2& e2) {
602 typedef std::tr1::tuple<
603 typename internal::DecayArray<T1>::type,
604 typename internal::DecayArray<T2>::type> Args;
605 return internal::ElementsAreMatcher<Args>(Args(e1, e2));
shiqiane35fdd92008-12-10 05:08:54 +0000606}
607
608template <typename T1, typename T2, typename T3>
zhanyong.wanfb25d532013-07-28 08:24:00 +0000609inline internal::ElementsAreMatcher<
610 std::tr1::tuple<
611 typename internal::DecayArray<T1>::type,
612 typename internal::DecayArray<T2>::type,
613 typename internal::DecayArray<T3>::type> >
614ElementsAre(const T1& e1, const T2& e2, const T3& e3) {
615 typedef std::tr1::tuple<
616 typename internal::DecayArray<T1>::type,
617 typename internal::DecayArray<T2>::type,
618 typename internal::DecayArray<T3>::type> Args;
619 return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3));
shiqiane35fdd92008-12-10 05:08:54 +0000620}
621
622template <typename T1, typename T2, typename T3, typename T4>
zhanyong.wanfb25d532013-07-28 08:24:00 +0000623inline internal::ElementsAreMatcher<
624 std::tr1::tuple<
625 typename internal::DecayArray<T1>::type,
626 typename internal::DecayArray<T2>::type,
627 typename internal::DecayArray<T3>::type,
628 typename internal::DecayArray<T4>::type> >
629ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4) {
630 typedef std::tr1::tuple<
631 typename internal::DecayArray<T1>::type,
632 typename internal::DecayArray<T2>::type,
633 typename internal::DecayArray<T3>::type,
634 typename internal::DecayArray<T4>::type> Args;
635 return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4));
shiqiane35fdd92008-12-10 05:08:54 +0000636}
637
638template <typename T1, typename T2, typename T3, typename T4, typename T5>
zhanyong.wanfb25d532013-07-28 08:24:00 +0000639inline internal::ElementsAreMatcher<
640 std::tr1::tuple<
641 typename internal::DecayArray<T1>::type,
642 typename internal::DecayArray<T2>::type,
643 typename internal::DecayArray<T3>::type,
644 typename internal::DecayArray<T4>::type,
645 typename internal::DecayArray<T5>::type> >
646ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
shiqiane35fdd92008-12-10 05:08:54 +0000647 const T5& e5) {
zhanyong.wanfb25d532013-07-28 08:24:00 +0000648 typedef std::tr1::tuple<
649 typename internal::DecayArray<T1>::type,
650 typename internal::DecayArray<T2>::type,
651 typename internal::DecayArray<T3>::type,
652 typename internal::DecayArray<T4>::type,
653 typename internal::DecayArray<T5>::type> Args;
654 return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5));
shiqiane35fdd92008-12-10 05:08:54 +0000655}
656
657template <typename T1, typename T2, typename T3, typename T4, typename T5,
658 typename T6>
zhanyong.wanfb25d532013-07-28 08:24:00 +0000659inline internal::ElementsAreMatcher<
660 std::tr1::tuple<
661 typename internal::DecayArray<T1>::type,
662 typename internal::DecayArray<T2>::type,
663 typename internal::DecayArray<T3>::type,
664 typename internal::DecayArray<T4>::type,
665 typename internal::DecayArray<T5>::type,
666 typename internal::DecayArray<T6>::type> >
667ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
shiqiane35fdd92008-12-10 05:08:54 +0000668 const T5& e5, const T6& e6) {
zhanyong.wanfb25d532013-07-28 08:24:00 +0000669 typedef std::tr1::tuple<
670 typename internal::DecayArray<T1>::type,
671 typename internal::DecayArray<T2>::type,
672 typename internal::DecayArray<T3>::type,
673 typename internal::DecayArray<T4>::type,
674 typename internal::DecayArray<T5>::type,
675 typename internal::DecayArray<T6>::type> Args;
676 return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6));
shiqiane35fdd92008-12-10 05:08:54 +0000677}
678
679template <typename T1, typename T2, typename T3, typename T4, typename T5,
680 typename T6, typename T7>
zhanyong.wanfb25d532013-07-28 08:24:00 +0000681inline internal::ElementsAreMatcher<
682 std::tr1::tuple<
683 typename internal::DecayArray<T1>::type,
684 typename internal::DecayArray<T2>::type,
685 typename internal::DecayArray<T3>::type,
686 typename internal::DecayArray<T4>::type,
687 typename internal::DecayArray<T5>::type,
688 typename internal::DecayArray<T6>::type,
689 typename internal::DecayArray<T7>::type> >
690ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
shiqiane35fdd92008-12-10 05:08:54 +0000691 const T5& e5, const T6& e6, const T7& e7) {
zhanyong.wanfb25d532013-07-28 08:24:00 +0000692 typedef std::tr1::tuple<
693 typename internal::DecayArray<T1>::type,
694 typename internal::DecayArray<T2>::type,
695 typename internal::DecayArray<T3>::type,
696 typename internal::DecayArray<T4>::type,
697 typename internal::DecayArray<T5>::type,
698 typename internal::DecayArray<T6>::type,
699 typename internal::DecayArray<T7>::type> Args;
700 return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7));
shiqiane35fdd92008-12-10 05:08:54 +0000701}
702
703template <typename T1, typename T2, typename T3, typename T4, typename T5,
704 typename T6, typename T7, typename T8>
zhanyong.wanfb25d532013-07-28 08:24:00 +0000705inline internal::ElementsAreMatcher<
706 std::tr1::tuple<
707 typename internal::DecayArray<T1>::type,
708 typename internal::DecayArray<T2>::type,
709 typename internal::DecayArray<T3>::type,
710 typename internal::DecayArray<T4>::type,
711 typename internal::DecayArray<T5>::type,
712 typename internal::DecayArray<T6>::type,
713 typename internal::DecayArray<T7>::type,
714 typename internal::DecayArray<T8>::type> >
715ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
shiqiane35fdd92008-12-10 05:08:54 +0000716 const T5& e5, const T6& e6, const T7& e7, const T8& e8) {
zhanyong.wanfb25d532013-07-28 08:24:00 +0000717 typedef std::tr1::tuple<
718 typename internal::DecayArray<T1>::type,
719 typename internal::DecayArray<T2>::type,
720 typename internal::DecayArray<T3>::type,
721 typename internal::DecayArray<T4>::type,
722 typename internal::DecayArray<T5>::type,
723 typename internal::DecayArray<T6>::type,
724 typename internal::DecayArray<T7>::type,
725 typename internal::DecayArray<T8>::type> Args;
726 return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7,
727 e8));
shiqiane35fdd92008-12-10 05:08:54 +0000728}
729
730template <typename T1, typename T2, typename T3, typename T4, typename T5,
731 typename T6, typename T7, typename T8, typename T9>
zhanyong.wanfb25d532013-07-28 08:24:00 +0000732inline internal::ElementsAreMatcher<
733 std::tr1::tuple<
734 typename internal::DecayArray<T1>::type,
735 typename internal::DecayArray<T2>::type,
736 typename internal::DecayArray<T3>::type,
737 typename internal::DecayArray<T4>::type,
738 typename internal::DecayArray<T5>::type,
739 typename internal::DecayArray<T6>::type,
740 typename internal::DecayArray<T7>::type,
741 typename internal::DecayArray<T8>::type,
742 typename internal::DecayArray<T9>::type> >
743ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
shiqiane35fdd92008-12-10 05:08:54 +0000744 const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9) {
zhanyong.wanfb25d532013-07-28 08:24:00 +0000745 typedef std::tr1::tuple<
746 typename internal::DecayArray<T1>::type,
747 typename internal::DecayArray<T2>::type,
748 typename internal::DecayArray<T3>::type,
749 typename internal::DecayArray<T4>::type,
750 typename internal::DecayArray<T5>::type,
751 typename internal::DecayArray<T6>::type,
752 typename internal::DecayArray<T7>::type,
753 typename internal::DecayArray<T8>::type,
754 typename internal::DecayArray<T9>::type> Args;
755 return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7,
756 e8, e9));
shiqiane35fdd92008-12-10 05:08:54 +0000757}
758
759template <typename T1, typename T2, typename T3, typename T4, typename T5,
760 typename T6, typename T7, typename T8, typename T9, typename T10>
zhanyong.wanfb25d532013-07-28 08:24:00 +0000761inline internal::ElementsAreMatcher<
762 std::tr1::tuple<
763 typename internal::DecayArray<T1>::type,
764 typename internal::DecayArray<T2>::type,
765 typename internal::DecayArray<T3>::type,
766 typename internal::DecayArray<T4>::type,
767 typename internal::DecayArray<T5>::type,
768 typename internal::DecayArray<T6>::type,
769 typename internal::DecayArray<T7>::type,
770 typename internal::DecayArray<T8>::type,
771 typename internal::DecayArray<T9>::type,
772 typename internal::DecayArray<T10>::type> >
773ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
shiqiane35fdd92008-12-10 05:08:54 +0000774 const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,
775 const T10& e10) {
zhanyong.wanfb25d532013-07-28 08:24:00 +0000776 typedef std::tr1::tuple<
777 typename internal::DecayArray<T1>::type,
778 typename internal::DecayArray<T2>::type,
779 typename internal::DecayArray<T3>::type,
780 typename internal::DecayArray<T4>::type,
781 typename internal::DecayArray<T5>::type,
782 typename internal::DecayArray<T6>::type,
783 typename internal::DecayArray<T7>::type,
784 typename internal::DecayArray<T8>::type,
785 typename internal::DecayArray<T9>::type,
786 typename internal::DecayArray<T10>::type> Args;
787 return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7,
788 e8, e9, e10));
shiqiane35fdd92008-12-10 05:08:54 +0000789}
790
zhanyong.wanfb25d532013-07-28 08:24:00 +0000791// UnorderedElementsAre(e_1, e_2, ..., e_n) is an ElementsAre extension
792// that matches n elements in any order. We support up to n=10 arguments.
793
794inline internal::UnorderedElementsAreMatcher<
795 std::tr1::tuple<> >
796UnorderedElementsAre() {
797 typedef std::tr1::tuple<> Args;
798 return internal::UnorderedElementsAreMatcher<Args>(Args());
shiqiane35fdd92008-12-10 05:08:54 +0000799}
800
zhanyong.wanfb25d532013-07-28 08:24:00 +0000801template <typename T1>
802inline internal::UnorderedElementsAreMatcher<
803 std::tr1::tuple<
804 typename internal::DecayArray<T1>::type> >
805UnorderedElementsAre(const T1& e1) {
806 typedef std::tr1::tuple<
807 typename internal::DecayArray<T1>::type> Args;
808 return internal::UnorderedElementsAreMatcher<Args>(Args(e1));
shiqiane35fdd92008-12-10 05:08:54 +0000809}
810
zhanyong.wanfb25d532013-07-28 08:24:00 +0000811template <typename T1, typename T2>
812inline internal::UnorderedElementsAreMatcher<
813 std::tr1::tuple<
814 typename internal::DecayArray<T1>::type,
815 typename internal::DecayArray<T2>::type> >
816UnorderedElementsAre(const T1& e1, const T2& e2) {
817 typedef std::tr1::tuple<
818 typename internal::DecayArray<T1>::type,
819 typename internal::DecayArray<T2>::type> Args;
820 return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2));
jgm38513a82012-11-15 15:50:36 +0000821}
822
zhanyong.wanfb25d532013-07-28 08:24:00 +0000823template <typename T1, typename T2, typename T3>
824inline internal::UnorderedElementsAreMatcher<
825 std::tr1::tuple<
826 typename internal::DecayArray<T1>::type,
827 typename internal::DecayArray<T2>::type,
828 typename internal::DecayArray<T3>::type> >
829UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3) {
830 typedef std::tr1::tuple<
831 typename internal::DecayArray<T1>::type,
832 typename internal::DecayArray<T2>::type,
833 typename internal::DecayArray<T3>::type> Args;
834 return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3));
jgm38513a82012-11-15 15:50:36 +0000835}
836
zhanyong.wanfb25d532013-07-28 08:24:00 +0000837template <typename T1, typename T2, typename T3, typename T4>
838inline internal::UnorderedElementsAreMatcher<
839 std::tr1::tuple<
840 typename internal::DecayArray<T1>::type,
841 typename internal::DecayArray<T2>::type,
842 typename internal::DecayArray<T3>::type,
843 typename internal::DecayArray<T4>::type> >
844UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4) {
845 typedef std::tr1::tuple<
846 typename internal::DecayArray<T1>::type,
847 typename internal::DecayArray<T2>::type,
848 typename internal::DecayArray<T3>::type,
849 typename internal::DecayArray<T4>::type> Args;
850 return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4));
851}
852
853template <typename T1, typename T2, typename T3, typename T4, typename T5>
854inline internal::UnorderedElementsAreMatcher<
855 std::tr1::tuple<
856 typename internal::DecayArray<T1>::type,
857 typename internal::DecayArray<T2>::type,
858 typename internal::DecayArray<T3>::type,
859 typename internal::DecayArray<T4>::type,
860 typename internal::DecayArray<T5>::type> >
861UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
862 const T5& e5) {
863 typedef std::tr1::tuple<
864 typename internal::DecayArray<T1>::type,
865 typename internal::DecayArray<T2>::type,
866 typename internal::DecayArray<T3>::type,
867 typename internal::DecayArray<T4>::type,
868 typename internal::DecayArray<T5>::type> Args;
869 return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5));
870}
871
872template <typename T1, typename T2, typename T3, typename T4, typename T5,
873 typename T6>
874inline internal::UnorderedElementsAreMatcher<
875 std::tr1::tuple<
876 typename internal::DecayArray<T1>::type,
877 typename internal::DecayArray<T2>::type,
878 typename internal::DecayArray<T3>::type,
879 typename internal::DecayArray<T4>::type,
880 typename internal::DecayArray<T5>::type,
881 typename internal::DecayArray<T6>::type> >
882UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
883 const T5& e5, const T6& e6) {
884 typedef std::tr1::tuple<
885 typename internal::DecayArray<T1>::type,
886 typename internal::DecayArray<T2>::type,
887 typename internal::DecayArray<T3>::type,
888 typename internal::DecayArray<T4>::type,
889 typename internal::DecayArray<T5>::type,
890 typename internal::DecayArray<T6>::type> Args;
891 return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
892 e6));
893}
894
895template <typename T1, typename T2, typename T3, typename T4, typename T5,
896 typename T6, typename T7>
897inline internal::UnorderedElementsAreMatcher<
898 std::tr1::tuple<
899 typename internal::DecayArray<T1>::type,
900 typename internal::DecayArray<T2>::type,
901 typename internal::DecayArray<T3>::type,
902 typename internal::DecayArray<T4>::type,
903 typename internal::DecayArray<T5>::type,
904 typename internal::DecayArray<T6>::type,
905 typename internal::DecayArray<T7>::type> >
906UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
907 const T5& e5, const T6& e6, const T7& e7) {
908 typedef std::tr1::tuple<
909 typename internal::DecayArray<T1>::type,
910 typename internal::DecayArray<T2>::type,
911 typename internal::DecayArray<T3>::type,
912 typename internal::DecayArray<T4>::type,
913 typename internal::DecayArray<T5>::type,
914 typename internal::DecayArray<T6>::type,
915 typename internal::DecayArray<T7>::type> Args;
916 return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
917 e6, e7));
918}
919
920template <typename T1, typename T2, typename T3, typename T4, typename T5,
921 typename T6, typename T7, typename T8>
922inline internal::UnorderedElementsAreMatcher<
923 std::tr1::tuple<
924 typename internal::DecayArray<T1>::type,
925 typename internal::DecayArray<T2>::type,
926 typename internal::DecayArray<T3>::type,
927 typename internal::DecayArray<T4>::type,
928 typename internal::DecayArray<T5>::type,
929 typename internal::DecayArray<T6>::type,
930 typename internal::DecayArray<T7>::type,
931 typename internal::DecayArray<T8>::type> >
932UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
933 const T5& e5, const T6& e6, const T7& e7, const T8& e8) {
934 typedef std::tr1::tuple<
935 typename internal::DecayArray<T1>::type,
936 typename internal::DecayArray<T2>::type,
937 typename internal::DecayArray<T3>::type,
938 typename internal::DecayArray<T4>::type,
939 typename internal::DecayArray<T5>::type,
940 typename internal::DecayArray<T6>::type,
941 typename internal::DecayArray<T7>::type,
942 typename internal::DecayArray<T8>::type> Args;
943 return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
944 e6, e7, e8));
945}
946
947template <typename T1, typename T2, typename T3, typename T4, typename T5,
948 typename T6, typename T7, typename T8, typename T9>
949inline internal::UnorderedElementsAreMatcher<
950 std::tr1::tuple<
951 typename internal::DecayArray<T1>::type,
952 typename internal::DecayArray<T2>::type,
953 typename internal::DecayArray<T3>::type,
954 typename internal::DecayArray<T4>::type,
955 typename internal::DecayArray<T5>::type,
956 typename internal::DecayArray<T6>::type,
957 typename internal::DecayArray<T7>::type,
958 typename internal::DecayArray<T8>::type,
959 typename internal::DecayArray<T9>::type> >
960UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
961 const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9) {
962 typedef std::tr1::tuple<
963 typename internal::DecayArray<T1>::type,
964 typename internal::DecayArray<T2>::type,
965 typename internal::DecayArray<T3>::type,
966 typename internal::DecayArray<T4>::type,
967 typename internal::DecayArray<T5>::type,
968 typename internal::DecayArray<T6>::type,
969 typename internal::DecayArray<T7>::type,
970 typename internal::DecayArray<T8>::type,
971 typename internal::DecayArray<T9>::type> Args;
972 return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
973 e6, e7, e8, e9));
974}
975
976template <typename T1, typename T2, typename T3, typename T4, typename T5,
977 typename T6, typename T7, typename T8, typename T9, typename T10>
978inline internal::UnorderedElementsAreMatcher<
979 std::tr1::tuple<
980 typename internal::DecayArray<T1>::type,
981 typename internal::DecayArray<T2>::type,
982 typename internal::DecayArray<T3>::type,
983 typename internal::DecayArray<T4>::type,
984 typename internal::DecayArray<T5>::type,
985 typename internal::DecayArray<T6>::type,
986 typename internal::DecayArray<T7>::type,
987 typename internal::DecayArray<T8>::type,
988 typename internal::DecayArray<T9>::type,
989 typename internal::DecayArray<T10>::type> >
990UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
991 const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,
992 const T10& e10) {
993 typedef std::tr1::tuple<
994 typename internal::DecayArray<T1>::type,
995 typename internal::DecayArray<T2>::type,
996 typename internal::DecayArray<T3>::type,
997 typename internal::DecayArray<T4>::type,
998 typename internal::DecayArray<T5>::type,
999 typename internal::DecayArray<T6>::type,
1000 typename internal::DecayArray<T7>::type,
1001 typename internal::DecayArray<T8>::type,
1002 typename internal::DecayArray<T9>::type,
1003 typename internal::DecayArray<T10>::type> Args;
1004 return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
1005 e6, e7, e8, e9, e10));
1006}
jgm38513a82012-11-15 15:50:36 +00001007
zhanyong.wan02c15052010-06-09 19:21:30 +00001008// AllOf(m1, m2, ..., mk) matches any value that matches all of the given
zhanyong.wan86d2eeb2011-03-16 17:10:39 +00001009// sub-matchers. AllOf is called fully qualified to prevent ADL from firing.
zhanyong.wan02c15052010-06-09 19:21:30 +00001010
jgm79a367e2012-04-10 16:02:11 +00001011template <typename M1, typename M2>
1012inline typename internal::AllOfResult2<M1, M2>::type
1013AllOf(M1 m1, M2 m2) {
1014 return typename internal::AllOfResult2<M1, M2>::type(
1015 m1,
1016 m2);
zhanyong.wan02c15052010-06-09 19:21:30 +00001017}
1018
jgm79a367e2012-04-10 16:02:11 +00001019template <typename M1, typename M2, typename M3>
1020inline typename internal::AllOfResult3<M1, M2, M3>::type
1021AllOf(M1 m1, M2 m2, M3 m3) {
1022 return typename internal::AllOfResult3<M1, M2, M3>::type(
1023 m1,
1024 ::testing::AllOf(m2, m3));
zhanyong.wan02c15052010-06-09 19:21:30 +00001025}
1026
jgm79a367e2012-04-10 16:02:11 +00001027template <typename M1, typename M2, typename M3, typename M4>
1028inline typename internal::AllOfResult4<M1, M2, M3, M4>::type
1029AllOf(M1 m1, M2 m2, M3 m3, M4 m4) {
1030 return typename internal::AllOfResult4<M1, M2, M3, M4>::type(
1031 ::testing::AllOf(m1, m2),
1032 ::testing::AllOf(m3, m4));
zhanyong.wan02c15052010-06-09 19:21:30 +00001033}
1034
jgm79a367e2012-04-10 16:02:11 +00001035template <typename M1, typename M2, typename M3, typename M4, typename M5>
1036inline typename internal::AllOfResult5<M1, M2, M3, M4, M5>::type
1037AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5) {
1038 return typename internal::AllOfResult5<M1, M2, M3, M4, M5>::type(
1039 ::testing::AllOf(m1, m2),
1040 ::testing::AllOf(m3, m4, m5));
zhanyong.wan02c15052010-06-09 19:21:30 +00001041}
1042
jgm79a367e2012-04-10 16:02:11 +00001043template <typename M1, typename M2, typename M3, typename M4, typename M5,
1044 typename M6>
1045inline typename internal::AllOfResult6<M1, M2, M3, M4, M5, M6>::type
1046AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6) {
1047 return typename internal::AllOfResult6<M1, M2, M3, M4, M5, M6>::type(
1048 ::testing::AllOf(m1, m2, m3),
1049 ::testing::AllOf(m4, m5, m6));
zhanyong.wan02c15052010-06-09 19:21:30 +00001050}
1051
jgm79a367e2012-04-10 16:02:11 +00001052template <typename M1, typename M2, typename M3, typename M4, typename M5,
1053 typename M6, typename M7>
1054inline typename internal::AllOfResult7<M1, M2, M3, M4, M5, M6, M7>::type
1055AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7) {
1056 return typename internal::AllOfResult7<M1, M2, M3, M4, M5, M6, M7>::type(
1057 ::testing::AllOf(m1, m2, m3),
1058 ::testing::AllOf(m4, m5, m6, m7));
zhanyong.wan02c15052010-06-09 19:21:30 +00001059}
1060
jgm79a367e2012-04-10 16:02:11 +00001061template <typename M1, typename M2, typename M3, typename M4, typename M5,
1062 typename M6, typename M7, typename M8>
1063inline typename internal::AllOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type
1064AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8) {
1065 return typename internal::AllOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type(
1066 ::testing::AllOf(m1, m2, m3, m4),
1067 ::testing::AllOf(m5, m6, m7, m8));
zhanyong.wan02c15052010-06-09 19:21:30 +00001068}
1069
jgm79a367e2012-04-10 16:02:11 +00001070template <typename M1, typename M2, typename M3, typename M4, typename M5,
1071 typename M6, typename M7, typename M8, typename M9>
1072inline typename internal::AllOfResult9<M1, M2, M3, M4, M5, M6, M7, M8, M9>::type
1073AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9) {
1074 return typename internal::AllOfResult9<M1, M2, M3, M4, M5, M6, M7, M8,
1075 M9>::type(
1076 ::testing::AllOf(m1, m2, m3, m4),
1077 ::testing::AllOf(m5, m6, m7, m8, m9));
zhanyong.wan02c15052010-06-09 19:21:30 +00001078}
1079
jgm79a367e2012-04-10 16:02:11 +00001080template <typename M1, typename M2, typename M3, typename M4, typename M5,
1081 typename M6, typename M7, typename M8, typename M9, typename M10>
1082inline typename internal::AllOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
1083 M10>::type
1084AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
1085 return typename internal::AllOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
1086 M10>::type(
1087 ::testing::AllOf(m1, m2, m3, m4, m5),
1088 ::testing::AllOf(m6, m7, m8, m9, m10));
zhanyong.wan02c15052010-06-09 19:21:30 +00001089}
1090
1091// AnyOf(m1, m2, ..., mk) matches any value that matches any of the given
zhanyong.wan86d2eeb2011-03-16 17:10:39 +00001092// sub-matchers. AnyOf is called fully qualified to prevent ADL from firing.
zhanyong.wan02c15052010-06-09 19:21:30 +00001093
jgm79a367e2012-04-10 16:02:11 +00001094template <typename M1, typename M2>
1095inline typename internal::AnyOfResult2<M1, M2>::type
1096AnyOf(M1 m1, M2 m2) {
1097 return typename internal::AnyOfResult2<M1, M2>::type(
1098 m1,
1099 m2);
zhanyong.wan02c15052010-06-09 19:21:30 +00001100}
1101
jgm79a367e2012-04-10 16:02:11 +00001102template <typename M1, typename M2, typename M3>
1103inline typename internal::AnyOfResult3<M1, M2, M3>::type
1104AnyOf(M1 m1, M2 m2, M3 m3) {
1105 return typename internal::AnyOfResult3<M1, M2, M3>::type(
1106 m1,
1107 ::testing::AnyOf(m2, m3));
zhanyong.wan02c15052010-06-09 19:21:30 +00001108}
1109
jgm79a367e2012-04-10 16:02:11 +00001110template <typename M1, typename M2, typename M3, typename M4>
1111inline typename internal::AnyOfResult4<M1, M2, M3, M4>::type
1112AnyOf(M1 m1, M2 m2, M3 m3, M4 m4) {
1113 return typename internal::AnyOfResult4<M1, M2, M3, M4>::type(
1114 ::testing::AnyOf(m1, m2),
1115 ::testing::AnyOf(m3, m4));
zhanyong.wan02c15052010-06-09 19:21:30 +00001116}
1117
jgm79a367e2012-04-10 16:02:11 +00001118template <typename M1, typename M2, typename M3, typename M4, typename M5>
1119inline typename internal::AnyOfResult5<M1, M2, M3, M4, M5>::type
1120AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5) {
1121 return typename internal::AnyOfResult5<M1, M2, M3, M4, M5>::type(
1122 ::testing::AnyOf(m1, m2),
1123 ::testing::AnyOf(m3, m4, m5));
zhanyong.wan02c15052010-06-09 19:21:30 +00001124}
1125
jgm79a367e2012-04-10 16:02:11 +00001126template <typename M1, typename M2, typename M3, typename M4, typename M5,
1127 typename M6>
1128inline typename internal::AnyOfResult6<M1, M2, M3, M4, M5, M6>::type
1129AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6) {
1130 return typename internal::AnyOfResult6<M1, M2, M3, M4, M5, M6>::type(
1131 ::testing::AnyOf(m1, m2, m3),
1132 ::testing::AnyOf(m4, m5, m6));
zhanyong.wan02c15052010-06-09 19:21:30 +00001133}
1134
jgm79a367e2012-04-10 16:02:11 +00001135template <typename M1, typename M2, typename M3, typename M4, typename M5,
1136 typename M6, typename M7>
1137inline typename internal::AnyOfResult7<M1, M2, M3, M4, M5, M6, M7>::type
1138AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7) {
1139 return typename internal::AnyOfResult7<M1, M2, M3, M4, M5, M6, M7>::type(
1140 ::testing::AnyOf(m1, m2, m3),
1141 ::testing::AnyOf(m4, m5, m6, m7));
zhanyong.wan02c15052010-06-09 19:21:30 +00001142}
1143
jgm79a367e2012-04-10 16:02:11 +00001144template <typename M1, typename M2, typename M3, typename M4, typename M5,
1145 typename M6, typename M7, typename M8>
1146inline typename internal::AnyOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type
1147AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8) {
1148 return typename internal::AnyOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type(
1149 ::testing::AnyOf(m1, m2, m3, m4),
1150 ::testing::AnyOf(m5, m6, m7, m8));
zhanyong.wan02c15052010-06-09 19:21:30 +00001151}
1152
jgm79a367e2012-04-10 16:02:11 +00001153template <typename M1, typename M2, typename M3, typename M4, typename M5,
1154 typename M6, typename M7, typename M8, typename M9>
1155inline typename internal::AnyOfResult9<M1, M2, M3, M4, M5, M6, M7, M8, M9>::type
1156AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9) {
1157 return typename internal::AnyOfResult9<M1, M2, M3, M4, M5, M6, M7, M8,
1158 M9>::type(
1159 ::testing::AnyOf(m1, m2, m3, m4),
1160 ::testing::AnyOf(m5, m6, m7, m8, m9));
zhanyong.wan02c15052010-06-09 19:21:30 +00001161}
1162
jgm79a367e2012-04-10 16:02:11 +00001163template <typename M1, typename M2, typename M3, typename M4, typename M5,
1164 typename M6, typename M7, typename M8, typename M9, typename M10>
1165inline typename internal::AnyOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
1166 M10>::type
1167AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
1168 return typename internal::AnyOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
1169 M10>::type(
1170 ::testing::AnyOf(m1, m2, m3, m4, m5),
1171 ::testing::AnyOf(m6, m7, m8, m9, m10));
zhanyong.wan02c15052010-06-09 19:21:30 +00001172}
1173
shiqiane35fdd92008-12-10 05:08:54 +00001174} // namespace testing
1175
zhanyong.wan86d2eeb2011-03-16 17:10:39 +00001176
zhanyong.wance198ff2009-02-12 01:34:27 +00001177// The MATCHER* family of macros can be used in a namespace scope to
zhanyong.wan82113312010-01-08 21:55:40 +00001178// define custom matchers easily.
1179//
1180// Basic Usage
1181// ===========
1182//
1183// The syntax
zhanyong.wance198ff2009-02-12 01:34:27 +00001184//
1185// MATCHER(name, description_string) { statements; }
1186//
zhanyong.wan82113312010-01-08 21:55:40 +00001187// defines a matcher with the given name that executes the statements,
1188// which must return a bool to indicate if the match succeeds. Inside
1189// the statements, you can refer to the value being matched by 'arg',
1190// and refer to its type by 'arg_type'.
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001191//
1192// The description string documents what the matcher does, and is used
1193// to generate the failure message when the match fails. Since a
1194// MATCHER() is usually defined in a header file shared by multiple
1195// C++ source files, we require the description to be a C-string
1196// literal to avoid possible side effects. It can be empty, in which
1197// case we'll use the sequence of words in the matcher name as the
1198// description.
1199//
1200// For example:
zhanyong.wance198ff2009-02-12 01:34:27 +00001201//
1202// MATCHER(IsEven, "") { return (arg % 2) == 0; }
1203//
1204// allows you to write
1205//
1206// // Expects mock_foo.Bar(n) to be called where n is even.
1207// EXPECT_CALL(mock_foo, Bar(IsEven()));
1208//
1209// or,
1210//
1211// // Verifies that the value of some_expression is even.
1212// EXPECT_THAT(some_expression, IsEven());
1213//
1214// If the above assertion fails, it will print something like:
1215//
1216// Value of: some_expression
1217// Expected: is even
1218// Actual: 7
1219//
1220// where the description "is even" is automatically calculated from the
1221// matcher name IsEven.
1222//
zhanyong.wan82113312010-01-08 21:55:40 +00001223// Argument Type
1224// =============
1225//
zhanyong.wance198ff2009-02-12 01:34:27 +00001226// Note that the type of the value being matched (arg_type) is
1227// determined by the context in which you use the matcher and is
1228// supplied to you by the compiler, so you don't need to worry about
1229// declaring it (nor can you). This allows the matcher to be
1230// polymorphic. For example, IsEven() can be used to match any type
1231// where the value of "(arg % 2) == 0" can be implicitly converted to
1232// a bool. In the "Bar(IsEven())" example above, if method Bar()
1233// takes an int, 'arg_type' will be int; if it takes an unsigned long,
1234// 'arg_type' will be unsigned long; and so on.
1235//
zhanyong.wan82113312010-01-08 21:55:40 +00001236// Parameterizing Matchers
1237// =======================
1238//
zhanyong.wance198ff2009-02-12 01:34:27 +00001239// Sometimes you'll want to parameterize the matcher. For that you
1240// can use another macro:
1241//
1242// MATCHER_P(name, param_name, description_string) { statements; }
1243//
1244// For example:
1245//
1246// MATCHER_P(HasAbsoluteValue, value, "") { return abs(arg) == value; }
1247//
1248// will allow you to write:
1249//
1250// EXPECT_THAT(Blah("a"), HasAbsoluteValue(n));
1251//
1252// which may lead to this message (assuming n is 10):
1253//
1254// Value of: Blah("a")
1255// Expected: has absolute value 10
1256// Actual: -9
1257//
1258// Note that both the matcher description and its parameter are
1259// printed, making the message human-friendly.
1260//
1261// In the matcher definition body, you can write 'foo_type' to
1262// reference the type of a parameter named 'foo'. For example, in the
1263// body of MATCHER_P(HasAbsoluteValue, value) above, you can write
1264// 'value_type' to refer to the type of 'value'.
1265//
1266// We also provide MATCHER_P2, MATCHER_P3, ..., up to MATCHER_P10 to
1267// support multi-parameter matchers.
1268//
zhanyong.wan82113312010-01-08 21:55:40 +00001269// Describing Parameterized Matchers
1270// =================================
1271//
zhanyong.wanb4140802010-06-08 22:53:57 +00001272// The last argument to MATCHER*() is a string-typed expression. The
1273// expression can reference all of the matcher's parameters and a
1274// special bool-typed variable named 'negation'. When 'negation' is
1275// false, the expression should evaluate to the matcher's description;
1276// otherwise it should evaluate to the description of the negation of
1277// the matcher. For example,
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001278//
zhanyong.wanb4140802010-06-08 22:53:57 +00001279// using testing::PrintToString;
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001280//
zhanyong.wanb4140802010-06-08 22:53:57 +00001281// MATCHER_P2(InClosedRange, low, hi,
1282// string(negation ? "is not" : "is") + " in range [" +
1283// PrintToString(low) + ", " + PrintToString(hi) + "]") {
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001284// return low <= arg && arg <= hi;
1285// }
1286// ...
1287// EXPECT_THAT(3, InClosedRange(4, 6));
zhanyong.wanb4140802010-06-08 22:53:57 +00001288// EXPECT_THAT(3, Not(InClosedRange(2, 4)));
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001289//
zhanyong.wanb4140802010-06-08 22:53:57 +00001290// would generate two failures that contain the text:
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001291//
1292// Expected: is in range [4, 6]
zhanyong.wanb4140802010-06-08 22:53:57 +00001293// ...
1294// Expected: is not in range [2, 4]
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001295//
1296// If you specify "" as the description, the failure message will
1297// contain the sequence of words in the matcher name followed by the
1298// parameter values printed as a tuple. For example,
1299//
1300// MATCHER_P2(InClosedRange, low, hi, "") { ... }
1301// ...
1302// EXPECT_THAT(3, InClosedRange(4, 6));
zhanyong.wanb4140802010-06-08 22:53:57 +00001303// EXPECT_THAT(3, Not(InClosedRange(2, 4)));
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001304//
zhanyong.wanb4140802010-06-08 22:53:57 +00001305// would generate two failures that contain the text:
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001306//
1307// Expected: in closed range (4, 6)
zhanyong.wanb4140802010-06-08 22:53:57 +00001308// ...
1309// Expected: not (in closed range (2, 4))
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001310//
zhanyong.wan82113312010-01-08 21:55:40 +00001311// Types of Matcher Parameters
1312// ===========================
1313//
zhanyong.wance198ff2009-02-12 01:34:27 +00001314// For the purpose of typing, you can view
1315//
1316// MATCHER_Pk(Foo, p1, ..., pk, description_string) { ... }
1317//
1318// as shorthand for
1319//
1320// template <typename p1_type, ..., typename pk_type>
1321// FooMatcherPk<p1_type, ..., pk_type>
1322// Foo(p1_type p1, ..., pk_type pk) { ... }
1323//
1324// When you write Foo(v1, ..., vk), the compiler infers the types of
1325// the parameters v1, ..., and vk for you. If you are not happy with
1326// the result of the type inference, you can specify the types by
1327// explicitly instantiating the template, as in Foo<long, bool>(5,
1328// false). As said earlier, you don't get to (or need to) specify
1329// 'arg_type' as that's determined by the context in which the matcher
1330// is used. You can assign the result of expression Foo(p1, ..., pk)
1331// to a variable of type FooMatcherPk<p1_type, ..., pk_type>. This
1332// can be useful when composing matchers.
1333//
1334// While you can instantiate a matcher template with reference types,
1335// passing the parameters by pointer usually makes your code more
1336// readable. If, however, you still want to pass a parameter by
1337// reference, be aware that in the failure message generated by the
1338// matcher you will see the value of the referenced object but not its
1339// address.
1340//
zhanyong.wan82113312010-01-08 21:55:40 +00001341// Explaining Match Results
1342// ========================
1343//
1344// Sometimes the matcher description alone isn't enough to explain why
1345// the match has failed or succeeded. For example, when expecting a
1346// long string, it can be very helpful to also print the diff between
1347// the expected string and the actual one. To achieve that, you can
1348// optionally stream additional information to a special variable
1349// named result_listener, whose type is a pointer to class
1350// MatchResultListener:
1351//
1352// MATCHER_P(EqualsLongString, str, "") {
1353// if (arg == str) return true;
1354//
1355// *result_listener << "the difference: "
1356/// << DiffStrings(str, arg);
1357// return false;
1358// }
1359//
1360// Overloading Matchers
1361// ====================
1362//
zhanyong.wance198ff2009-02-12 01:34:27 +00001363// You can overload matchers with different numbers of parameters:
1364//
1365// MATCHER_P(Blah, a, description_string1) { ... }
1366// MATCHER_P2(Blah, a, b, description_string2) { ... }
1367//
zhanyong.wan82113312010-01-08 21:55:40 +00001368// Caveats
1369// =======
zhanyong.wance198ff2009-02-12 01:34:27 +00001370//
zhanyong.wan82113312010-01-08 21:55:40 +00001371// When defining a new matcher, you should also consider implementing
1372// MatcherInterface or using MakePolymorphicMatcher(). These
1373// approaches require more work than the MATCHER* macros, but also
1374// give you more control on the types of the value being matched and
1375// the matcher parameters, which may leads to better compiler error
1376// messages when the matcher is used wrong. They also allow
1377// overloading matchers based on parameter types (as opposed to just
1378// based on the number of parameters).
zhanyong.wance198ff2009-02-12 01:34:27 +00001379//
1380// MATCHER*() can only be used in a namespace scope. The reason is
1381// that C++ doesn't yet allow function-local types to be used to
1382// instantiate templates. The up-coming C++0x standard will fix this.
1383// Once that's done, we'll consider supporting using MATCHER*() inside
1384// a function.
1385//
zhanyong.wan82113312010-01-08 21:55:40 +00001386// More Information
1387// ================
zhanyong.wance198ff2009-02-12 01:34:27 +00001388//
1389// To learn more about using these macros, please search for 'MATCHER'
1390// on http://code.google.com/p/googlemock/wiki/CookBook.
1391
1392#define MATCHER(name, description)\
1393 class name##Matcher {\
1394 public:\
1395 template <typename arg_type>\
1396 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1397 public:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001398 gmock_Impl()\
1399 {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001400 virtual bool MatchAndExplain(\
1401 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001402 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001403 *gmock_os << FormatDescription(false);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001404 }\
zhanyong.wanb4140802010-06-08 22:53:57 +00001405 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1406 *gmock_os << FormatDescription(true);\
1407 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001408 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001409 ::testing::internal::string FormatDescription(bool negation) const {\
1410 const ::testing::internal::string gmock_description = (description);\
1411 if (!gmock_description.empty())\
1412 return gmock_description;\
1413 return ::testing::internal::FormatMatcherDescription(\
jgm79a367e2012-04-10 16:02:11 +00001414 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001415 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1416 ::std::tr1::tuple<>()));\
1417 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001418 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001419 };\
1420 template <typename arg_type>\
1421 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001422 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001423 new gmock_Impl<arg_type>());\
zhanyong.wance198ff2009-02-12 01:34:27 +00001424 }\
1425 name##Matcher() {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001426 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001427 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001428 GTEST_DISALLOW_ASSIGN_(name##Matcher);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001429 };\
1430 inline name##Matcher name() {\
1431 return name##Matcher();\
1432 }\
1433 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001434 bool name##Matcher::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00001435 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00001436 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1437 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001438
1439#define MATCHER_P(name, p0, description)\
1440 template <typename p0##_type>\
1441 class name##MatcherP {\
1442 public:\
1443 template <typename arg_type>\
1444 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1445 public:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001446 explicit gmock_Impl(p0##_type gmock_p0)\
1447 : p0(gmock_p0) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001448 virtual bool MatchAndExplain(\
1449 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001450 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001451 *gmock_os << FormatDescription(false);\
1452 }\
1453 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1454 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001455 }\
1456 p0##_type p0;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001457 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001458 ::testing::internal::string FormatDescription(bool negation) const {\
1459 const ::testing::internal::string gmock_description = (description);\
1460 if (!gmock_description.empty())\
1461 return gmock_description;\
1462 return ::testing::internal::FormatMatcherDescription(\
jgm79a367e2012-04-10 16:02:11 +00001463 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001464 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1465 ::std::tr1::tuple<p0##_type>(p0)));\
1466 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001467 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001468 };\
1469 template <typename arg_type>\
1470 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001471 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001472 new gmock_Impl<arg_type>(p0));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001473 }\
1474 name##MatcherP(p0##_type gmock_p0) : p0(gmock_p0) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001475 }\
1476 p0##_type p0;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001477 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001478 GTEST_DISALLOW_ASSIGN_(name##MatcherP);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001479 };\
1480 template <typename p0##_type>\
1481 inline name##MatcherP<p0##_type> name(p0##_type p0) {\
1482 return name##MatcherP<p0##_type>(p0);\
1483 }\
1484 template <typename p0##_type>\
1485 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001486 bool name##MatcherP<p0##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00001487 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00001488 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1489 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001490
1491#define MATCHER_P2(name, p0, p1, description)\
1492 template <typename p0##_type, typename p1##_type>\
1493 class name##MatcherP2 {\
1494 public:\
1495 template <typename arg_type>\
1496 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1497 public:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001498 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1)\
1499 : p0(gmock_p0), p1(gmock_p1) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001500 virtual bool MatchAndExplain(\
1501 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001502 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001503 *gmock_os << FormatDescription(false);\
1504 }\
1505 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1506 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001507 }\
1508 p0##_type p0;\
1509 p1##_type p1;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001510 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001511 ::testing::internal::string FormatDescription(bool negation) const {\
1512 const ::testing::internal::string gmock_description = (description);\
1513 if (!gmock_description.empty())\
1514 return gmock_description;\
1515 return ::testing::internal::FormatMatcherDescription(\
jgm79a367e2012-04-10 16:02:11 +00001516 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001517 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1518 ::std::tr1::tuple<p0##_type, p1##_type>(p0, p1)));\
1519 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001520 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001521 };\
1522 template <typename arg_type>\
1523 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001524 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001525 new gmock_Impl<arg_type>(p0, p1));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001526 }\
1527 name##MatcherP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
1528 p1(gmock_p1) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001529 }\
1530 p0##_type p0;\
1531 p1##_type p1;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001532 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001533 GTEST_DISALLOW_ASSIGN_(name##MatcherP2);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001534 };\
1535 template <typename p0##_type, typename p1##_type>\
1536 inline name##MatcherP2<p0##_type, p1##_type> name(p0##_type p0, \
1537 p1##_type p1) {\
1538 return name##MatcherP2<p0##_type, p1##_type>(p0, p1);\
1539 }\
1540 template <typename p0##_type, typename p1##_type>\
1541 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001542 bool name##MatcherP2<p0##_type, \
1543 p1##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00001544 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00001545 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1546 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001547
1548#define MATCHER_P3(name, p0, p1, p2, description)\
1549 template <typename p0##_type, typename p1##_type, typename p2##_type>\
1550 class name##MatcherP3 {\
1551 public:\
1552 template <typename arg_type>\
1553 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1554 public:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001555 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2)\
1556 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001557 virtual bool MatchAndExplain(\
1558 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001559 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001560 *gmock_os << FormatDescription(false);\
1561 }\
1562 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1563 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001564 }\
1565 p0##_type p0;\
1566 p1##_type p1;\
1567 p2##_type p2;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001568 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001569 ::testing::internal::string FormatDescription(bool negation) const {\
1570 const ::testing::internal::string gmock_description = (description);\
1571 if (!gmock_description.empty())\
1572 return gmock_description;\
1573 return ::testing::internal::FormatMatcherDescription(\
jgm79a367e2012-04-10 16:02:11 +00001574 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001575 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1576 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type>(p0, p1, \
1577 p2)));\
1578 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001579 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001580 };\
1581 template <typename arg_type>\
1582 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001583 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001584 new gmock_Impl<arg_type>(p0, p1, p2));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001585 }\
1586 name##MatcherP3(p0##_type gmock_p0, p1##_type gmock_p1, \
1587 p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001588 }\
1589 p0##_type p0;\
1590 p1##_type p1;\
1591 p2##_type p2;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001592 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001593 GTEST_DISALLOW_ASSIGN_(name##MatcherP3);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001594 };\
1595 template <typename p0##_type, typename p1##_type, typename p2##_type>\
1596 inline name##MatcherP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0, \
1597 p1##_type p1, p2##_type p2) {\
1598 return name##MatcherP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\
1599 }\
1600 template <typename p0##_type, typename p1##_type, typename p2##_type>\
1601 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001602 bool name##MatcherP3<p0##_type, p1##_type, \
1603 p2##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00001604 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00001605 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1606 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001607
1608#define MATCHER_P4(name, p0, p1, p2, p3, description)\
1609 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1610 typename p3##_type>\
1611 class name##MatcherP4 {\
1612 public:\
1613 template <typename arg_type>\
1614 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1615 public:\
1616 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001617 p3##_type gmock_p3)\
1618 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001619 virtual bool MatchAndExplain(\
1620 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001621 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001622 *gmock_os << FormatDescription(false);\
1623 }\
1624 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1625 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001626 }\
1627 p0##_type p0;\
1628 p1##_type p1;\
1629 p2##_type p2;\
1630 p3##_type p3;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001631 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001632 ::testing::internal::string FormatDescription(bool negation) const {\
1633 const ::testing::internal::string gmock_description = (description);\
1634 if (!gmock_description.empty())\
1635 return gmock_description;\
1636 return ::testing::internal::FormatMatcherDescription(\
jgm79a367e2012-04-10 16:02:11 +00001637 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001638 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1639 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, \
1640 p3##_type>(p0, p1, p2, p3)));\
1641 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001642 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001643 };\
1644 template <typename arg_type>\
1645 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001646 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001647 new gmock_Impl<arg_type>(p0, p1, p2, p3));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001648 }\
1649 name##MatcherP4(p0##_type gmock_p0, p1##_type gmock_p1, \
1650 p2##_type gmock_p2, p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), \
1651 p2(gmock_p2), p3(gmock_p3) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001652 }\
1653 p0##_type p0;\
1654 p1##_type p1;\
1655 p2##_type p2;\
1656 p3##_type p3;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001657 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001658 GTEST_DISALLOW_ASSIGN_(name##MatcherP4);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001659 };\
1660 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1661 typename p3##_type>\
1662 inline name##MatcherP4<p0##_type, p1##_type, p2##_type, \
1663 p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
1664 p3##_type p3) {\
1665 return name##MatcherP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, \
1666 p1, p2, p3);\
1667 }\
1668 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1669 typename p3##_type>\
1670 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001671 bool name##MatcherP4<p0##_type, p1##_type, p2##_type, \
1672 p3##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00001673 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00001674 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1675 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001676
1677#define MATCHER_P5(name, p0, p1, p2, p3, p4, description)\
1678 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1679 typename p3##_type, typename p4##_type>\
1680 class name##MatcherP5 {\
1681 public:\
1682 template <typename arg_type>\
1683 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1684 public:\
1685 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001686 p3##_type gmock_p3, p4##_type gmock_p4)\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001687 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
zhanyong.wanb4140802010-06-08 22:53:57 +00001688 p4(gmock_p4) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001689 virtual bool MatchAndExplain(\
1690 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001691 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001692 *gmock_os << FormatDescription(false);\
1693 }\
1694 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1695 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001696 }\
1697 p0##_type p0;\
1698 p1##_type p1;\
1699 p2##_type p2;\
1700 p3##_type p3;\
1701 p4##_type p4;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001702 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001703 ::testing::internal::string FormatDescription(bool negation) const {\
1704 const ::testing::internal::string gmock_description = (description);\
1705 if (!gmock_description.empty())\
1706 return gmock_description;\
1707 return ::testing::internal::FormatMatcherDescription(\
jgm79a367e2012-04-10 16:02:11 +00001708 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001709 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1710 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1711 p4##_type>(p0, p1, p2, p3, p4)));\
1712 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001713 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001714 };\
1715 template <typename arg_type>\
1716 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001717 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001718 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001719 }\
1720 name##MatcherP5(p0##_type gmock_p0, p1##_type gmock_p1, \
1721 p2##_type gmock_p2, p3##_type gmock_p3, \
1722 p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1723 p3(gmock_p3), p4(gmock_p4) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001724 }\
1725 p0##_type p0;\
1726 p1##_type p1;\
1727 p2##_type p2;\
1728 p3##_type p3;\
1729 p4##_type p4;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001730 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001731 GTEST_DISALLOW_ASSIGN_(name##MatcherP5);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001732 };\
1733 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1734 typename p3##_type, typename p4##_type>\
1735 inline name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1736 p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
1737 p4##_type p4) {\
1738 return name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1739 p4##_type>(p0, p1, p2, p3, p4);\
1740 }\
1741 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1742 typename p3##_type, typename p4##_type>\
1743 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001744 bool name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1745 p4##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00001746 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00001747 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1748 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001749
1750#define MATCHER_P6(name, p0, p1, p2, p3, p4, p5, description)\
1751 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1752 typename p3##_type, typename p4##_type, typename p5##_type>\
1753 class name##MatcherP6 {\
1754 public:\
1755 template <typename arg_type>\
1756 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1757 public:\
1758 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001759 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5)\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001760 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
zhanyong.wanb4140802010-06-08 22:53:57 +00001761 p4(gmock_p4), p5(gmock_p5) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001762 virtual bool MatchAndExplain(\
1763 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001764 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001765 *gmock_os << FormatDescription(false);\
1766 }\
1767 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1768 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001769 }\
1770 p0##_type p0;\
1771 p1##_type p1;\
1772 p2##_type p2;\
1773 p3##_type p3;\
1774 p4##_type p4;\
1775 p5##_type p5;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001776 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001777 ::testing::internal::string FormatDescription(bool negation) const {\
1778 const ::testing::internal::string gmock_description = (description);\
1779 if (!gmock_description.empty())\
1780 return gmock_description;\
1781 return ::testing::internal::FormatMatcherDescription(\
jgm79a367e2012-04-10 16:02:11 +00001782 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001783 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1784 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1785 p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5)));\
1786 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001787 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001788 };\
1789 template <typename arg_type>\
1790 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001791 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001792 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001793 }\
1794 name##MatcherP6(p0##_type gmock_p0, p1##_type gmock_p1, \
1795 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1796 p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1797 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001798 }\
1799 p0##_type p0;\
1800 p1##_type p1;\
1801 p2##_type p2;\
1802 p3##_type p3;\
1803 p4##_type p4;\
1804 p5##_type p5;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001805 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001806 GTEST_DISALLOW_ASSIGN_(name##MatcherP6);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001807 };\
1808 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1809 typename p3##_type, typename p4##_type, typename p5##_type>\
1810 inline name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
1811 p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
1812 p3##_type p3, p4##_type p4, p5##_type p5) {\
1813 return name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
1814 p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\
1815 }\
1816 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1817 typename p3##_type, typename p4##_type, typename p5##_type>\
1818 template <typename arg_type>\
1819 bool name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00001820 p5##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00001821 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00001822 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1823 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001824
1825#define MATCHER_P7(name, p0, p1, p2, p3, p4, p5, p6, description)\
1826 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1827 typename p3##_type, typename p4##_type, typename p5##_type, \
1828 typename p6##_type>\
1829 class name##MatcherP7 {\
1830 public:\
1831 template <typename arg_type>\
1832 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1833 public:\
1834 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1835 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001836 p6##_type gmock_p6)\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001837 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
zhanyong.wanb4140802010-06-08 22:53:57 +00001838 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001839 virtual bool MatchAndExplain(\
1840 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001841 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001842 *gmock_os << FormatDescription(false);\
1843 }\
1844 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1845 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001846 }\
1847 p0##_type p0;\
1848 p1##_type p1;\
1849 p2##_type p2;\
1850 p3##_type p3;\
1851 p4##_type p4;\
1852 p5##_type p5;\
1853 p6##_type p6;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001854 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001855 ::testing::internal::string FormatDescription(bool negation) const {\
1856 const ::testing::internal::string gmock_description = (description);\
1857 if (!gmock_description.empty())\
1858 return gmock_description;\
1859 return ::testing::internal::FormatMatcherDescription(\
jgm79a367e2012-04-10 16:02:11 +00001860 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001861 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1862 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1863 p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, \
1864 p6)));\
1865 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001866 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001867 };\
1868 template <typename arg_type>\
1869 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001870 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001871 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001872 }\
1873 name##MatcherP7(p0##_type gmock_p0, p1##_type gmock_p1, \
1874 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1875 p5##_type gmock_p5, p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), \
1876 p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), \
1877 p6(gmock_p6) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001878 }\
1879 p0##_type p0;\
1880 p1##_type p1;\
1881 p2##_type p2;\
1882 p3##_type p3;\
1883 p4##_type p4;\
1884 p5##_type p5;\
1885 p6##_type p6;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001886 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001887 GTEST_DISALLOW_ASSIGN_(name##MatcherP7);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001888 };\
1889 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1890 typename p3##_type, typename p4##_type, typename p5##_type, \
1891 typename p6##_type>\
1892 inline name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
1893 p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \
1894 p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
1895 p6##_type p6) {\
1896 return name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
1897 p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\
1898 }\
1899 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1900 typename p3##_type, typename p4##_type, typename p5##_type, \
1901 typename p6##_type>\
1902 template <typename arg_type>\
1903 bool name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00001904 p5##_type, p6##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00001905 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00001906 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1907 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001908
1909#define MATCHER_P8(name, p0, p1, p2, p3, p4, p5, p6, p7, description)\
1910 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1911 typename p3##_type, typename p4##_type, typename p5##_type, \
1912 typename p6##_type, typename p7##_type>\
1913 class name##MatcherP8 {\
1914 public:\
1915 template <typename arg_type>\
1916 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1917 public:\
1918 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1919 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001920 p6##_type gmock_p6, p7##_type gmock_p7)\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001921 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
zhanyong.wanb4140802010-06-08 22:53:57 +00001922 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001923 virtual bool MatchAndExplain(\
1924 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001925 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001926 *gmock_os << FormatDescription(false);\
1927 }\
1928 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1929 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001930 }\
1931 p0##_type p0;\
1932 p1##_type p1;\
1933 p2##_type p2;\
1934 p3##_type p3;\
1935 p4##_type p4;\
1936 p5##_type p5;\
1937 p6##_type p6;\
1938 p7##_type p7;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001939 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001940 ::testing::internal::string FormatDescription(bool negation) const {\
1941 const ::testing::internal::string gmock_description = (description);\
1942 if (!gmock_description.empty())\
1943 return gmock_description;\
1944 return ::testing::internal::FormatMatcherDescription(\
jgm79a367e2012-04-10 16:02:11 +00001945 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001946 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1947 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1948 p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, \
1949 p3, p4, p5, p6, p7)));\
1950 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001951 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001952 };\
1953 template <typename arg_type>\
1954 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001955 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001956 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001957 }\
1958 name##MatcherP8(p0##_type gmock_p0, p1##_type gmock_p1, \
1959 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1960 p5##_type gmock_p5, p6##_type gmock_p6, \
1961 p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1962 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
1963 p7(gmock_p7) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001964 }\
1965 p0##_type p0;\
1966 p1##_type p1;\
1967 p2##_type p2;\
1968 p3##_type p3;\
1969 p4##_type p4;\
1970 p5##_type p5;\
1971 p6##_type p6;\
1972 p7##_type p7;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001973 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001974 GTEST_DISALLOW_ASSIGN_(name##MatcherP8);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001975 };\
1976 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1977 typename p3##_type, typename p4##_type, typename p5##_type, \
1978 typename p6##_type, typename p7##_type>\
1979 inline name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
1980 p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \
1981 p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
1982 p6##_type p6, p7##_type p7) {\
1983 return name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
1984 p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5, \
1985 p6, p7);\
1986 }\
1987 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1988 typename p3##_type, typename p4##_type, typename p5##_type, \
1989 typename p6##_type, typename p7##_type>\
1990 template <typename arg_type>\
1991 bool name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00001992 p5##_type, p6##_type, \
1993 p7##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00001994 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00001995 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1996 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001997
1998#define MATCHER_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, description)\
1999 template <typename p0##_type, typename p1##_type, typename p2##_type, \
2000 typename p3##_type, typename p4##_type, typename p5##_type, \
2001 typename p6##_type, typename p7##_type, typename p8##_type>\
2002 class name##MatcherP9 {\
2003 public:\
2004 template <typename arg_type>\
2005 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
2006 public:\
2007 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
2008 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
zhanyong.wanb4140802010-06-08 22:53:57 +00002009 p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8)\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00002010 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
2011 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
zhanyong.wanb4140802010-06-08 22:53:57 +00002012 p8(gmock_p8) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00002013 virtual bool MatchAndExplain(\
2014 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00002015 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00002016 *gmock_os << FormatDescription(false);\
2017 }\
2018 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
2019 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00002020 }\
2021 p0##_type p0;\
2022 p1##_type p1;\
2023 p2##_type p2;\
2024 p3##_type p3;\
2025 p4##_type p4;\
2026 p5##_type p5;\
2027 p6##_type p6;\
2028 p7##_type p7;\
2029 p8##_type p8;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002030 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00002031 ::testing::internal::string FormatDescription(bool negation) const {\
2032 const ::testing::internal::string gmock_description = (description);\
2033 if (!gmock_description.empty())\
2034 return gmock_description;\
2035 return ::testing::internal::FormatMatcherDescription(\
jgm79a367e2012-04-10 16:02:11 +00002036 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00002037 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
2038 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
2039 p4##_type, p5##_type, p6##_type, p7##_type, \
2040 p8##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8)));\
2041 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002042 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00002043 };\
2044 template <typename arg_type>\
2045 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00002046 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00002047 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8));\
zhanyong.wance198ff2009-02-12 01:34:27 +00002048 }\
2049 name##MatcherP9(p0##_type gmock_p0, p1##_type gmock_p1, \
2050 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
2051 p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
2052 p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
2053 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
2054 p8(gmock_p8) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00002055 }\
2056 p0##_type p0;\
2057 p1##_type p1;\
2058 p2##_type p2;\
2059 p3##_type p3;\
2060 p4##_type p4;\
2061 p5##_type p5;\
2062 p6##_type p6;\
2063 p7##_type p7;\
2064 p8##_type p8;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002065 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002066 GTEST_DISALLOW_ASSIGN_(name##MatcherP9);\
zhanyong.wance198ff2009-02-12 01:34:27 +00002067 };\
2068 template <typename p0##_type, typename p1##_type, typename p2##_type, \
2069 typename p3##_type, typename p4##_type, typename p5##_type, \
2070 typename p6##_type, typename p7##_type, typename p8##_type>\
2071 inline name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \
2072 p4##_type, p5##_type, p6##_type, p7##_type, \
2073 p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
2074 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \
2075 p8##_type p8) {\
2076 return name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \
2077 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type>(p0, p1, p2, \
2078 p3, p4, p5, p6, p7, p8);\
2079 }\
2080 template <typename p0##_type, typename p1##_type, typename p2##_type, \
2081 typename p3##_type, typename p4##_type, typename p5##_type, \
2082 typename p6##_type, typename p7##_type, typename p8##_type>\
2083 template <typename arg_type>\
2084 bool name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00002085 p5##_type, p6##_type, p7##_type, \
2086 p8##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00002087 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00002088 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
2089 const
zhanyong.wance198ff2009-02-12 01:34:27 +00002090
2091#define MATCHER_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, description)\
2092 template <typename p0##_type, typename p1##_type, typename p2##_type, \
2093 typename p3##_type, typename p4##_type, typename p5##_type, \
2094 typename p6##_type, typename p7##_type, typename p8##_type, \
2095 typename p9##_type>\
2096 class name##MatcherP10 {\
2097 public:\
2098 template <typename arg_type>\
2099 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
2100 public:\
2101 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
2102 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
2103 p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
zhanyong.wanb4140802010-06-08 22:53:57 +00002104 p9##_type gmock_p9)\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00002105 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
2106 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
zhanyong.wanb4140802010-06-08 22:53:57 +00002107 p8(gmock_p8), p9(gmock_p9) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00002108 virtual bool MatchAndExplain(\
2109 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00002110 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00002111 *gmock_os << FormatDescription(false);\
2112 }\
2113 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
2114 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00002115 }\
2116 p0##_type p0;\
2117 p1##_type p1;\
2118 p2##_type p2;\
2119 p3##_type p3;\
2120 p4##_type p4;\
2121 p5##_type p5;\
2122 p6##_type p6;\
2123 p7##_type p7;\
2124 p8##_type p8;\
2125 p9##_type p9;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002126 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00002127 ::testing::internal::string FormatDescription(bool negation) const {\
2128 const ::testing::internal::string gmock_description = (description);\
2129 if (!gmock_description.empty())\
2130 return gmock_description;\
2131 return ::testing::internal::FormatMatcherDescription(\
jgm79a367e2012-04-10 16:02:11 +00002132 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00002133 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
2134 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
2135 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
2136 p9##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)));\
2137 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002138 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00002139 };\
2140 template <typename arg_type>\
2141 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00002142 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00002143 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9));\
zhanyong.wance198ff2009-02-12 01:34:27 +00002144 }\
2145 name##MatcherP10(p0##_type gmock_p0, p1##_type gmock_p1, \
2146 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
2147 p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
2148 p8##_type gmock_p8, p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), \
2149 p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
2150 p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00002151 }\
2152 p0##_type p0;\
2153 p1##_type p1;\
2154 p2##_type p2;\
2155 p3##_type p3;\
2156 p4##_type p4;\
2157 p5##_type p5;\
2158 p6##_type p6;\
2159 p7##_type p7;\
2160 p8##_type p8;\
2161 p9##_type p9;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002162 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002163 GTEST_DISALLOW_ASSIGN_(name##MatcherP10);\
zhanyong.wance198ff2009-02-12 01:34:27 +00002164 };\
2165 template <typename p0##_type, typename p1##_type, typename p2##_type, \
2166 typename p3##_type, typename p4##_type, typename p5##_type, \
2167 typename p6##_type, typename p7##_type, typename p8##_type, \
2168 typename p9##_type>\
2169 inline name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
2170 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
2171 p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
2172 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
2173 p9##_type p9) {\
2174 return name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
2175 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>(p0, \
2176 p1, p2, p3, p4, p5, p6, p7, p8, p9);\
2177 }\
2178 template <typename p0##_type, typename p1##_type, typename p2##_type, \
2179 typename p3##_type, typename p4##_type, typename p5##_type, \
2180 typename p6##_type, typename p7##_type, typename p8##_type, \
2181 typename p9##_type>\
2182 template <typename arg_type>\
2183 bool name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00002184 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
2185 p9##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00002186 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00002187 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
2188 const
zhanyong.wance198ff2009-02-12 01:34:27 +00002189
shiqiane35fdd92008-12-10 05:08:54 +00002190#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_