• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // This file was GENERATED by command:
2 //     pump.py gmock-generated-matchers.h.pump
3 // DO NOT EDIT BY HAND!!!
4 
5 // Copyright 2008, Google Inc.
6 // All rights reserved.
7 //
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions are
10 // met:
11 //
12 //     * Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 //     * Redistributions in binary form must reproduce the above
15 // copyright notice, this list of conditions and the following disclaimer
16 // in the documentation and/or other materials provided with the
17 // distribution.
18 //     * Neither the name of Google Inc. nor the names of its
19 // contributors may be used to endorse or promote products derived from
20 // this software without specific prior written permission.
21 //
22 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 
34 // Google Mock - a framework for writing C++ mock classes.
35 //
36 // This file implements some commonly used variadic matchers.
37 
38 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
39 #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
40 
41 #include <sstream>
42 #include <string>
43 #include <vector>
44 #include "gmock/gmock-matchers.h"
45 
46 namespace testing {
47 namespace internal {
48 
49 // The type of the i-th (0-based) field of Tuple.
50 #define GMOCK_FIELD_TYPE_(Tuple, i) \
51     typename ::std::tr1::tuple_element<i, Tuple>::type
52 
53 // TupleFields<Tuple, k0, ..., kn> is for selecting fields from a
54 // tuple of type Tuple.  It has two members:
55 //
56 //   type: a tuple type whose i-th field is the ki-th field of Tuple.
57 //   GetSelectedFields(t): returns fields k0, ..., and kn of t as a tuple.
58 //
59 // For example, in class TupleFields<tuple<bool, char, int>, 2, 0>, we have:
60 //
61 //   type is tuple<int, bool>, and
62 //   GetSelectedFields(make_tuple(true, 'a', 42)) is (42, true).
63 
64 template <class Tuple, int k0 = -1, int k1 = -1, int k2 = -1, int k3 = -1,
65     int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
66     int k9 = -1>
67 class TupleFields;
68 
69 // This generic version is used when there are 10 selectors.
70 template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
71     int k7, int k8, int k9>
72 class TupleFields {
73  public:
74   typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
75       GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
76       GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
77       GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
78       GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8),
79       GMOCK_FIELD_TYPE_(Tuple, k9)> type;
GetSelectedFields(const Tuple & t)80   static type GetSelectedFields(const Tuple& t) {
81     using ::std::tr1::get;
82     return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
83         get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t), get<k9>(t));
84   }
85 };
86 
87 // The following specialization is used for 0 ~ 9 selectors.
88 
89 template <class Tuple>
90 class TupleFields<Tuple, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
91  public:
92   typedef ::std::tr1::tuple<> type;
GetSelectedFields(const Tuple &)93   static type GetSelectedFields(const Tuple& /* t */) {
94     using ::std::tr1::get;
95     return type();
96   }
97 };
98 
99 template <class Tuple, int k0>
100 class TupleFields<Tuple, k0, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
101  public:
102   typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0)> type;
GetSelectedFields(const Tuple & t)103   static type GetSelectedFields(const Tuple& t) {
104     using ::std::tr1::get;
105     return type(get<k0>(t));
106   }
107 };
108 
109 template <class Tuple, int k0, int k1>
110 class TupleFields<Tuple, k0, k1, -1, -1, -1, -1, -1, -1, -1, -1> {
111  public:
112   typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
113       GMOCK_FIELD_TYPE_(Tuple, k1)> type;
GetSelectedFields(const Tuple & t)114   static type GetSelectedFields(const Tuple& t) {
115     using ::std::tr1::get;
116     return type(get<k0>(t), get<k1>(t));
117   }
118 };
119 
120 template <class Tuple, int k0, int k1, int k2>
121 class TupleFields<Tuple, k0, k1, k2, -1, -1, -1, -1, -1, -1, -1> {
122  public:
123   typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
124       GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2)> type;
GetSelectedFields(const Tuple & t)125   static type GetSelectedFields(const Tuple& t) {
126     using ::std::tr1::get;
127     return type(get<k0>(t), get<k1>(t), get<k2>(t));
128   }
129 };
130 
131 template <class Tuple, int k0, int k1, int k2, int k3>
132 class TupleFields<Tuple, k0, k1, k2, k3, -1, -1, -1, -1, -1, -1> {
133  public:
134   typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
135       GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
136       GMOCK_FIELD_TYPE_(Tuple, k3)> type;
GetSelectedFields(const Tuple & t)137   static type GetSelectedFields(const Tuple& t) {
138     using ::std::tr1::get;
139     return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t));
140   }
141 };
142 
143 template <class Tuple, int k0, int k1, int k2, int k3, int k4>
144 class TupleFields<Tuple, k0, k1, k2, k3, k4, -1, -1, -1, -1, -1> {
145  public:
146   typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
147       GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
148       GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4)> type;
GetSelectedFields(const Tuple & t)149   static type GetSelectedFields(const Tuple& t) {
150     using ::std::tr1::get;
151     return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t));
152   }
153 };
154 
155 template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5>
156 class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, -1, -1, -1, -1> {
157  public:
158   typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
159       GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
160       GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
161       GMOCK_FIELD_TYPE_(Tuple, k5)> type;
GetSelectedFields(const Tuple & t)162   static type GetSelectedFields(const Tuple& t) {
163     using ::std::tr1::get;
164     return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
165         get<k5>(t));
166   }
167 };
168 
169 template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6>
170 class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, -1, -1, -1> {
171  public:
172   typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
173       GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
174       GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
175       GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6)> type;
GetSelectedFields(const Tuple & t)176   static type GetSelectedFields(const Tuple& t) {
177     using ::std::tr1::get;
178     return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
179         get<k5>(t), get<k6>(t));
180   }
181 };
182 
183 template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
184     int k7>
185 class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, -1, -1> {
186  public:
187   typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
188       GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
189       GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
190       GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
191       GMOCK_FIELD_TYPE_(Tuple, k7)> type;
GetSelectedFields(const Tuple & t)192   static type GetSelectedFields(const Tuple& t) {
193     using ::std::tr1::get;
194     return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
195         get<k5>(t), get<k6>(t), get<k7>(t));
196   }
197 };
198 
199 template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
200     int k7, int k8>
201 class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, k8, -1> {
202  public:
203   typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
204       GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
205       GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
206       GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
207       GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8)> type;
GetSelectedFields(const Tuple & t)208   static type GetSelectedFields(const Tuple& t) {
209     using ::std::tr1::get;
210     return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
211         get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t));
212   }
213 };
214 
215 #undef GMOCK_FIELD_TYPE_
216 
217 // Implements the Args() matcher.
218 template <class ArgsTuple, int k0 = -1, int k1 = -1, int k2 = -1, int k3 = -1,
219     int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
220     int k9 = -1>
221 class ArgsMatcherImpl : public MatcherInterface<ArgsTuple> {
222  public:
223   // ArgsTuple may have top-level const or reference modifiers.
224   typedef GTEST_REMOVE_REFERENCE_AND_CONST_(ArgsTuple) RawArgsTuple;
225   typedef typename internal::TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5,
226       k6, k7, k8, k9>::type SelectedArgs;
227   typedef Matcher<const SelectedArgs&> MonomorphicInnerMatcher;
228 
229   template <typename InnerMatcher>
ArgsMatcherImpl(const InnerMatcher & inner_matcher)230   explicit ArgsMatcherImpl(const InnerMatcher& inner_matcher)
231       : inner_matcher_(SafeMatcherCast<const SelectedArgs&>(inner_matcher)) {}
232 
MatchAndExplain(ArgsTuple args,MatchResultListener * listener)233   virtual bool MatchAndExplain(ArgsTuple args,
234                                MatchResultListener* listener) const {
235     const SelectedArgs& selected_args = GetSelectedArgs(args);
236     if (!listener->IsInterested())
237       return inner_matcher_.Matches(selected_args);
238 
239     PrintIndices(listener->stream());
240     *listener << "are " << PrintToString(selected_args);
241 
242     StringMatchResultListener inner_listener;
243     const bool match = inner_matcher_.MatchAndExplain(selected_args,
244                                                       &inner_listener);
245     PrintIfNotEmpty(inner_listener.str(), listener->stream());
246     return match;
247   }
248 
DescribeTo(::std::ostream * os)249   virtual void DescribeTo(::std::ostream* os) const {
250     *os << "are a tuple ";
251     PrintIndices(os);
252     inner_matcher_.DescribeTo(os);
253   }
254 
DescribeNegationTo(::std::ostream * os)255   virtual void DescribeNegationTo(::std::ostream* os) const {
256     *os << "are a tuple ";
257     PrintIndices(os);
258     inner_matcher_.DescribeNegationTo(os);
259   }
260 
261  private:
GetSelectedArgs(ArgsTuple args)262   static SelectedArgs GetSelectedArgs(ArgsTuple args) {
263     return TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5, k6, k7, k8,
264         k9>::GetSelectedFields(args);
265   }
266 
267   // Prints the indices of the selected fields.
PrintIndices(::std::ostream * os)268   static void PrintIndices(::std::ostream* os) {
269     *os << "whose fields (";
270     const int indices[10] = { k0, k1, k2, k3, k4, k5, k6, k7, k8, k9 };
271     for (int i = 0; i < 10; i++) {
272       if (indices[i] < 0)
273         break;
274 
275       if (i >= 1)
276         *os << ", ";
277 
278       *os << "#" << indices[i];
279     }
280     *os << ") ";
281   }
282 
283   const MonomorphicInnerMatcher inner_matcher_;
284 
285   GTEST_DISALLOW_ASSIGN_(ArgsMatcherImpl);
286 };
287 
288 template <class InnerMatcher, int k0 = -1, int k1 = -1, int k2 = -1,
289     int k3 = -1, int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1,
290     int k8 = -1, int k9 = -1>
291 class ArgsMatcher {
292  public:
ArgsMatcher(const InnerMatcher & inner_matcher)293   explicit ArgsMatcher(const InnerMatcher& inner_matcher)
294       : inner_matcher_(inner_matcher) {}
295 
296   template <typename ArgsTuple>
297   operator Matcher<ArgsTuple>() const {
298     return MakeMatcher(new ArgsMatcherImpl<ArgsTuple, k0, k1, k2, k3, k4, k5,
299         k6, k7, k8, k9>(inner_matcher_));
300   }
301 
302  private:
303   const InnerMatcher inner_matcher_;
304 
305   GTEST_DISALLOW_ASSIGN_(ArgsMatcher);
306 };
307 
308 // Implements ElementsAre() of 1-10 arguments.
309 
310 template <typename T1>
311 class ElementsAreMatcher1 {
312  public:
ElementsAreMatcher1(const T1 & e1)313   explicit ElementsAreMatcher1(const T1& e1) : e1_(e1) {}
314 
315   template <typename Container>
316   operator Matcher<Container>() const {
317     typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
318     typedef typename internal::StlContainerView<RawContainer>::type::value_type
319         Element;
320 
321     // Nokia's Symbian Compiler has a nasty bug where the object put
322     // in a one-element local array is not destructed when the array
323     // goes out of scope.  This leads to obvious badness as we've
324     // added the linked_ptr in it to our other linked_ptrs list.
325     // Hence we implement ElementsAreMatcher1 specially to avoid using
326     // a local array.
327     const Matcher<const Element&> matcher =
328         MatcherCast<const Element&>(e1_);
329     return MakeMatcher(new ElementsAreMatcherImpl<Container>(&matcher, 1));
330   }
331 
332  private:
333   const T1& e1_;
334 
335   GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher1);
336 };
337 
338 template <typename T1, typename T2>
339 class ElementsAreMatcher2 {
340  public:
ElementsAreMatcher2(const T1 & e1,const T2 & e2)341   ElementsAreMatcher2(const T1& e1, const T2& e2) : e1_(e1), e2_(e2) {}
342 
343   template <typename Container>
344   operator Matcher<Container>() const {
345     typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
346     typedef typename internal::StlContainerView<RawContainer>::type::value_type
347         Element;
348 
349     const Matcher<const Element&> matchers[] = {
350       MatcherCast<const Element&>(e1_),
351       MatcherCast<const Element&>(e2_),
352     };
353 
354     return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 2));
355   }
356 
357  private:
358   const T1& e1_;
359   const T2& e2_;
360 
361   GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher2);
362 };
363 
364 template <typename T1, typename T2, typename T3>
365 class ElementsAreMatcher3 {
366  public:
ElementsAreMatcher3(const T1 & e1,const T2 & e2,const T3 & e3)367   ElementsAreMatcher3(const T1& e1, const T2& e2, const T3& e3) : e1_(e1),
368       e2_(e2), e3_(e3) {}
369 
370   template <typename Container>
371   operator Matcher<Container>() const {
372     typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
373     typedef typename internal::StlContainerView<RawContainer>::type::value_type
374         Element;
375 
376     const Matcher<const Element&> matchers[] = {
377       MatcherCast<const Element&>(e1_),
378       MatcherCast<const Element&>(e2_),
379       MatcherCast<const Element&>(e3_),
380     };
381 
382     return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 3));
383   }
384 
385  private:
386   const T1& e1_;
387   const T2& e2_;
388   const T3& e3_;
389 
390   GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher3);
391 };
392 
393 template <typename T1, typename T2, typename T3, typename T4>
394 class ElementsAreMatcher4 {
395  public:
ElementsAreMatcher4(const T1 & e1,const T2 & e2,const T3 & e3,const T4 & e4)396   ElementsAreMatcher4(const T1& e1, const T2& e2, const T3& e3,
397       const T4& e4) : e1_(e1), e2_(e2), e3_(e3), e4_(e4) {}
398 
399   template <typename Container>
400   operator Matcher<Container>() const {
401     typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
402     typedef typename internal::StlContainerView<RawContainer>::type::value_type
403         Element;
404 
405     const Matcher<const Element&> matchers[] = {
406       MatcherCast<const Element&>(e1_),
407       MatcherCast<const Element&>(e2_),
408       MatcherCast<const Element&>(e3_),
409       MatcherCast<const Element&>(e4_),
410     };
411 
412     return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 4));
413   }
414 
415  private:
416   const T1& e1_;
417   const T2& e2_;
418   const T3& e3_;
419   const T4& e4_;
420 
421   GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher4);
422 };
423 
424 template <typename T1, typename T2, typename T3, typename T4, typename T5>
425 class ElementsAreMatcher5 {
426  public:
ElementsAreMatcher5(const T1 & e1,const T2 & e2,const T3 & e3,const T4 & e4,const T5 & e5)427   ElementsAreMatcher5(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
428       const T5& e5) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5) {}
429 
430   template <typename Container>
431   operator Matcher<Container>() const {
432     typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
433     typedef typename internal::StlContainerView<RawContainer>::type::value_type
434         Element;
435 
436     const Matcher<const Element&> matchers[] = {
437       MatcherCast<const Element&>(e1_),
438       MatcherCast<const Element&>(e2_),
439       MatcherCast<const Element&>(e3_),
440       MatcherCast<const Element&>(e4_),
441       MatcherCast<const Element&>(e5_),
442     };
443 
444     return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 5));
445   }
446 
447  private:
448   const T1& e1_;
449   const T2& e2_;
450   const T3& e3_;
451   const T4& e4_;
452   const T5& e5_;
453 
454   GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher5);
455 };
456 
457 template <typename T1, typename T2, typename T3, typename T4, typename T5,
458     typename T6>
459 class ElementsAreMatcher6 {
460  public:
ElementsAreMatcher6(const T1 & e1,const T2 & e2,const T3 & e3,const T4 & e4,const T5 & e5,const T6 & e6)461   ElementsAreMatcher6(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
462       const T5& e5, const T6& e6) : e1_(e1), e2_(e2), e3_(e3), e4_(e4),
463       e5_(e5), e6_(e6) {}
464 
465   template <typename Container>
466   operator Matcher<Container>() const {
467     typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
468     typedef typename internal::StlContainerView<RawContainer>::type::value_type
469         Element;
470 
471     const Matcher<const Element&> matchers[] = {
472       MatcherCast<const Element&>(e1_),
473       MatcherCast<const Element&>(e2_),
474       MatcherCast<const Element&>(e3_),
475       MatcherCast<const Element&>(e4_),
476       MatcherCast<const Element&>(e5_),
477       MatcherCast<const Element&>(e6_),
478     };
479 
480     return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 6));
481   }
482 
483  private:
484   const T1& e1_;
485   const T2& e2_;
486   const T3& e3_;
487   const T4& e4_;
488   const T5& e5_;
489   const T6& e6_;
490 
491   GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher6);
492 };
493 
494 template <typename T1, typename T2, typename T3, typename T4, typename T5,
495     typename T6, typename T7>
496 class ElementsAreMatcher7 {
497  public:
ElementsAreMatcher7(const T1 & e1,const T2 & e2,const T3 & e3,const T4 & e4,const T5 & e5,const T6 & e6,const T7 & e7)498   ElementsAreMatcher7(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
499       const T5& e5, const T6& e6, const T7& e7) : e1_(e1), e2_(e2), e3_(e3),
500       e4_(e4), e5_(e5), e6_(e6), e7_(e7) {}
501 
502   template <typename Container>
503   operator Matcher<Container>() const {
504     typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
505     typedef typename internal::StlContainerView<RawContainer>::type::value_type
506         Element;
507 
508     const Matcher<const Element&> matchers[] = {
509       MatcherCast<const Element&>(e1_),
510       MatcherCast<const Element&>(e2_),
511       MatcherCast<const Element&>(e3_),
512       MatcherCast<const Element&>(e4_),
513       MatcherCast<const Element&>(e5_),
514       MatcherCast<const Element&>(e6_),
515       MatcherCast<const Element&>(e7_),
516     };
517 
518     return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 7));
519   }
520 
521  private:
522   const T1& e1_;
523   const T2& e2_;
524   const T3& e3_;
525   const T4& e4_;
526   const T5& e5_;
527   const T6& e6_;
528   const T7& e7_;
529 
530   GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher7);
531 };
532 
533 template <typename T1, typename T2, typename T3, typename T4, typename T5,
534     typename T6, typename T7, typename T8>
535 class ElementsAreMatcher8 {
536  public:
ElementsAreMatcher8(const T1 & e1,const T2 & e2,const T3 & e3,const T4 & e4,const T5 & e5,const T6 & e6,const T7 & e7,const T8 & e8)537   ElementsAreMatcher8(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
538       const T5& e5, const T6& e6, const T7& e7, const T8& e8) : e1_(e1),
539       e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6), e7_(e7), e8_(e8) {}
540 
541   template <typename Container>
542   operator Matcher<Container>() const {
543     typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
544     typedef typename internal::StlContainerView<RawContainer>::type::value_type
545         Element;
546 
547     const Matcher<const Element&> matchers[] = {
548       MatcherCast<const Element&>(e1_),
549       MatcherCast<const Element&>(e2_),
550       MatcherCast<const Element&>(e3_),
551       MatcherCast<const Element&>(e4_),
552       MatcherCast<const Element&>(e5_),
553       MatcherCast<const Element&>(e6_),
554       MatcherCast<const Element&>(e7_),
555       MatcherCast<const Element&>(e8_),
556     };
557 
558     return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 8));
559   }
560 
561  private:
562   const T1& e1_;
563   const T2& e2_;
564   const T3& e3_;
565   const T4& e4_;
566   const T5& e5_;
567   const T6& e6_;
568   const T7& e7_;
569   const T8& e8_;
570 
571   GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher8);
572 };
573 
574 template <typename T1, typename T2, typename T3, typename T4, typename T5,
575     typename T6, typename T7, typename T8, typename T9>
576 class ElementsAreMatcher9 {
577  public:
ElementsAreMatcher9(const T1 & e1,const T2 & e2,const T3 & e3,const T4 & e4,const T5 & e5,const T6 & e6,const T7 & e7,const T8 & e8,const T9 & e9)578   ElementsAreMatcher9(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
579       const T5& e5, const T6& e6, const T7& e7, const T8& e8,
580       const T9& e9) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6),
581       e7_(e7), e8_(e8), e9_(e9) {}
582 
583   template <typename Container>
584   operator Matcher<Container>() const {
585     typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
586     typedef typename internal::StlContainerView<RawContainer>::type::value_type
587         Element;
588 
589     const Matcher<const Element&> matchers[] = {
590       MatcherCast<const Element&>(e1_),
591       MatcherCast<const Element&>(e2_),
592       MatcherCast<const Element&>(e3_),
593       MatcherCast<const Element&>(e4_),
594       MatcherCast<const Element&>(e5_),
595       MatcherCast<const Element&>(e6_),
596       MatcherCast<const Element&>(e7_),
597       MatcherCast<const Element&>(e8_),
598       MatcherCast<const Element&>(e9_),
599     };
600 
601     return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 9));
602   }
603 
604  private:
605   const T1& e1_;
606   const T2& e2_;
607   const T3& e3_;
608   const T4& e4_;
609   const T5& e5_;
610   const T6& e6_;
611   const T7& e7_;
612   const T8& e8_;
613   const T9& e9_;
614 
615   GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher9);
616 };
617 
618 template <typename T1, typename T2, typename T3, typename T4, typename T5,
619     typename T6, typename T7, typename T8, typename T9, typename T10>
620 class ElementsAreMatcher10 {
621  public:
ElementsAreMatcher10(const T1 & e1,const T2 & e2,const T3 & e3,const T4 & e4,const T5 & e5,const T6 & e6,const T7 & e7,const T8 & e8,const T9 & e9,const T10 & e10)622   ElementsAreMatcher10(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
623       const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,
624       const T10& e10) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6),
625       e7_(e7), e8_(e8), e9_(e9), e10_(e10) {}
626 
627   template <typename Container>
628   operator Matcher<Container>() const {
629     typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
630     typedef typename internal::StlContainerView<RawContainer>::type::value_type
631         Element;
632 
633     const Matcher<const Element&> matchers[] = {
634       MatcherCast<const Element&>(e1_),
635       MatcherCast<const Element&>(e2_),
636       MatcherCast<const Element&>(e3_),
637       MatcherCast<const Element&>(e4_),
638       MatcherCast<const Element&>(e5_),
639       MatcherCast<const Element&>(e6_),
640       MatcherCast<const Element&>(e7_),
641       MatcherCast<const Element&>(e8_),
642       MatcherCast<const Element&>(e9_),
643       MatcherCast<const Element&>(e10_),
644     };
645 
646     return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 10));
647   }
648 
649  private:
650   const T1& e1_;
651   const T2& e2_;
652   const T3& e3_;
653   const T4& e4_;
654   const T5& e5_;
655   const T6& e6_;
656   const T7& e7_;
657   const T8& e8_;
658   const T9& e9_;
659   const T10& e10_;
660 
661   GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher10);
662 };
663 
664 // A set of metafunctions for computing the result type of AllOf.
665 // AllOf(m1, ..., mN) returns
666 // AllOfResultN<decltype(m1), ..., decltype(mN)>::type.
667 
668 // Although AllOf isn't defined for one argument, AllOfResult1 is defined
669 // to simplify the implementation.
670 template <typename M1>
671 struct AllOfResult1 {
672   typedef M1 type;
673 };
674 
675 template <typename M1, typename M2>
676 struct AllOfResult2 {
677   typedef BothOfMatcher<
678       typename AllOfResult1<M1>::type,
679       typename AllOfResult1<M2>::type
680   > type;
681 };
682 
683 template <typename M1, typename M2, typename M3>
684 struct AllOfResult3 {
685   typedef BothOfMatcher<
686       typename AllOfResult1<M1>::type,
687       typename AllOfResult2<M2, M3>::type
688   > type;
689 };
690 
691 template <typename M1, typename M2, typename M3, typename M4>
692 struct AllOfResult4 {
693   typedef BothOfMatcher<
694       typename AllOfResult2<M1, M2>::type,
695       typename AllOfResult2<M3, M4>::type
696   > type;
697 };
698 
699 template <typename M1, typename M2, typename M3, typename M4, typename M5>
700 struct AllOfResult5 {
701   typedef BothOfMatcher<
702       typename AllOfResult2<M1, M2>::type,
703       typename AllOfResult3<M3, M4, M5>::type
704   > type;
705 };
706 
707 template <typename M1, typename M2, typename M3, typename M4, typename M5,
708     typename M6>
709 struct AllOfResult6 {
710   typedef BothOfMatcher<
711       typename AllOfResult3<M1, M2, M3>::type,
712       typename AllOfResult3<M4, M5, M6>::type
713   > type;
714 };
715 
716 template <typename M1, typename M2, typename M3, typename M4, typename M5,
717     typename M6, typename M7>
718 struct AllOfResult7 {
719   typedef BothOfMatcher<
720       typename AllOfResult3<M1, M2, M3>::type,
721       typename AllOfResult4<M4, M5, M6, M7>::type
722   > type;
723 };
724 
725 template <typename M1, typename M2, typename M3, typename M4, typename M5,
726     typename M6, typename M7, typename M8>
727 struct AllOfResult8 {
728   typedef BothOfMatcher<
729       typename AllOfResult4<M1, M2, M3, M4>::type,
730       typename AllOfResult4<M5, M6, M7, M8>::type
731   > type;
732 };
733 
734 template <typename M1, typename M2, typename M3, typename M4, typename M5,
735     typename M6, typename M7, typename M8, typename M9>
736 struct AllOfResult9 {
737   typedef BothOfMatcher<
738       typename AllOfResult4<M1, M2, M3, M4>::type,
739       typename AllOfResult5<M5, M6, M7, M8, M9>::type
740   > type;
741 };
742 
743 template <typename M1, typename M2, typename M3, typename M4, typename M5,
744     typename M6, typename M7, typename M8, typename M9, typename M10>
745 struct AllOfResult10 {
746   typedef BothOfMatcher<
747       typename AllOfResult5<M1, M2, M3, M4, M5>::type,
748       typename AllOfResult5<M6, M7, M8, M9, M10>::type
749   > type;
750 };
751 
752 // A set of metafunctions for computing the result type of AnyOf.
753 // AnyOf(m1, ..., mN) returns
754 // AnyOfResultN<decltype(m1), ..., decltype(mN)>::type.
755 
756 // Although AnyOf isn't defined for one argument, AnyOfResult1 is defined
757 // to simplify the implementation.
758 template <typename M1>
759 struct AnyOfResult1 {
760   typedef M1 type;
761 };
762 
763 template <typename M1, typename M2>
764 struct AnyOfResult2 {
765   typedef EitherOfMatcher<
766       typename AnyOfResult1<M1>::type,
767       typename AnyOfResult1<M2>::type
768   > type;
769 };
770 
771 template <typename M1, typename M2, typename M3>
772 struct AnyOfResult3 {
773   typedef EitherOfMatcher<
774       typename AnyOfResult1<M1>::type,
775       typename AnyOfResult2<M2, M3>::type
776   > type;
777 };
778 
779 template <typename M1, typename M2, typename M3, typename M4>
780 struct AnyOfResult4 {
781   typedef EitherOfMatcher<
782       typename AnyOfResult2<M1, M2>::type,
783       typename AnyOfResult2<M3, M4>::type
784   > type;
785 };
786 
787 template <typename M1, typename M2, typename M3, typename M4, typename M5>
788 struct AnyOfResult5 {
789   typedef EitherOfMatcher<
790       typename AnyOfResult2<M1, M2>::type,
791       typename AnyOfResult3<M3, M4, M5>::type
792   > type;
793 };
794 
795 template <typename M1, typename M2, typename M3, typename M4, typename M5,
796     typename M6>
797 struct AnyOfResult6 {
798   typedef EitherOfMatcher<
799       typename AnyOfResult3<M1, M2, M3>::type,
800       typename AnyOfResult3<M4, M5, M6>::type
801   > type;
802 };
803 
804 template <typename M1, typename M2, typename M3, typename M4, typename M5,
805     typename M6, typename M7>
806 struct AnyOfResult7 {
807   typedef EitherOfMatcher<
808       typename AnyOfResult3<M1, M2, M3>::type,
809       typename AnyOfResult4<M4, M5, M6, M7>::type
810   > type;
811 };
812 
813 template <typename M1, typename M2, typename M3, typename M4, typename M5,
814     typename M6, typename M7, typename M8>
815 struct AnyOfResult8 {
816   typedef EitherOfMatcher<
817       typename AnyOfResult4<M1, M2, M3, M4>::type,
818       typename AnyOfResult4<M5, M6, M7, M8>::type
819   > type;
820 };
821 
822 template <typename M1, typename M2, typename M3, typename M4, typename M5,
823     typename M6, typename M7, typename M8, typename M9>
824 struct AnyOfResult9 {
825   typedef EitherOfMatcher<
826       typename AnyOfResult4<M1, M2, M3, M4>::type,
827       typename AnyOfResult5<M5, M6, M7, M8, M9>::type
828   > type;
829 };
830 
831 template <typename M1, typename M2, typename M3, typename M4, typename M5,
832     typename M6, typename M7, typename M8, typename M9, typename M10>
833 struct AnyOfResult10 {
834   typedef EitherOfMatcher<
835       typename AnyOfResult5<M1, M2, M3, M4, M5>::type,
836       typename AnyOfResult5<M6, M7, M8, M9, M10>::type
837   > type;
838 };
839 
840 }  // namespace internal
841 
842 // Args<N1, N2, ..., Nk>(a_matcher) matches a tuple if the selected
843 // fields of it matches a_matcher.  C++ doesn't support default
844 // arguments for function templates, so we have to overload it.
845 template <typename InnerMatcher>
846 inline internal::ArgsMatcher<InnerMatcher>
Args(const InnerMatcher & matcher)847 Args(const InnerMatcher& matcher) {
848   return internal::ArgsMatcher<InnerMatcher>(matcher);
849 }
850 
851 template <int k1, typename InnerMatcher>
852 inline internal::ArgsMatcher<InnerMatcher, k1>
Args(const InnerMatcher & matcher)853 Args(const InnerMatcher& matcher) {
854   return internal::ArgsMatcher<InnerMatcher, k1>(matcher);
855 }
856 
857 template <int k1, int k2, typename InnerMatcher>
858 inline internal::ArgsMatcher<InnerMatcher, k1, k2>
Args(const InnerMatcher & matcher)859 Args(const InnerMatcher& matcher) {
860   return internal::ArgsMatcher<InnerMatcher, k1, k2>(matcher);
861 }
862 
863 template <int k1, int k2, int k3, typename InnerMatcher>
864 inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3>
Args(const InnerMatcher & matcher)865 Args(const InnerMatcher& matcher) {
866   return internal::ArgsMatcher<InnerMatcher, k1, k2, k3>(matcher);
867 }
868 
869 template <int k1, int k2, int k3, int k4, typename InnerMatcher>
870 inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>
Args(const InnerMatcher & matcher)871 Args(const InnerMatcher& matcher) {
872   return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>(matcher);
873 }
874 
875 template <int k1, int k2, int k3, int k4, int k5, typename InnerMatcher>
876 inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>
Args(const InnerMatcher & matcher)877 Args(const InnerMatcher& matcher) {
878   return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>(matcher);
879 }
880 
881 template <int k1, int k2, int k3, int k4, int k5, int k6, typename InnerMatcher>
882 inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>
Args(const InnerMatcher & matcher)883 Args(const InnerMatcher& matcher) {
884   return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>(matcher);
885 }
886 
887 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7,
888     typename InnerMatcher>
889 inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7>
Args(const InnerMatcher & matcher)890 Args(const InnerMatcher& matcher) {
891   return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6,
892       k7>(matcher);
893 }
894 
895 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
896     typename InnerMatcher>
897 inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8>
Args(const InnerMatcher & matcher)898 Args(const InnerMatcher& matcher) {
899   return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7,
900       k8>(matcher);
901 }
902 
903 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
904     int k9, typename InnerMatcher>
905 inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9>
Args(const InnerMatcher & matcher)906 Args(const InnerMatcher& matcher) {
907   return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
908       k9>(matcher);
909 }
910 
911 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
912     int k9, int k10, typename InnerMatcher>
913 inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9,
914     k10>
Args(const InnerMatcher & matcher)915 Args(const InnerMatcher& matcher) {
916   return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
917       k9, k10>(matcher);
918 }
919 
920 // ElementsAre(e0, e1, ..., e_n) matches an STL-style container with
921 // (n + 1) elements, where the i-th element in the container must
922 // match the i-th argument in the list.  Each argument of
923 // ElementsAre() can be either a value or a matcher.  We support up to
924 // 10 arguments.
925 //
926 // NOTE: Since ElementsAre() cares about the order of the elements, it
927 // must not be used with containers whose elements's order is
928 // undefined (e.g. hash_map).
929 
ElementsAre()930 inline internal::ElementsAreMatcher0 ElementsAre() {
931   return internal::ElementsAreMatcher0();
932 }
933 
934 template <typename T1>
ElementsAre(const T1 & e1)935 inline internal::ElementsAreMatcher1<T1> ElementsAre(const T1& e1) {
936   return internal::ElementsAreMatcher1<T1>(e1);
937 }
938 
939 template <typename T1, typename T2>
ElementsAre(const T1 & e1,const T2 & e2)940 inline internal::ElementsAreMatcher2<T1, T2> ElementsAre(const T1& e1,
941     const T2& e2) {
942   return internal::ElementsAreMatcher2<T1, T2>(e1, e2);
943 }
944 
945 template <typename T1, typename T2, typename T3>
ElementsAre(const T1 & e1,const T2 & e2,const T3 & e3)946 inline internal::ElementsAreMatcher3<T1, T2, T3> ElementsAre(const T1& e1,
947     const T2& e2, const T3& e3) {
948   return internal::ElementsAreMatcher3<T1, T2, T3>(e1, e2, e3);
949 }
950 
951 template <typename T1, typename T2, typename T3, typename T4>
ElementsAre(const T1 & e1,const T2 & e2,const T3 & e3,const T4 & e4)952 inline internal::ElementsAreMatcher4<T1, T2, T3, T4> ElementsAre(const T1& e1,
953     const T2& e2, const T3& e3, const T4& e4) {
954   return internal::ElementsAreMatcher4<T1, T2, T3, T4>(e1, e2, e3, e4);
955 }
956 
957 template <typename T1, typename T2, typename T3, typename T4, typename T5>
958 inline internal::ElementsAreMatcher5<T1, T2, T3, T4,
ElementsAre(const T1 & e1,const T2 & e2,const T3 & e3,const T4 & e4,const T5 & e5)959     T5> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
960     const T5& e5) {
961   return internal::ElementsAreMatcher5<T1, T2, T3, T4, T5>(e1, e2, e3, e4, e5);
962 }
963 
964 template <typename T1, typename T2, typename T3, typename T4, typename T5,
965     typename T6>
966 inline internal::ElementsAreMatcher6<T1, T2, T3, T4, T5,
ElementsAre(const T1 & e1,const T2 & e2,const T3 & e3,const T4 & e4,const T5 & e5,const T6 & e6)967     T6> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
968     const T5& e5, const T6& e6) {
969   return internal::ElementsAreMatcher6<T1, T2, T3, T4, T5, T6>(e1, e2, e3, e4,
970       e5, e6);
971 }
972 
973 template <typename T1, typename T2, typename T3, typename T4, typename T5,
974     typename T6, typename T7>
975 inline internal::ElementsAreMatcher7<T1, T2, T3, T4, T5, T6,
ElementsAre(const T1 & e1,const T2 & e2,const T3 & e3,const T4 & e4,const T5 & e5,const T6 & e6,const T7 & e7)976     T7> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
977     const T5& e5, const T6& e6, const T7& e7) {
978   return internal::ElementsAreMatcher7<T1, T2, T3, T4, T5, T6, T7>(e1, e2, e3,
979       e4, e5, e6, e7);
980 }
981 
982 template <typename T1, typename T2, typename T3, typename T4, typename T5,
983     typename T6, typename T7, typename T8>
984 inline internal::ElementsAreMatcher8<T1, T2, T3, T4, T5, T6, T7,
ElementsAre(const T1 & e1,const T2 & e2,const T3 & e3,const T4 & e4,const T5 & e5,const T6 & e6,const T7 & e7,const T8 & e8)985     T8> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
986     const T5& e5, const T6& e6, const T7& e7, const T8& e8) {
987   return internal::ElementsAreMatcher8<T1, T2, T3, T4, T5, T6, T7, T8>(e1, e2,
988       e3, e4, e5, e6, e7, e8);
989 }
990 
991 template <typename T1, typename T2, typename T3, typename T4, typename T5,
992     typename T6, typename T7, typename T8, typename T9>
993 inline internal::ElementsAreMatcher9<T1, T2, T3, T4, T5, T6, T7, T8,
ElementsAre(const T1 & e1,const T2 & e2,const T3 & e3,const T4 & e4,const T5 & e5,const T6 & e6,const T7 & e7,const T8 & e8,const T9 & e9)994     T9> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
995     const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9) {
996   return internal::ElementsAreMatcher9<T1, T2, T3, T4, T5, T6, T7, T8, T9>(e1,
997       e2, e3, e4, e5, e6, e7, e8, e9);
998 }
999 
1000 template <typename T1, typename T2, typename T3, typename T4, typename T5,
1001     typename T6, typename T7, typename T8, typename T9, typename T10>
1002 inline internal::ElementsAreMatcher10<T1, T2, T3, T4, T5, T6, T7, T8, T9,
ElementsAre(const T1 & e1,const T2 & e2,const T3 & e3,const T4 & e4,const T5 & e5,const T6 & e6,const T7 & e7,const T8 & e8,const T9 & e9,const T10 & e10)1003     T10> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
1004     const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,
1005     const T10& e10) {
1006   return internal::ElementsAreMatcher10<T1, T2, T3, T4, T5, T6, T7, T8, T9,
1007       T10>(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10);
1008 }
1009 
1010 // ElementsAreArray(array) and ElementAreArray(array, count) are like
1011 // ElementsAre(), except that they take an array of values or
1012 // matchers.  The former form infers the size of 'array', which must
1013 // be a static C-style array.  In the latter form, 'array' can either
1014 // be a static array or a pointer to a dynamically created array.
1015 
1016 template <typename T>
ElementsAreArray(const T * first,size_t count)1017 inline internal::ElementsAreArrayMatcher<T> ElementsAreArray(
1018     const T* first, size_t count) {
1019   return internal::ElementsAreArrayMatcher<T>(first, count);
1020 }
1021 
1022 template <typename T, size_t N>
1023 inline internal::ElementsAreArrayMatcher<T>
ElementsAreArray(const T (& array)[N])1024 ElementsAreArray(const T (&array)[N]) {
1025   return internal::ElementsAreArrayMatcher<T>(array, N);
1026 }
1027 
1028 // AllOf(m1, m2, ..., mk) matches any value that matches all of the given
1029 // sub-matchers.  AllOf is called fully qualified to prevent ADL from firing.
1030 
1031 template <typename M1, typename M2>
1032 inline typename internal::AllOfResult2<M1, M2>::type
AllOf(M1 m1,M2 m2)1033 AllOf(M1 m1, M2 m2) {
1034   return typename internal::AllOfResult2<M1, M2>::type(
1035       m1,
1036       m2);
1037 }
1038 
1039 template <typename M1, typename M2, typename M3>
1040 inline typename internal::AllOfResult3<M1, M2, M3>::type
AllOf(M1 m1,M2 m2,M3 m3)1041 AllOf(M1 m1, M2 m2, M3 m3) {
1042   return typename internal::AllOfResult3<M1, M2, M3>::type(
1043       m1,
1044       ::testing::AllOf(m2, m3));
1045 }
1046 
1047 template <typename M1, typename M2, typename M3, typename M4>
1048 inline typename internal::AllOfResult4<M1, M2, M3, M4>::type
AllOf(M1 m1,M2 m2,M3 m3,M4 m4)1049 AllOf(M1 m1, M2 m2, M3 m3, M4 m4) {
1050   return typename internal::AllOfResult4<M1, M2, M3, M4>::type(
1051       ::testing::AllOf(m1, m2),
1052       ::testing::AllOf(m3, m4));
1053 }
1054 
1055 template <typename M1, typename M2, typename M3, typename M4, typename M5>
1056 inline typename internal::AllOfResult5<M1, M2, M3, M4, M5>::type
AllOf(M1 m1,M2 m2,M3 m3,M4 m4,M5 m5)1057 AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5) {
1058   return typename internal::AllOfResult5<M1, M2, M3, M4, M5>::type(
1059       ::testing::AllOf(m1, m2),
1060       ::testing::AllOf(m3, m4, m5));
1061 }
1062 
1063 template <typename M1, typename M2, typename M3, typename M4, typename M5,
1064     typename M6>
1065 inline typename internal::AllOfResult6<M1, M2, M3, M4, M5, M6>::type
AllOf(M1 m1,M2 m2,M3 m3,M4 m4,M5 m5,M6 m6)1066 AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6) {
1067   return typename internal::AllOfResult6<M1, M2, M3, M4, M5, M6>::type(
1068       ::testing::AllOf(m1, m2, m3),
1069       ::testing::AllOf(m4, m5, m6));
1070 }
1071 
1072 template <typename M1, typename M2, typename M3, typename M4, typename M5,
1073     typename M6, typename M7>
1074 inline typename internal::AllOfResult7<M1, M2, M3, M4, M5, M6, M7>::type
AllOf(M1 m1,M2 m2,M3 m3,M4 m4,M5 m5,M6 m6,M7 m7)1075 AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7) {
1076   return typename internal::AllOfResult7<M1, M2, M3, M4, M5, M6, M7>::type(
1077       ::testing::AllOf(m1, m2, m3),
1078       ::testing::AllOf(m4, m5, m6, m7));
1079 }
1080 
1081 template <typename M1, typename M2, typename M3, typename M4, typename M5,
1082     typename M6, typename M7, typename M8>
1083 inline typename internal::AllOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type
AllOf(M1 m1,M2 m2,M3 m3,M4 m4,M5 m5,M6 m6,M7 m7,M8 m8)1084 AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8) {
1085   return typename internal::AllOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type(
1086       ::testing::AllOf(m1, m2, m3, m4),
1087       ::testing::AllOf(m5, m6, m7, m8));
1088 }
1089 
1090 template <typename M1, typename M2, typename M3, typename M4, typename M5,
1091     typename M6, typename M7, typename M8, typename M9>
1092 inline typename internal::AllOfResult9<M1, M2, M3, M4, M5, M6, M7, M8, M9>::type
AllOf(M1 m1,M2 m2,M3 m3,M4 m4,M5 m5,M6 m6,M7 m7,M8 m8,M9 m9)1093 AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9) {
1094   return typename internal::AllOfResult9<M1, M2, M3, M4, M5, M6, M7, M8,
1095       M9>::type(
1096       ::testing::AllOf(m1, m2, m3, m4),
1097       ::testing::AllOf(m5, m6, m7, m8, m9));
1098 }
1099 
1100 template <typename M1, typename M2, typename M3, typename M4, typename M5,
1101     typename M6, typename M7, typename M8, typename M9, typename M10>
1102 inline typename internal::AllOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
1103     M10>::type
AllOf(M1 m1,M2 m2,M3 m3,M4 m4,M5 m5,M6 m6,M7 m7,M8 m8,M9 m9,M10 m10)1104 AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
1105   return typename internal::AllOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
1106       M10>::type(
1107       ::testing::AllOf(m1, m2, m3, m4, m5),
1108       ::testing::AllOf(m6, m7, m8, m9, m10));
1109 }
1110 
1111 // AnyOf(m1, m2, ..., mk) matches any value that matches any of the given
1112 // sub-matchers.  AnyOf is called fully qualified to prevent ADL from firing.
1113 
1114 template <typename M1, typename M2>
1115 inline typename internal::AnyOfResult2<M1, M2>::type
AnyOf(M1 m1,M2 m2)1116 AnyOf(M1 m1, M2 m2) {
1117   return typename internal::AnyOfResult2<M1, M2>::type(
1118       m1,
1119       m2);
1120 }
1121 
1122 template <typename M1, typename M2, typename M3>
1123 inline typename internal::AnyOfResult3<M1, M2, M3>::type
AnyOf(M1 m1,M2 m2,M3 m3)1124 AnyOf(M1 m1, M2 m2, M3 m3) {
1125   return typename internal::AnyOfResult3<M1, M2, M3>::type(
1126       m1,
1127       ::testing::AnyOf(m2, m3));
1128 }
1129 
1130 template <typename M1, typename M2, typename M3, typename M4>
1131 inline typename internal::AnyOfResult4<M1, M2, M3, M4>::type
AnyOf(M1 m1,M2 m2,M3 m3,M4 m4)1132 AnyOf(M1 m1, M2 m2, M3 m3, M4 m4) {
1133   return typename internal::AnyOfResult4<M1, M2, M3, M4>::type(
1134       ::testing::AnyOf(m1, m2),
1135       ::testing::AnyOf(m3, m4));
1136 }
1137 
1138 template <typename M1, typename M2, typename M3, typename M4, typename M5>
1139 inline typename internal::AnyOfResult5<M1, M2, M3, M4, M5>::type
AnyOf(M1 m1,M2 m2,M3 m3,M4 m4,M5 m5)1140 AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5) {
1141   return typename internal::AnyOfResult5<M1, M2, M3, M4, M5>::type(
1142       ::testing::AnyOf(m1, m2),
1143       ::testing::AnyOf(m3, m4, m5));
1144 }
1145 
1146 template <typename M1, typename M2, typename M3, typename M4, typename M5,
1147     typename M6>
1148 inline typename internal::AnyOfResult6<M1, M2, M3, M4, M5, M6>::type
AnyOf(M1 m1,M2 m2,M3 m3,M4 m4,M5 m5,M6 m6)1149 AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6) {
1150   return typename internal::AnyOfResult6<M1, M2, M3, M4, M5, M6>::type(
1151       ::testing::AnyOf(m1, m2, m3),
1152       ::testing::AnyOf(m4, m5, m6));
1153 }
1154 
1155 template <typename M1, typename M2, typename M3, typename M4, typename M5,
1156     typename M6, typename M7>
1157 inline typename internal::AnyOfResult7<M1, M2, M3, M4, M5, M6, M7>::type
AnyOf(M1 m1,M2 m2,M3 m3,M4 m4,M5 m5,M6 m6,M7 m7)1158 AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7) {
1159   return typename internal::AnyOfResult7<M1, M2, M3, M4, M5, M6, M7>::type(
1160       ::testing::AnyOf(m1, m2, m3),
1161       ::testing::AnyOf(m4, m5, m6, m7));
1162 }
1163 
1164 template <typename M1, typename M2, typename M3, typename M4, typename M5,
1165     typename M6, typename M7, typename M8>
1166 inline typename internal::AnyOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type
AnyOf(M1 m1,M2 m2,M3 m3,M4 m4,M5 m5,M6 m6,M7 m7,M8 m8)1167 AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8) {
1168   return typename internal::AnyOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type(
1169       ::testing::AnyOf(m1, m2, m3, m4),
1170       ::testing::AnyOf(m5, m6, m7, m8));
1171 }
1172 
1173 template <typename M1, typename M2, typename M3, typename M4, typename M5,
1174     typename M6, typename M7, typename M8, typename M9>
1175 inline typename internal::AnyOfResult9<M1, M2, M3, M4, M5, M6, M7, M8, M9>::type
AnyOf(M1 m1,M2 m2,M3 m3,M4 m4,M5 m5,M6 m6,M7 m7,M8 m8,M9 m9)1176 AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9) {
1177   return typename internal::AnyOfResult9<M1, M2, M3, M4, M5, M6, M7, M8,
1178       M9>::type(
1179       ::testing::AnyOf(m1, m2, m3, m4),
1180       ::testing::AnyOf(m5, m6, m7, m8, m9));
1181 }
1182 
1183 template <typename M1, typename M2, typename M3, typename M4, typename M5,
1184     typename M6, typename M7, typename M8, typename M9, typename M10>
1185 inline typename internal::AnyOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
1186     M10>::type
AnyOf(M1 m1,M2 m2,M3 m3,M4 m4,M5 m5,M6 m6,M7 m7,M8 m8,M9 m9,M10 m10)1187 AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
1188   return typename internal::AnyOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
1189       M10>::type(
1190       ::testing::AnyOf(m1, m2, m3, m4, m5),
1191       ::testing::AnyOf(m6, m7, m8, m9, m10));
1192 }
1193 
1194 }  // namespace testing
1195 
1196 
1197 // The MATCHER* family of macros can be used in a namespace scope to
1198 // define custom matchers easily.
1199 //
1200 // Basic Usage
1201 // ===========
1202 //
1203 // The syntax
1204 //
1205 //   MATCHER(name, description_string) { statements; }
1206 //
1207 // defines a matcher with the given name that executes the statements,
1208 // which must return a bool to indicate if the match succeeds.  Inside
1209 // the statements, you can refer to the value being matched by 'arg',
1210 // and refer to its type by 'arg_type'.
1211 //
1212 // The description string documents what the matcher does, and is used
1213 // to generate the failure message when the match fails.  Since a
1214 // MATCHER() is usually defined in a header file shared by multiple
1215 // C++ source files, we require the description to be a C-string
1216 // literal to avoid possible side effects.  It can be empty, in which
1217 // case we'll use the sequence of words in the matcher name as the
1218 // description.
1219 //
1220 // For example:
1221 //
1222 //   MATCHER(IsEven, "") { return (arg % 2) == 0; }
1223 //
1224 // allows you to write
1225 //
1226 //   // Expects mock_foo.Bar(n) to be called where n is even.
1227 //   EXPECT_CALL(mock_foo, Bar(IsEven()));
1228 //
1229 // or,
1230 //
1231 //   // Verifies that the value of some_expression is even.
1232 //   EXPECT_THAT(some_expression, IsEven());
1233 //
1234 // If the above assertion fails, it will print something like:
1235 //
1236 //   Value of: some_expression
1237 //   Expected: is even
1238 //     Actual: 7
1239 //
1240 // where the description "is even" is automatically calculated from the
1241 // matcher name IsEven.
1242 //
1243 // Argument Type
1244 // =============
1245 //
1246 // Note that the type of the value being matched (arg_type) is
1247 // determined by the context in which you use the matcher and is
1248 // supplied to you by the compiler, so you don't need to worry about
1249 // declaring it (nor can you).  This allows the matcher to be
1250 // polymorphic.  For example, IsEven() can be used to match any type
1251 // where the value of "(arg % 2) == 0" can be implicitly converted to
1252 // a bool.  In the "Bar(IsEven())" example above, if method Bar()
1253 // takes an int, 'arg_type' will be int; if it takes an unsigned long,
1254 // 'arg_type' will be unsigned long; and so on.
1255 //
1256 // Parameterizing Matchers
1257 // =======================
1258 //
1259 // Sometimes you'll want to parameterize the matcher.  For that you
1260 // can use another macro:
1261 //
1262 //   MATCHER_P(name, param_name, description_string) { statements; }
1263 //
1264 // For example:
1265 //
1266 //   MATCHER_P(HasAbsoluteValue, value, "") { return abs(arg) == value; }
1267 //
1268 // will allow you to write:
1269 //
1270 //   EXPECT_THAT(Blah("a"), HasAbsoluteValue(n));
1271 //
1272 // which may lead to this message (assuming n is 10):
1273 //
1274 //   Value of: Blah("a")
1275 //   Expected: has absolute value 10
1276 //     Actual: -9
1277 //
1278 // Note that both the matcher description and its parameter are
1279 // printed, making the message human-friendly.
1280 //
1281 // In the matcher definition body, you can write 'foo_type' to
1282 // reference the type of a parameter named 'foo'.  For example, in the
1283 // body of MATCHER_P(HasAbsoluteValue, value) above, you can write
1284 // 'value_type' to refer to the type of 'value'.
1285 //
1286 // We also provide MATCHER_P2, MATCHER_P3, ..., up to MATCHER_P10 to
1287 // support multi-parameter matchers.
1288 //
1289 // Describing Parameterized Matchers
1290 // =================================
1291 //
1292 // The last argument to MATCHER*() is a string-typed expression.  The
1293 // expression can reference all of the matcher's parameters and a
1294 // special bool-typed variable named 'negation'.  When 'negation' is
1295 // false, the expression should evaluate to the matcher's description;
1296 // otherwise it should evaluate to the description of the negation of
1297 // the matcher.  For example,
1298 //
1299 //   using testing::PrintToString;
1300 //
1301 //   MATCHER_P2(InClosedRange, low, hi,
1302 //       string(negation ? "is not" : "is") + " in range [" +
1303 //       PrintToString(low) + ", " + PrintToString(hi) + "]") {
1304 //     return low <= arg && arg <= hi;
1305 //   }
1306 //   ...
1307 //   EXPECT_THAT(3, InClosedRange(4, 6));
1308 //   EXPECT_THAT(3, Not(InClosedRange(2, 4)));
1309 //
1310 // would generate two failures that contain the text:
1311 //
1312 //   Expected: is in range [4, 6]
1313 //   ...
1314 //   Expected: is not in range [2, 4]
1315 //
1316 // If you specify "" as the description, the failure message will
1317 // contain the sequence of words in the matcher name followed by the
1318 // parameter values printed as a tuple.  For example,
1319 //
1320 //   MATCHER_P2(InClosedRange, low, hi, "") { ... }
1321 //   ...
1322 //   EXPECT_THAT(3, InClosedRange(4, 6));
1323 //   EXPECT_THAT(3, Not(InClosedRange(2, 4)));
1324 //
1325 // would generate two failures that contain the text:
1326 //
1327 //   Expected: in closed range (4, 6)
1328 //   ...
1329 //   Expected: not (in closed range (2, 4))
1330 //
1331 // Types of Matcher Parameters
1332 // ===========================
1333 //
1334 // For the purpose of typing, you can view
1335 //
1336 //   MATCHER_Pk(Foo, p1, ..., pk, description_string) { ... }
1337 //
1338 // as shorthand for
1339 //
1340 //   template <typename p1_type, ..., typename pk_type>
1341 //   FooMatcherPk<p1_type, ..., pk_type>
1342 //   Foo(p1_type p1, ..., pk_type pk) { ... }
1343 //
1344 // When you write Foo(v1, ..., vk), the compiler infers the types of
1345 // the parameters v1, ..., and vk for you.  If you are not happy with
1346 // the result of the type inference, you can specify the types by
1347 // explicitly instantiating the template, as in Foo<long, bool>(5,
1348 // false).  As said earlier, you don't get to (or need to) specify
1349 // 'arg_type' as that's determined by the context in which the matcher
1350 // is used.  You can assign the result of expression Foo(p1, ..., pk)
1351 // to a variable of type FooMatcherPk<p1_type, ..., pk_type>.  This
1352 // can be useful when composing matchers.
1353 //
1354 // While you can instantiate a matcher template with reference types,
1355 // passing the parameters by pointer usually makes your code more
1356 // readable.  If, however, you still want to pass a parameter by
1357 // reference, be aware that in the failure message generated by the
1358 // matcher you will see the value of the referenced object but not its
1359 // address.
1360 //
1361 // Explaining Match Results
1362 // ========================
1363 //
1364 // Sometimes the matcher description alone isn't enough to explain why
1365 // the match has failed or succeeded.  For example, when expecting a
1366 // long string, it can be very helpful to also print the diff between
1367 // the expected string and the actual one.  To achieve that, you can
1368 // optionally stream additional information to a special variable
1369 // named result_listener, whose type is a pointer to class
1370 // MatchResultListener:
1371 //
1372 //   MATCHER_P(EqualsLongString, str, "") {
1373 //     if (arg == str) return true;
1374 //
1375 //     *result_listener << "the difference: "
1376 ///                     << DiffStrings(str, arg);
1377 //     return false;
1378 //   }
1379 //
1380 // Overloading Matchers
1381 // ====================
1382 //
1383 // You can overload matchers with different numbers of parameters:
1384 //
1385 //   MATCHER_P(Blah, a, description_string1) { ... }
1386 //   MATCHER_P2(Blah, a, b, description_string2) { ... }
1387 //
1388 // Caveats
1389 // =======
1390 //
1391 // When defining a new matcher, you should also consider implementing
1392 // MatcherInterface or using MakePolymorphicMatcher().  These
1393 // approaches require more work than the MATCHER* macros, but also
1394 // give you more control on the types of the value being matched and
1395 // the matcher parameters, which may leads to better compiler error
1396 // messages when the matcher is used wrong.  They also allow
1397 // overloading matchers based on parameter types (as opposed to just
1398 // based on the number of parameters).
1399 //
1400 // MATCHER*() can only be used in a namespace scope.  The reason is
1401 // that C++ doesn't yet allow function-local types to be used to
1402 // instantiate templates.  The up-coming C++0x standard will fix this.
1403 // Once that's done, we'll consider supporting using MATCHER*() inside
1404 // a function.
1405 //
1406 // More Information
1407 // ================
1408 //
1409 // To learn more about using these macros, please search for 'MATCHER'
1410 // on http://code.google.com/p/googlemock/wiki/CookBook.
1411 
1412 #define MATCHER(name, description)\
1413   class name##Matcher {\
1414    public:\
1415     template <typename arg_type>\
1416     class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1417      public:\
1418       gmock_Impl()\
1419            {}\
1420       virtual bool MatchAndExplain(\
1421           arg_type arg, ::testing::MatchResultListener* result_listener) const;\
1422       virtual void DescribeTo(::std::ostream* gmock_os) const {\
1423         *gmock_os << FormatDescription(false);\
1424       }\
1425       virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1426         *gmock_os << FormatDescription(true);\
1427       }\
1428      private:\
1429       ::testing::internal::string FormatDescription(bool negation) const {\
1430         const ::testing::internal::string gmock_description = (description);\
1431         if (!gmock_description.empty())\
1432           return gmock_description;\
1433         return ::testing::internal::FormatMatcherDescription(\
1434             negation, #name, \
1435             ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1436                 ::std::tr1::tuple<>()));\
1437       }\
1438       GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1439     };\
1440     template <typename arg_type>\
1441     operator ::testing::Matcher<arg_type>() const {\
1442       return ::testing::Matcher<arg_type>(\
1443           new gmock_Impl<arg_type>());\
1444     }\
1445     name##Matcher() {\
1446     }\
1447    private:\
1448     GTEST_DISALLOW_ASSIGN_(name##Matcher);\
1449   };\
1450   inline name##Matcher name() {\
1451     return name##Matcher();\
1452   }\
1453   template <typename arg_type>\
1454   bool name##Matcher::gmock_Impl<arg_type>::MatchAndExplain(\
1455       arg_type arg, \
1456       ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1457           const
1458 
1459 #define MATCHER_P(name, p0, description)\
1460   template <typename p0##_type>\
1461   class name##MatcherP {\
1462    public:\
1463     template <typename arg_type>\
1464     class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1465      public:\
1466       explicit gmock_Impl(p0##_type gmock_p0)\
1467            : p0(gmock_p0) {}\
1468       virtual bool MatchAndExplain(\
1469           arg_type arg, ::testing::MatchResultListener* result_listener) const;\
1470       virtual void DescribeTo(::std::ostream* gmock_os) const {\
1471         *gmock_os << FormatDescription(false);\
1472       }\
1473       virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1474         *gmock_os << FormatDescription(true);\
1475       }\
1476       p0##_type p0;\
1477      private:\
1478       ::testing::internal::string FormatDescription(bool negation) const {\
1479         const ::testing::internal::string gmock_description = (description);\
1480         if (!gmock_description.empty())\
1481           return gmock_description;\
1482         return ::testing::internal::FormatMatcherDescription(\
1483             negation, #name, \
1484             ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1485                 ::std::tr1::tuple<p0##_type>(p0)));\
1486       }\
1487       GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1488     };\
1489     template <typename arg_type>\
1490     operator ::testing::Matcher<arg_type>() const {\
1491       return ::testing::Matcher<arg_type>(\
1492           new gmock_Impl<arg_type>(p0));\
1493     }\
1494     name##MatcherP(p0##_type gmock_p0) : p0(gmock_p0) {\
1495     }\
1496     p0##_type p0;\
1497    private:\
1498     GTEST_DISALLOW_ASSIGN_(name##MatcherP);\
1499   };\
1500   template <typename p0##_type>\
1501   inline name##MatcherP<p0##_type> name(p0##_type p0) {\
1502     return name##MatcherP<p0##_type>(p0);\
1503   }\
1504   template <typename p0##_type>\
1505   template <typename arg_type>\
1506   bool name##MatcherP<p0##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1507       arg_type arg, \
1508       ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1509           const
1510 
1511 #define MATCHER_P2(name, p0, p1, description)\
1512   template <typename p0##_type, typename p1##_type>\
1513   class name##MatcherP2 {\
1514    public:\
1515     template <typename arg_type>\
1516     class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1517      public:\
1518       gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1)\
1519            : p0(gmock_p0), p1(gmock_p1) {}\
1520       virtual bool MatchAndExplain(\
1521           arg_type arg, ::testing::MatchResultListener* result_listener) const;\
1522       virtual void DescribeTo(::std::ostream* gmock_os) const {\
1523         *gmock_os << FormatDescription(false);\
1524       }\
1525       virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1526         *gmock_os << FormatDescription(true);\
1527       }\
1528       p0##_type p0;\
1529       p1##_type p1;\
1530      private:\
1531       ::testing::internal::string FormatDescription(bool negation) const {\
1532         const ::testing::internal::string gmock_description = (description);\
1533         if (!gmock_description.empty())\
1534           return gmock_description;\
1535         return ::testing::internal::FormatMatcherDescription(\
1536             negation, #name, \
1537             ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1538                 ::std::tr1::tuple<p0##_type, p1##_type>(p0, p1)));\
1539       }\
1540       GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1541     };\
1542     template <typename arg_type>\
1543     operator ::testing::Matcher<arg_type>() const {\
1544       return ::testing::Matcher<arg_type>(\
1545           new gmock_Impl<arg_type>(p0, p1));\
1546     }\
1547     name##MatcherP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
1548         p1(gmock_p1) {\
1549     }\
1550     p0##_type p0;\
1551     p1##_type p1;\
1552    private:\
1553     GTEST_DISALLOW_ASSIGN_(name##MatcherP2);\
1554   };\
1555   template <typename p0##_type, typename p1##_type>\
1556   inline name##MatcherP2<p0##_type, p1##_type> name(p0##_type p0, \
1557       p1##_type p1) {\
1558     return name##MatcherP2<p0##_type, p1##_type>(p0, p1);\
1559   }\
1560   template <typename p0##_type, typename p1##_type>\
1561   template <typename arg_type>\
1562   bool name##MatcherP2<p0##_type, \
1563       p1##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1564       arg_type arg, \
1565       ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1566           const
1567 
1568 #define MATCHER_P3(name, p0, p1, p2, description)\
1569   template <typename p0##_type, typename p1##_type, typename p2##_type>\
1570   class name##MatcherP3 {\
1571    public:\
1572     template <typename arg_type>\
1573     class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1574      public:\
1575       gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2)\
1576            : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\
1577       virtual bool MatchAndExplain(\
1578           arg_type arg, ::testing::MatchResultListener* result_listener) const;\
1579       virtual void DescribeTo(::std::ostream* gmock_os) const {\
1580         *gmock_os << FormatDescription(false);\
1581       }\
1582       virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1583         *gmock_os << FormatDescription(true);\
1584       }\
1585       p0##_type p0;\
1586       p1##_type p1;\
1587       p2##_type p2;\
1588      private:\
1589       ::testing::internal::string FormatDescription(bool negation) const {\
1590         const ::testing::internal::string gmock_description = (description);\
1591         if (!gmock_description.empty())\
1592           return gmock_description;\
1593         return ::testing::internal::FormatMatcherDescription(\
1594             negation, #name, \
1595             ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1596                 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type>(p0, p1, \
1597                     p2)));\
1598       }\
1599       GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1600     };\
1601     template <typename arg_type>\
1602     operator ::testing::Matcher<arg_type>() const {\
1603       return ::testing::Matcher<arg_type>(\
1604           new gmock_Impl<arg_type>(p0, p1, p2));\
1605     }\
1606     name##MatcherP3(p0##_type gmock_p0, p1##_type gmock_p1, \
1607         p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {\
1608     }\
1609     p0##_type p0;\
1610     p1##_type p1;\
1611     p2##_type p2;\
1612    private:\
1613     GTEST_DISALLOW_ASSIGN_(name##MatcherP3);\
1614   };\
1615   template <typename p0##_type, typename p1##_type, typename p2##_type>\
1616   inline name##MatcherP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0, \
1617       p1##_type p1, p2##_type p2) {\
1618     return name##MatcherP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\
1619   }\
1620   template <typename p0##_type, typename p1##_type, typename p2##_type>\
1621   template <typename arg_type>\
1622   bool name##MatcherP3<p0##_type, p1##_type, \
1623       p2##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1624       arg_type arg, \
1625       ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1626           const
1627 
1628 #define MATCHER_P4(name, p0, p1, p2, p3, description)\
1629   template <typename p0##_type, typename p1##_type, typename p2##_type, \
1630       typename p3##_type>\
1631   class name##MatcherP4 {\
1632    public:\
1633     template <typename arg_type>\
1634     class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1635      public:\
1636       gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1637           p3##_type gmock_p3)\
1638            : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3) {}\
1639       virtual bool MatchAndExplain(\
1640           arg_type arg, ::testing::MatchResultListener* result_listener) const;\
1641       virtual void DescribeTo(::std::ostream* gmock_os) const {\
1642         *gmock_os << FormatDescription(false);\
1643       }\
1644       virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1645         *gmock_os << FormatDescription(true);\
1646       }\
1647       p0##_type p0;\
1648       p1##_type p1;\
1649       p2##_type p2;\
1650       p3##_type p3;\
1651      private:\
1652       ::testing::internal::string FormatDescription(bool negation) const {\
1653         const ::testing::internal::string gmock_description = (description);\
1654         if (!gmock_description.empty())\
1655           return gmock_description;\
1656         return ::testing::internal::FormatMatcherDescription(\
1657             negation, #name, \
1658             ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1659                 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, \
1660                     p3##_type>(p0, p1, p2, p3)));\
1661       }\
1662       GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1663     };\
1664     template <typename arg_type>\
1665     operator ::testing::Matcher<arg_type>() const {\
1666       return ::testing::Matcher<arg_type>(\
1667           new gmock_Impl<arg_type>(p0, p1, p2, p3));\
1668     }\
1669     name##MatcherP4(p0##_type gmock_p0, p1##_type gmock_p1, \
1670         p2##_type gmock_p2, p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), \
1671         p2(gmock_p2), p3(gmock_p3) {\
1672     }\
1673     p0##_type p0;\
1674     p1##_type p1;\
1675     p2##_type p2;\
1676     p3##_type p3;\
1677    private:\
1678     GTEST_DISALLOW_ASSIGN_(name##MatcherP4);\
1679   };\
1680   template <typename p0##_type, typename p1##_type, typename p2##_type, \
1681       typename p3##_type>\
1682   inline name##MatcherP4<p0##_type, p1##_type, p2##_type, \
1683       p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
1684       p3##_type p3) {\
1685     return name##MatcherP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, \
1686         p1, p2, p3);\
1687   }\
1688   template <typename p0##_type, typename p1##_type, typename p2##_type, \
1689       typename p3##_type>\
1690   template <typename arg_type>\
1691   bool name##MatcherP4<p0##_type, p1##_type, p2##_type, \
1692       p3##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1693       arg_type arg, \
1694       ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1695           const
1696 
1697 #define MATCHER_P5(name, p0, p1, p2, p3, p4, description)\
1698   template <typename p0##_type, typename p1##_type, typename p2##_type, \
1699       typename p3##_type, typename p4##_type>\
1700   class name##MatcherP5 {\
1701    public:\
1702     template <typename arg_type>\
1703     class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1704      public:\
1705       gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1706           p3##_type gmock_p3, p4##_type gmock_p4)\
1707            : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1708                p4(gmock_p4) {}\
1709       virtual bool MatchAndExplain(\
1710           arg_type arg, ::testing::MatchResultListener* result_listener) const;\
1711       virtual void DescribeTo(::std::ostream* gmock_os) const {\
1712         *gmock_os << FormatDescription(false);\
1713       }\
1714       virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1715         *gmock_os << FormatDescription(true);\
1716       }\
1717       p0##_type p0;\
1718       p1##_type p1;\
1719       p2##_type p2;\
1720       p3##_type p3;\
1721       p4##_type p4;\
1722      private:\
1723       ::testing::internal::string FormatDescription(bool negation) const {\
1724         const ::testing::internal::string gmock_description = (description);\
1725         if (!gmock_description.empty())\
1726           return gmock_description;\
1727         return ::testing::internal::FormatMatcherDescription(\
1728             negation, #name, \
1729             ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1730                 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1731                     p4##_type>(p0, p1, p2, p3, p4)));\
1732       }\
1733       GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1734     };\
1735     template <typename arg_type>\
1736     operator ::testing::Matcher<arg_type>() const {\
1737       return ::testing::Matcher<arg_type>(\
1738           new gmock_Impl<arg_type>(p0, p1, p2, p3, p4));\
1739     }\
1740     name##MatcherP5(p0##_type gmock_p0, p1##_type gmock_p1, \
1741         p2##_type gmock_p2, p3##_type gmock_p3, \
1742         p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1743         p3(gmock_p3), p4(gmock_p4) {\
1744     }\
1745     p0##_type p0;\
1746     p1##_type p1;\
1747     p2##_type p2;\
1748     p3##_type p3;\
1749     p4##_type p4;\
1750    private:\
1751     GTEST_DISALLOW_ASSIGN_(name##MatcherP5);\
1752   };\
1753   template <typename p0##_type, typename p1##_type, typename p2##_type, \
1754       typename p3##_type, typename p4##_type>\
1755   inline name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1756       p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
1757       p4##_type p4) {\
1758     return name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1759         p4##_type>(p0, p1, p2, p3, p4);\
1760   }\
1761   template <typename p0##_type, typename p1##_type, typename p2##_type, \
1762       typename p3##_type, typename p4##_type>\
1763   template <typename arg_type>\
1764   bool name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1765       p4##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1766       arg_type arg, \
1767       ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1768           const
1769 
1770 #define MATCHER_P6(name, p0, p1, p2, p3, p4, p5, description)\
1771   template <typename p0##_type, typename p1##_type, typename p2##_type, \
1772       typename p3##_type, typename p4##_type, typename p5##_type>\
1773   class name##MatcherP6 {\
1774    public:\
1775     template <typename arg_type>\
1776     class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1777      public:\
1778       gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1779           p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5)\
1780            : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1781                p4(gmock_p4), p5(gmock_p5) {}\
1782       virtual bool MatchAndExplain(\
1783           arg_type arg, ::testing::MatchResultListener* result_listener) const;\
1784       virtual void DescribeTo(::std::ostream* gmock_os) const {\
1785         *gmock_os << FormatDescription(false);\
1786       }\
1787       virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1788         *gmock_os << FormatDescription(true);\
1789       }\
1790       p0##_type p0;\
1791       p1##_type p1;\
1792       p2##_type p2;\
1793       p3##_type p3;\
1794       p4##_type p4;\
1795       p5##_type p5;\
1796      private:\
1797       ::testing::internal::string FormatDescription(bool negation) const {\
1798         const ::testing::internal::string gmock_description = (description);\
1799         if (!gmock_description.empty())\
1800           return gmock_description;\
1801         return ::testing::internal::FormatMatcherDescription(\
1802             negation, #name, \
1803             ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1804                 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1805                     p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5)));\
1806       }\
1807       GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1808     };\
1809     template <typename arg_type>\
1810     operator ::testing::Matcher<arg_type>() const {\
1811       return ::testing::Matcher<arg_type>(\
1812           new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5));\
1813     }\
1814     name##MatcherP6(p0##_type gmock_p0, p1##_type gmock_p1, \
1815         p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1816         p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1817         p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {\
1818     }\
1819     p0##_type p0;\
1820     p1##_type p1;\
1821     p2##_type p2;\
1822     p3##_type p3;\
1823     p4##_type p4;\
1824     p5##_type p5;\
1825    private:\
1826     GTEST_DISALLOW_ASSIGN_(name##MatcherP6);\
1827   };\
1828   template <typename p0##_type, typename p1##_type, typename p2##_type, \
1829       typename p3##_type, typename p4##_type, typename p5##_type>\
1830   inline name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
1831       p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
1832       p3##_type p3, p4##_type p4, p5##_type p5) {\
1833     return name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
1834         p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\
1835   }\
1836   template <typename p0##_type, typename p1##_type, typename p2##_type, \
1837       typename p3##_type, typename p4##_type, typename p5##_type>\
1838   template <typename arg_type>\
1839   bool name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
1840       p5##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1841       arg_type arg, \
1842       ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1843           const
1844 
1845 #define MATCHER_P7(name, p0, p1, p2, p3, p4, p5, p6, description)\
1846   template <typename p0##_type, typename p1##_type, typename p2##_type, \
1847       typename p3##_type, typename p4##_type, typename p5##_type, \
1848       typename p6##_type>\
1849   class name##MatcherP7 {\
1850    public:\
1851     template <typename arg_type>\
1852     class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1853      public:\
1854       gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1855           p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
1856           p6##_type gmock_p6)\
1857            : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1858                p4(gmock_p4), p5(gmock_p5), p6(gmock_p6) {}\
1859       virtual bool MatchAndExplain(\
1860           arg_type arg, ::testing::MatchResultListener* result_listener) const;\
1861       virtual void DescribeTo(::std::ostream* gmock_os) const {\
1862         *gmock_os << FormatDescription(false);\
1863       }\
1864       virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1865         *gmock_os << FormatDescription(true);\
1866       }\
1867       p0##_type p0;\
1868       p1##_type p1;\
1869       p2##_type p2;\
1870       p3##_type p3;\
1871       p4##_type p4;\
1872       p5##_type p5;\
1873       p6##_type p6;\
1874      private:\
1875       ::testing::internal::string FormatDescription(bool negation) const {\
1876         const ::testing::internal::string gmock_description = (description);\
1877         if (!gmock_description.empty())\
1878           return gmock_description;\
1879         return ::testing::internal::FormatMatcherDescription(\
1880             negation, #name, \
1881             ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1882                 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1883                     p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, \
1884                     p6)));\
1885       }\
1886       GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1887     };\
1888     template <typename arg_type>\
1889     operator ::testing::Matcher<arg_type>() const {\
1890       return ::testing::Matcher<arg_type>(\
1891           new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6));\
1892     }\
1893     name##MatcherP7(p0##_type gmock_p0, p1##_type gmock_p1, \
1894         p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1895         p5##_type gmock_p5, p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), \
1896         p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), \
1897         p6(gmock_p6) {\
1898     }\
1899     p0##_type p0;\
1900     p1##_type p1;\
1901     p2##_type p2;\
1902     p3##_type p3;\
1903     p4##_type p4;\
1904     p5##_type p5;\
1905     p6##_type p6;\
1906    private:\
1907     GTEST_DISALLOW_ASSIGN_(name##MatcherP7);\
1908   };\
1909   template <typename p0##_type, typename p1##_type, typename p2##_type, \
1910       typename p3##_type, typename p4##_type, typename p5##_type, \
1911       typename p6##_type>\
1912   inline name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
1913       p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \
1914       p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
1915       p6##_type p6) {\
1916     return name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
1917         p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\
1918   }\
1919   template <typename p0##_type, typename p1##_type, typename p2##_type, \
1920       typename p3##_type, typename p4##_type, typename p5##_type, \
1921       typename p6##_type>\
1922   template <typename arg_type>\
1923   bool name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
1924       p5##_type, p6##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1925       arg_type arg, \
1926       ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1927           const
1928 
1929 #define MATCHER_P8(name, p0, p1, p2, p3, p4, p5, p6, p7, description)\
1930   template <typename p0##_type, typename p1##_type, typename p2##_type, \
1931       typename p3##_type, typename p4##_type, typename p5##_type, \
1932       typename p6##_type, typename p7##_type>\
1933   class name##MatcherP8 {\
1934    public:\
1935     template <typename arg_type>\
1936     class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1937      public:\
1938       gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1939           p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
1940           p6##_type gmock_p6, p7##_type gmock_p7)\
1941            : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1942                p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7) {}\
1943       virtual bool MatchAndExplain(\
1944           arg_type arg, ::testing::MatchResultListener* result_listener) const;\
1945       virtual void DescribeTo(::std::ostream* gmock_os) const {\
1946         *gmock_os << FormatDescription(false);\
1947       }\
1948       virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1949         *gmock_os << FormatDescription(true);\
1950       }\
1951       p0##_type p0;\
1952       p1##_type p1;\
1953       p2##_type p2;\
1954       p3##_type p3;\
1955       p4##_type p4;\
1956       p5##_type p5;\
1957       p6##_type p6;\
1958       p7##_type p7;\
1959      private:\
1960       ::testing::internal::string FormatDescription(bool negation) const {\
1961         const ::testing::internal::string gmock_description = (description);\
1962         if (!gmock_description.empty())\
1963           return gmock_description;\
1964         return ::testing::internal::FormatMatcherDescription(\
1965             negation, #name, \
1966             ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1967                 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1968                     p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, \
1969                     p3, p4, p5, p6, p7)));\
1970       }\
1971       GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1972     };\
1973     template <typename arg_type>\
1974     operator ::testing::Matcher<arg_type>() const {\
1975       return ::testing::Matcher<arg_type>(\
1976           new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7));\
1977     }\
1978     name##MatcherP8(p0##_type gmock_p0, p1##_type gmock_p1, \
1979         p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1980         p5##_type gmock_p5, p6##_type gmock_p6, \
1981         p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1982         p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
1983         p7(gmock_p7) {\
1984     }\
1985     p0##_type p0;\
1986     p1##_type p1;\
1987     p2##_type p2;\
1988     p3##_type p3;\
1989     p4##_type p4;\
1990     p5##_type p5;\
1991     p6##_type p6;\
1992     p7##_type p7;\
1993    private:\
1994     GTEST_DISALLOW_ASSIGN_(name##MatcherP8);\
1995   };\
1996   template <typename p0##_type, typename p1##_type, typename p2##_type, \
1997       typename p3##_type, typename p4##_type, typename p5##_type, \
1998       typename p6##_type, typename p7##_type>\
1999   inline name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
2000       p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \
2001       p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
2002       p6##_type p6, p7##_type p7) {\
2003     return name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
2004         p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5, \
2005         p6, p7);\
2006   }\
2007   template <typename p0##_type, typename p1##_type, typename p2##_type, \
2008       typename p3##_type, typename p4##_type, typename p5##_type, \
2009       typename p6##_type, typename p7##_type>\
2010   template <typename arg_type>\
2011   bool name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
2012       p5##_type, p6##_type, \
2013       p7##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
2014       arg_type arg, \
2015       ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
2016           const
2017 
2018 #define MATCHER_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, description)\
2019   template <typename p0##_type, typename p1##_type, typename p2##_type, \
2020       typename p3##_type, typename p4##_type, typename p5##_type, \
2021       typename p6##_type, typename p7##_type, typename p8##_type>\
2022   class name##MatcherP9 {\
2023    public:\
2024     template <typename arg_type>\
2025     class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
2026      public:\
2027       gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
2028           p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
2029           p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8)\
2030            : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
2031                p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
2032                p8(gmock_p8) {}\
2033       virtual bool MatchAndExplain(\
2034           arg_type arg, ::testing::MatchResultListener* result_listener) const;\
2035       virtual void DescribeTo(::std::ostream* gmock_os) const {\
2036         *gmock_os << FormatDescription(false);\
2037       }\
2038       virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
2039         *gmock_os << FormatDescription(true);\
2040       }\
2041       p0##_type p0;\
2042       p1##_type p1;\
2043       p2##_type p2;\
2044       p3##_type p3;\
2045       p4##_type p4;\
2046       p5##_type p5;\
2047       p6##_type p6;\
2048       p7##_type p7;\
2049       p8##_type p8;\
2050      private:\
2051       ::testing::internal::string FormatDescription(bool negation) const {\
2052         const ::testing::internal::string gmock_description = (description);\
2053         if (!gmock_description.empty())\
2054           return gmock_description;\
2055         return ::testing::internal::FormatMatcherDescription(\
2056             negation, #name, \
2057             ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
2058                 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
2059                     p4##_type, p5##_type, p6##_type, p7##_type, \
2060                     p8##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8)));\
2061       }\
2062       GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
2063     };\
2064     template <typename arg_type>\
2065     operator ::testing::Matcher<arg_type>() const {\
2066       return ::testing::Matcher<arg_type>(\
2067           new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8));\
2068     }\
2069     name##MatcherP9(p0##_type gmock_p0, p1##_type gmock_p1, \
2070         p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
2071         p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
2072         p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
2073         p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
2074         p8(gmock_p8) {\
2075     }\
2076     p0##_type p0;\
2077     p1##_type p1;\
2078     p2##_type p2;\
2079     p3##_type p3;\
2080     p4##_type p4;\
2081     p5##_type p5;\
2082     p6##_type p6;\
2083     p7##_type p7;\
2084     p8##_type p8;\
2085    private:\
2086     GTEST_DISALLOW_ASSIGN_(name##MatcherP9);\
2087   };\
2088   template <typename p0##_type, typename p1##_type, typename p2##_type, \
2089       typename p3##_type, typename p4##_type, typename p5##_type, \
2090       typename p6##_type, typename p7##_type, typename p8##_type>\
2091   inline name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \
2092       p4##_type, p5##_type, p6##_type, p7##_type, \
2093       p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
2094       p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \
2095       p8##_type p8) {\
2096     return name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \
2097         p4##_type, p5##_type, p6##_type, p7##_type, p8##_type>(p0, p1, p2, \
2098         p3, p4, p5, p6, p7, p8);\
2099   }\
2100   template <typename p0##_type, typename p1##_type, typename p2##_type, \
2101       typename p3##_type, typename p4##_type, typename p5##_type, \
2102       typename p6##_type, typename p7##_type, typename p8##_type>\
2103   template <typename arg_type>\
2104   bool name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
2105       p5##_type, p6##_type, p7##_type, \
2106       p8##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
2107       arg_type arg, \
2108       ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
2109           const
2110 
2111 #define MATCHER_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, description)\
2112   template <typename p0##_type, typename p1##_type, typename p2##_type, \
2113       typename p3##_type, typename p4##_type, typename p5##_type, \
2114       typename p6##_type, typename p7##_type, typename p8##_type, \
2115       typename p9##_type>\
2116   class name##MatcherP10 {\
2117    public:\
2118     template <typename arg_type>\
2119     class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
2120      public:\
2121       gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
2122           p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
2123           p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
2124           p9##_type gmock_p9)\
2125            : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
2126                p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
2127                p8(gmock_p8), p9(gmock_p9) {}\
2128       virtual bool MatchAndExplain(\
2129           arg_type arg, ::testing::MatchResultListener* result_listener) const;\
2130       virtual void DescribeTo(::std::ostream* gmock_os) const {\
2131         *gmock_os << FormatDescription(false);\
2132       }\
2133       virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
2134         *gmock_os << FormatDescription(true);\
2135       }\
2136       p0##_type p0;\
2137       p1##_type p1;\
2138       p2##_type p2;\
2139       p3##_type p3;\
2140       p4##_type p4;\
2141       p5##_type p5;\
2142       p6##_type p6;\
2143       p7##_type p7;\
2144       p8##_type p8;\
2145       p9##_type p9;\
2146      private:\
2147       ::testing::internal::string FormatDescription(bool negation) const {\
2148         const ::testing::internal::string gmock_description = (description);\
2149         if (!gmock_description.empty())\
2150           return gmock_description;\
2151         return ::testing::internal::FormatMatcherDescription(\
2152             negation, #name, \
2153             ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
2154                 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
2155                     p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
2156                     p9##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)));\
2157       }\
2158       GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
2159     };\
2160     template <typename arg_type>\
2161     operator ::testing::Matcher<arg_type>() const {\
2162       return ::testing::Matcher<arg_type>(\
2163           new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9));\
2164     }\
2165     name##MatcherP10(p0##_type gmock_p0, p1##_type gmock_p1, \
2166         p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
2167         p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
2168         p8##_type gmock_p8, p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), \
2169         p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
2170         p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {\
2171     }\
2172     p0##_type p0;\
2173     p1##_type p1;\
2174     p2##_type p2;\
2175     p3##_type p3;\
2176     p4##_type p4;\
2177     p5##_type p5;\
2178     p6##_type p6;\
2179     p7##_type p7;\
2180     p8##_type p8;\
2181     p9##_type p9;\
2182    private:\
2183     GTEST_DISALLOW_ASSIGN_(name##MatcherP10);\
2184   };\
2185   template <typename p0##_type, typename p1##_type, typename p2##_type, \
2186       typename p3##_type, typename p4##_type, typename p5##_type, \
2187       typename p6##_type, typename p7##_type, typename p8##_type, \
2188       typename p9##_type>\
2189   inline name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
2190       p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
2191       p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
2192       p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
2193       p9##_type p9) {\
2194     return name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
2195         p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>(p0, \
2196         p1, p2, p3, p4, p5, p6, p7, p8, p9);\
2197   }\
2198   template <typename p0##_type, typename p1##_type, typename p2##_type, \
2199       typename p3##_type, typename p4##_type, typename p5##_type, \
2200       typename p6##_type, typename p7##_type, typename p8##_type, \
2201       typename p9##_type>\
2202   template <typename arg_type>\
2203   bool name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
2204       p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
2205       p9##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
2206       arg_type arg, \
2207       ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
2208           const
2209 
2210 #endif  // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
2211