blob: 5527ed3eb6b5e6c6799c66bd97a1552f2337ed59 [file] [log] [blame]
zhanyong.wanb1c7f932010-03-24 17:35:11 +00001// This file was GENERATED by command:
2// pump.py gmock-generated-matchers.h.pump
3// DO NOT EDIT BY HAND!!!
shiqiane35fdd92008-12-10 05:08:54 +00004
5// Copyright 2008, Google Inc.
6// All rights reserved.
7//
8// Redistribution and use in source and binary forms, with or without
9// modification, are permitted provided that the following conditions are
10// met:
11//
12// * Redistributions of source code must retain the above copyright
13// notice, this list of conditions and the following disclaimer.
14// * Redistributions in binary form must reproduce the above
15// copyright notice, this list of conditions and the following disclaimer
16// in the documentation and/or other materials provided with the
17// distribution.
18// * Neither the name of Google Inc. nor the names of its
19// contributors may be used to endorse or promote products derived from
20// this software without specific prior written permission.
21//
22// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
34// Google Mock - a framework for writing C++ mock classes.
35//
36// This file implements some commonly used variadic matchers.
37
38#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
39#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
40
41#include <sstream>
42#include <string>
43#include <vector>
zhanyong.wan53e08c42010-09-14 05:38:21 +000044#include "gmock/gmock-matchers.h"
shiqiane35fdd92008-12-10 05:08:54 +000045
46namespace testing {
47namespace internal {
48
zhanyong.wan2661c682009-06-09 05:42:12 +000049// The type of the i-th (0-based) field of Tuple.
50#define GMOCK_FIELD_TYPE_(Tuple, i) \
51 typename ::std::tr1::tuple_element<i, Tuple>::type
52
53// TupleFields<Tuple, k0, ..., kn> is for selecting fields from a
54// tuple of type Tuple. It has two members:
55//
56// type: a tuple type whose i-th field is the ki-th field of Tuple.
57// GetSelectedFields(t): returns fields k0, ..., and kn of t as a tuple.
58//
59// For example, in class TupleFields<tuple<bool, char, int>, 2, 0>, we have:
60//
61// type is tuple<int, bool>, and
62// GetSelectedFields(make_tuple(true, 'a', 42)) is (42, true).
63
64template <class Tuple, int k0 = -1, int k1 = -1, int k2 = -1, int k3 = -1,
65 int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
66 int k9 = -1>
67class TupleFields;
68
69// This generic version is used when there are 10 selectors.
70template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
71 int k7, int k8, int k9>
72class TupleFields {
73 public:
74 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
75 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
76 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
77 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
78 GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8),
79 GMOCK_FIELD_TYPE_(Tuple, k9)> type;
80 static type GetSelectedFields(const Tuple& t) {
81 using ::std::tr1::get;
82 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
83 get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t), get<k9>(t));
84 }
85};
86
87// The following specialization is used for 0 ~ 9 selectors.
88
89template <class Tuple>
90class TupleFields<Tuple, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
91 public:
92 typedef ::std::tr1::tuple<> type;
zhanyong.wan32de5f52009-12-23 00:13:23 +000093 static type GetSelectedFields(const Tuple& /* t */) {
zhanyong.wan2661c682009-06-09 05:42:12 +000094 using ::std::tr1::get;
95 return type();
96 }
97};
98
99template <class Tuple, int k0>
100class TupleFields<Tuple, k0, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
101 public:
102 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0)> type;
103 static type GetSelectedFields(const Tuple& t) {
104 using ::std::tr1::get;
105 return type(get<k0>(t));
106 }
107};
108
109template <class Tuple, int k0, int k1>
110class TupleFields<Tuple, k0, k1, -1, -1, -1, -1, -1, -1, -1, -1> {
111 public:
112 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
113 GMOCK_FIELD_TYPE_(Tuple, k1)> type;
114 static type GetSelectedFields(const Tuple& t) {
115 using ::std::tr1::get;
116 return type(get<k0>(t), get<k1>(t));
117 }
118};
119
120template <class Tuple, int k0, int k1, int k2>
121class TupleFields<Tuple, k0, k1, k2, -1, -1, -1, -1, -1, -1, -1> {
122 public:
123 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
124 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2)> type;
125 static type GetSelectedFields(const Tuple& t) {
126 using ::std::tr1::get;
127 return type(get<k0>(t), get<k1>(t), get<k2>(t));
128 }
129};
130
131template <class Tuple, int k0, int k1, int k2, int k3>
132class TupleFields<Tuple, k0, k1, k2, k3, -1, -1, -1, -1, -1, -1> {
133 public:
134 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
135 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
136 GMOCK_FIELD_TYPE_(Tuple, k3)> type;
137 static type GetSelectedFields(const Tuple& t) {
138 using ::std::tr1::get;
139 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t));
140 }
141};
142
143template <class Tuple, int k0, int k1, int k2, int k3, int k4>
144class TupleFields<Tuple, k0, k1, k2, k3, k4, -1, -1, -1, -1, -1> {
145 public:
146 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
147 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
148 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4)> type;
149 static type GetSelectedFields(const Tuple& t) {
150 using ::std::tr1::get;
151 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t));
152 }
153};
154
155template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5>
156class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, -1, -1, -1, -1> {
157 public:
158 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
159 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
160 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
161 GMOCK_FIELD_TYPE_(Tuple, k5)> type;
162 static type GetSelectedFields(const Tuple& t) {
163 using ::std::tr1::get;
164 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
165 get<k5>(t));
166 }
167};
168
169template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6>
170class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, -1, -1, -1> {
171 public:
172 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
173 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
174 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
175 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6)> type;
176 static type GetSelectedFields(const Tuple& t) {
177 using ::std::tr1::get;
178 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
179 get<k5>(t), get<k6>(t));
180 }
181};
182
183template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
184 int k7>
185class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, -1, -1> {
186 public:
187 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
188 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
189 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
190 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
191 GMOCK_FIELD_TYPE_(Tuple, k7)> type;
192 static type GetSelectedFields(const Tuple& t) {
193 using ::std::tr1::get;
194 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
195 get<k5>(t), get<k6>(t), get<k7>(t));
196 }
197};
198
199template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
200 int k7, int k8>
201class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, k8, -1> {
202 public:
203 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
204 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
205 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
206 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
207 GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8)> type;
208 static type GetSelectedFields(const Tuple& t) {
209 using ::std::tr1::get;
210 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
211 get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t));
212 }
213};
214
215#undef GMOCK_FIELD_TYPE_
216
217// Implements the Args() matcher.
218template <class ArgsTuple, int k0 = -1, int k1 = -1, int k2 = -1, int k3 = -1,
219 int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
220 int k9 = -1>
221class ArgsMatcherImpl : public MatcherInterface<ArgsTuple> {
222 public:
223 // ArgsTuple may have top-level const or reference modifiers.
zhanyong.wanab5b77c2010-05-17 19:32:48 +0000224 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(ArgsTuple) RawArgsTuple;
zhanyong.wan2661c682009-06-09 05:42:12 +0000225 typedef typename internal::TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5,
226 k6, k7, k8, k9>::type SelectedArgs;
227 typedef Matcher<const SelectedArgs&> MonomorphicInnerMatcher;
228
229 template <typename InnerMatcher>
230 explicit ArgsMatcherImpl(const InnerMatcher& inner_matcher)
231 : inner_matcher_(SafeMatcherCast<const SelectedArgs&>(inner_matcher)) {}
232
zhanyong.wan82113312010-01-08 21:55:40 +0000233 virtual bool MatchAndExplain(ArgsTuple args,
234 MatchResultListener* listener) const {
zhanyong.wanb1c7f932010-03-24 17:35:11 +0000235 const SelectedArgs& selected_args = GetSelectedArgs(args);
236 if (!listener->IsInterested())
237 return inner_matcher_.Matches(selected_args);
238
239 PrintIndices(listener->stream());
240 *listener << "are " << PrintToString(selected_args);
241
242 StringMatchResultListener inner_listener;
243 const bool match = inner_matcher_.MatchAndExplain(selected_args,
244 &inner_listener);
245 PrintIfNotEmpty(inner_listener.str(), listener->stream());
246 return match;
zhanyong.wan2661c682009-06-09 05:42:12 +0000247 }
248
249 virtual void DescribeTo(::std::ostream* os) const {
zhanyong.wanb1c7f932010-03-24 17:35:11 +0000250 *os << "are a tuple ";
zhanyong.wan2661c682009-06-09 05:42:12 +0000251 PrintIndices(os);
252 inner_matcher_.DescribeTo(os);
253 }
254
255 virtual void DescribeNegationTo(::std::ostream* os) const {
zhanyong.wanb1c7f932010-03-24 17:35:11 +0000256 *os << "are a tuple ";
zhanyong.wan2661c682009-06-09 05:42:12 +0000257 PrintIndices(os);
258 inner_matcher_.DescribeNegationTo(os);
259 }
260
zhanyong.wan2661c682009-06-09 05:42:12 +0000261 private:
262 static SelectedArgs GetSelectedArgs(ArgsTuple args) {
263 return TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5, k6, k7, k8,
264 k9>::GetSelectedFields(args);
265 }
266
267 // Prints the indices of the selected fields.
268 static void PrintIndices(::std::ostream* os) {
zhanyong.wanb1c7f932010-03-24 17:35:11 +0000269 *os << "whose fields (";
zhanyong.wan2661c682009-06-09 05:42:12 +0000270 const int indices[10] = { k0, k1, k2, k3, k4, k5, k6, k7, k8, k9 };
271 for (int i = 0; i < 10; i++) {
272 if (indices[i] < 0)
273 break;
274
275 if (i >= 1)
276 *os << ", ";
277
278 *os << "#" << indices[i];
279 }
280 *os << ") ";
281 }
282
283 const MonomorphicInnerMatcher inner_matcher_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000284
285 GTEST_DISALLOW_ASSIGN_(ArgsMatcherImpl);
zhanyong.wan2661c682009-06-09 05:42:12 +0000286};
287
288template <class InnerMatcher, int k0 = -1, int k1 = -1, int k2 = -1,
289 int k3 = -1, int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1,
290 int k8 = -1, int k9 = -1>
291class ArgsMatcher {
292 public:
293 explicit ArgsMatcher(const InnerMatcher& inner_matcher)
294 : inner_matcher_(inner_matcher) {}
295
296 template <typename ArgsTuple>
297 operator Matcher<ArgsTuple>() const {
298 return MakeMatcher(new ArgsMatcherImpl<ArgsTuple, k0, k1, k2, k3, k4, k5,
299 k6, k7, k8, k9>(inner_matcher_));
300 }
301
zhanyong.wan32de5f52009-12-23 00:13:23 +0000302 private:
zhanyong.wan2661c682009-06-09 05:42:12 +0000303 const InnerMatcher inner_matcher_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000304
305 GTEST_DISALLOW_ASSIGN_(ArgsMatcher);
zhanyong.wan2661c682009-06-09 05:42:12 +0000306};
307
zhanyong.wan1afe1c72009-07-21 23:26:31 +0000308// Implements ElementsAre() of 1-10 arguments.
shiqiane35fdd92008-12-10 05:08:54 +0000309
310template <typename T1>
311class ElementsAreMatcher1 {
312 public:
313 explicit ElementsAreMatcher1(const T1& e1) : e1_(e1) {}
314
315 template <typename Container>
316 operator Matcher<Container>() const {
zhanyong.wanab5b77c2010-05-17 19:32:48 +0000317 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000318 typedef typename internal::StlContainerView<RawContainer>::type::value_type
319 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000320
zhanyong.wan95b12332009-09-25 18:55:50 +0000321 // 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));
shiqiane35fdd92008-12-10 05:08:54 +0000330 }
331
332 private:
333 const T1& e1_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000334
335 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher1);
shiqiane35fdd92008-12-10 05:08:54 +0000336};
337
338template <typename T1, typename T2>
339class ElementsAreMatcher2 {
340 public:
341 ElementsAreMatcher2(const T1& e1, const T2& e2) : e1_(e1), e2_(e2) {}
342
343 template <typename Container>
344 operator Matcher<Container>() const {
zhanyong.wanab5b77c2010-05-17 19:32:48 +0000345 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000346 typedef typename internal::StlContainerView<RawContainer>::type::value_type
347 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000348
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_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000360
361 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher2);
shiqiane35fdd92008-12-10 05:08:54 +0000362};
363
364template <typename T1, typename T2, typename T3>
365class ElementsAreMatcher3 {
366 public:
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 {
zhanyong.wanab5b77c2010-05-17 19:32:48 +0000372 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000373 typedef typename internal::StlContainerView<RawContainer>::type::value_type
374 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000375
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_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000389
390 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher3);
shiqiane35fdd92008-12-10 05:08:54 +0000391};
392
393template <typename T1, typename T2, typename T3, typename T4>
394class ElementsAreMatcher4 {
395 public:
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 {
zhanyong.wanab5b77c2010-05-17 19:32:48 +0000401 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000402 typedef typename internal::StlContainerView<RawContainer>::type::value_type
403 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000404
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_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000420
421 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher4);
shiqiane35fdd92008-12-10 05:08:54 +0000422};
423
424template <typename T1, typename T2, typename T3, typename T4, typename T5>
425class ElementsAreMatcher5 {
426 public:
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 {
zhanyong.wanab5b77c2010-05-17 19:32:48 +0000432 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000433 typedef typename internal::StlContainerView<RawContainer>::type::value_type
434 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000435
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_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000453
454 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher5);
shiqiane35fdd92008-12-10 05:08:54 +0000455};
456
457template <typename T1, typename T2, typename T3, typename T4, typename T5,
458 typename T6>
459class ElementsAreMatcher6 {
460 public:
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 {
zhanyong.wanab5b77c2010-05-17 19:32:48 +0000467 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000468 typedef typename internal::StlContainerView<RawContainer>::type::value_type
469 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000470
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_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000490
491 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher6);
shiqiane35fdd92008-12-10 05:08:54 +0000492};
493
494template <typename T1, typename T2, typename T3, typename T4, typename T5,
495 typename T6, typename T7>
496class ElementsAreMatcher7 {
497 public:
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 {
zhanyong.wanab5b77c2010-05-17 19:32:48 +0000504 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000505 typedef typename internal::StlContainerView<RawContainer>::type::value_type
506 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000507
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_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000529
530 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher7);
shiqiane35fdd92008-12-10 05:08:54 +0000531};
532
533template <typename T1, typename T2, typename T3, typename T4, typename T5,
534 typename T6, typename T7, typename T8>
535class ElementsAreMatcher8 {
536 public:
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 {
zhanyong.wanab5b77c2010-05-17 19:32:48 +0000543 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000544 typedef typename internal::StlContainerView<RawContainer>::type::value_type
545 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000546
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_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000570
571 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher8);
shiqiane35fdd92008-12-10 05:08:54 +0000572};
573
574template <typename T1, typename T2, typename T3, typename T4, typename T5,
575 typename T6, typename T7, typename T8, typename T9>
576class ElementsAreMatcher9 {
577 public:
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 {
zhanyong.wanab5b77c2010-05-17 19:32:48 +0000585 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000586 typedef typename internal::StlContainerView<RawContainer>::type::value_type
587 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000588
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_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000614
615 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher9);
shiqiane35fdd92008-12-10 05:08:54 +0000616};
617
618template <typename T1, typename T2, typename T3, typename T4, typename T5,
619 typename T6, typename T7, typename T8, typename T9, typename T10>
620class ElementsAreMatcher10 {
621 public:
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 {
zhanyong.wanab5b77c2010-05-17 19:32:48 +0000629 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000630 typedef typename internal::StlContainerView<RawContainer>::type::value_type
631 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000632
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_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000660
661 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher10);
shiqiane35fdd92008-12-10 05:08:54 +0000662};
663
jgm79a367e2012-04-10 16:02:11 +0000664// 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.
670template <typename M1>
671struct AllOfResult1 {
672 typedef M1 type;
673};
674
675template <typename M1, typename M2>
676struct AllOfResult2 {
677 typedef BothOfMatcher<
678 typename AllOfResult1<M1>::type,
679 typename AllOfResult1<M2>::type
680 > type;
681};
682
683template <typename M1, typename M2, typename M3>
684struct AllOfResult3 {
685 typedef BothOfMatcher<
686 typename AllOfResult1<M1>::type,
687 typename AllOfResult2<M2, M3>::type
688 > type;
689};
690
691template <typename M1, typename M2, typename M3, typename M4>
692struct AllOfResult4 {
693 typedef BothOfMatcher<
694 typename AllOfResult2<M1, M2>::type,
695 typename AllOfResult2<M3, M4>::type
696 > type;
697};
698
699template <typename M1, typename M2, typename M3, typename M4, typename M5>
700struct AllOfResult5 {
701 typedef BothOfMatcher<
702 typename AllOfResult2<M1, M2>::type,
703 typename AllOfResult3<M3, M4, M5>::type
704 > type;
705};
706
707template <typename M1, typename M2, typename M3, typename M4, typename M5,
708 typename M6>
709struct AllOfResult6 {
710 typedef BothOfMatcher<
711 typename AllOfResult3<M1, M2, M3>::type,
712 typename AllOfResult3<M4, M5, M6>::type
713 > type;
714};
715
716template <typename M1, typename M2, typename M3, typename M4, typename M5,
717 typename M6, typename M7>
718struct AllOfResult7 {
719 typedef BothOfMatcher<
720 typename AllOfResult3<M1, M2, M3>::type,
721 typename AllOfResult4<M4, M5, M6, M7>::type
722 > type;
723};
724
725template <typename M1, typename M2, typename M3, typename M4, typename M5,
726 typename M6, typename M7, typename M8>
727struct AllOfResult8 {
728 typedef BothOfMatcher<
729 typename AllOfResult4<M1, M2, M3, M4>::type,
730 typename AllOfResult4<M5, M6, M7, M8>::type
731 > type;
732};
733
734template <typename M1, typename M2, typename M3, typename M4, typename M5,
735 typename M6, typename M7, typename M8, typename M9>
736struct 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
743template <typename M1, typename M2, typename M3, typename M4, typename M5,
744 typename M6, typename M7, typename M8, typename M9, typename M10>
745struct 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.
758template <typename M1>
759struct AnyOfResult1 {
760 typedef M1 type;
761};
762
763template <typename M1, typename M2>
764struct AnyOfResult2 {
765 typedef EitherOfMatcher<
766 typename AnyOfResult1<M1>::type,
767 typename AnyOfResult1<M2>::type
768 > type;
769};
770
771template <typename M1, typename M2, typename M3>
772struct AnyOfResult3 {
773 typedef EitherOfMatcher<
774 typename AnyOfResult1<M1>::type,
775 typename AnyOfResult2<M2, M3>::type
776 > type;
777};
778
779template <typename M1, typename M2, typename M3, typename M4>
780struct AnyOfResult4 {
781 typedef EitherOfMatcher<
782 typename AnyOfResult2<M1, M2>::type,
783 typename AnyOfResult2<M3, M4>::type
784 > type;
785};
786
787template <typename M1, typename M2, typename M3, typename M4, typename M5>
788struct AnyOfResult5 {
789 typedef EitherOfMatcher<
790 typename AnyOfResult2<M1, M2>::type,
791 typename AnyOfResult3<M3, M4, M5>::type
792 > type;
793};
794
795template <typename M1, typename M2, typename M3, typename M4, typename M5,
796 typename M6>
797struct AnyOfResult6 {
798 typedef EitherOfMatcher<
799 typename AnyOfResult3<M1, M2, M3>::type,
800 typename AnyOfResult3<M4, M5, M6>::type
801 > type;
802};
803
804template <typename M1, typename M2, typename M3, typename M4, typename M5,
805 typename M6, typename M7>
806struct AnyOfResult7 {
807 typedef EitherOfMatcher<
808 typename AnyOfResult3<M1, M2, M3>::type,
809 typename AnyOfResult4<M4, M5, M6, M7>::type
810 > type;
811};
812
813template <typename M1, typename M2, typename M3, typename M4, typename M5,
814 typename M6, typename M7, typename M8>
815struct AnyOfResult8 {
816 typedef EitherOfMatcher<
817 typename AnyOfResult4<M1, M2, M3, M4>::type,
818 typename AnyOfResult4<M5, M6, M7, M8>::type
819 > type;
820};
821
822template <typename M1, typename M2, typename M3, typename M4, typename M5,
823 typename M6, typename M7, typename M8, typename M9>
824struct 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
831template <typename M1, typename M2, typename M3, typename M4, typename M5,
832 typename M6, typename M7, typename M8, typename M9, typename M10>
833struct 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
shiqiane35fdd92008-12-10 05:08:54 +0000840} // namespace internal
841
zhanyong.wan2661c682009-06-09 05:42:12 +0000842// 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.
845template <typename InnerMatcher>
846inline internal::ArgsMatcher<InnerMatcher>
847Args(const InnerMatcher& matcher) {
848 return internal::ArgsMatcher<InnerMatcher>(matcher);
849}
850
851template <int k1, typename InnerMatcher>
852inline internal::ArgsMatcher<InnerMatcher, k1>
853Args(const InnerMatcher& matcher) {
854 return internal::ArgsMatcher<InnerMatcher, k1>(matcher);
855}
856
857template <int k1, int k2, typename InnerMatcher>
858inline internal::ArgsMatcher<InnerMatcher, k1, k2>
859Args(const InnerMatcher& matcher) {
860 return internal::ArgsMatcher<InnerMatcher, k1, k2>(matcher);
861}
862
863template <int k1, int k2, int k3, typename InnerMatcher>
864inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3>
865Args(const InnerMatcher& matcher) {
866 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3>(matcher);
867}
868
869template <int k1, int k2, int k3, int k4, typename InnerMatcher>
870inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>
871Args(const InnerMatcher& matcher) {
872 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>(matcher);
873}
874
875template <int k1, int k2, int k3, int k4, int k5, typename InnerMatcher>
876inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>
877Args(const InnerMatcher& matcher) {
878 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>(matcher);
879}
880
881template <int k1, int k2, int k3, int k4, int k5, int k6, typename InnerMatcher>
882inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>
883Args(const InnerMatcher& matcher) {
884 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>(matcher);
885}
886
887template <int k1, int k2, int k3, int k4, int k5, int k6, int k7,
888 typename InnerMatcher>
889inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7>
890Args(const InnerMatcher& matcher) {
891 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6,
892 k7>(matcher);
893}
894
895template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
896 typename InnerMatcher>
897inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8>
898Args(const InnerMatcher& matcher) {
899 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7,
900 k8>(matcher);
901}
902
903template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
904 int k9, typename InnerMatcher>
905inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9>
906Args(const InnerMatcher& matcher) {
907 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
908 k9>(matcher);
909}
910
911template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
912 int k9, int k10, typename InnerMatcher>
913inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9,
914 k10>
915Args(const InnerMatcher& matcher) {
916 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
917 k9, k10>(matcher);
918}
919
shiqiane35fdd92008-12-10 05:08:54 +0000920// 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
930inline internal::ElementsAreMatcher0 ElementsAre() {
931 return internal::ElementsAreMatcher0();
932}
933
934template <typename T1>
935inline internal::ElementsAreMatcher1<T1> ElementsAre(const T1& e1) {
936 return internal::ElementsAreMatcher1<T1>(e1);
937}
938
939template <typename T1, typename T2>
940inline internal::ElementsAreMatcher2<T1, T2> ElementsAre(const T1& e1,
941 const T2& e2) {
942 return internal::ElementsAreMatcher2<T1, T2>(e1, e2);
943}
944
945template <typename T1, typename T2, typename T3>
946inline 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
951template <typename T1, typename T2, typename T3, typename T4>
952inline 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
957template <typename T1, typename T2, typename T3, typename T4, typename T5>
958inline internal::ElementsAreMatcher5<T1, T2, T3, T4,
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
964template <typename T1, typename T2, typename T3, typename T4, typename T5,
965 typename T6>
966inline internal::ElementsAreMatcher6<T1, T2, T3, T4, T5,
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
973template <typename T1, typename T2, typename T3, typename T4, typename T5,
974 typename T6, typename T7>
975inline internal::ElementsAreMatcher7<T1, T2, T3, T4, T5, T6,
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
982template <typename T1, typename T2, typename T3, typename T4, typename T5,
983 typename T6, typename T7, typename T8>
984inline internal::ElementsAreMatcher8<T1, T2, T3, T4, T5, T6, T7,
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
991template <typename T1, typename T2, typename T3, typename T4, typename T5,
992 typename T6, typename T7, typename T8, typename T9>
993inline internal::ElementsAreMatcher9<T1, T2, T3, T4, T5, T6, T7, T8,
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
1000template <typename T1, typename T2, typename T3, typename T4, typename T5,
1001 typename T6, typename T7, typename T8, typename T9, typename T10>
1002inline internal::ElementsAreMatcher10<T1, T2, T3, T4, T5, T6, T7, T8, T9,
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
1016template <typename T>
1017inline internal::ElementsAreArrayMatcher<T> ElementsAreArray(
1018 const T* first, size_t count) {
1019 return internal::ElementsAreArrayMatcher<T>(first, count);
1020}
1021
1022template <typename T, size_t N>
1023inline internal::ElementsAreArrayMatcher<T>
1024ElementsAreArray(const T (&array)[N]) {
1025 return internal::ElementsAreArrayMatcher<T>(array, N);
1026}
1027
zhanyong.wan02c15052010-06-09 19:21:30 +00001028// AllOf(m1, m2, ..., mk) matches any value that matches all of the given
zhanyong.wan86d2eeb2011-03-16 17:10:39 +00001029// sub-matchers. AllOf is called fully qualified to prevent ADL from firing.
zhanyong.wan02c15052010-06-09 19:21:30 +00001030
jgm79a367e2012-04-10 16:02:11 +00001031template <typename M1, typename M2>
1032inline typename internal::AllOfResult2<M1, M2>::type
1033AllOf(M1 m1, M2 m2) {
1034 return typename internal::AllOfResult2<M1, M2>::type(
1035 m1,
1036 m2);
zhanyong.wan02c15052010-06-09 19:21:30 +00001037}
1038
jgm79a367e2012-04-10 16:02:11 +00001039template <typename M1, typename M2, typename M3>
1040inline typename internal::AllOfResult3<M1, M2, M3>::type
1041AllOf(M1 m1, M2 m2, M3 m3) {
1042 return typename internal::AllOfResult3<M1, M2, M3>::type(
1043 m1,
1044 ::testing::AllOf(m2, m3));
zhanyong.wan02c15052010-06-09 19:21:30 +00001045}
1046
jgm79a367e2012-04-10 16:02:11 +00001047template <typename M1, typename M2, typename M3, typename M4>
1048inline typename internal::AllOfResult4<M1, M2, M3, M4>::type
1049AllOf(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));
zhanyong.wan02c15052010-06-09 19:21:30 +00001053}
1054
jgm79a367e2012-04-10 16:02:11 +00001055template <typename M1, typename M2, typename M3, typename M4, typename M5>
1056inline typename internal::AllOfResult5<M1, M2, M3, M4, M5>::type
1057AllOf(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));
zhanyong.wan02c15052010-06-09 19:21:30 +00001061}
1062
jgm79a367e2012-04-10 16:02:11 +00001063template <typename M1, typename M2, typename M3, typename M4, typename M5,
1064 typename M6>
1065inline typename internal::AllOfResult6<M1, M2, M3, M4, M5, M6>::type
1066AllOf(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));
zhanyong.wan02c15052010-06-09 19:21:30 +00001070}
1071
jgm79a367e2012-04-10 16:02:11 +00001072template <typename M1, typename M2, typename M3, typename M4, typename M5,
1073 typename M6, typename M7>
1074inline typename internal::AllOfResult7<M1, M2, M3, M4, M5, M6, M7>::type
1075AllOf(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));
zhanyong.wan02c15052010-06-09 19:21:30 +00001079}
1080
jgm79a367e2012-04-10 16:02:11 +00001081template <typename M1, typename M2, typename M3, typename M4, typename M5,
1082 typename M6, typename M7, typename M8>
1083inline typename internal::AllOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type
1084AllOf(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));
zhanyong.wan02c15052010-06-09 19:21:30 +00001088}
1089
jgm79a367e2012-04-10 16:02:11 +00001090template <typename M1, typename M2, typename M3, typename M4, typename M5,
1091 typename M6, typename M7, typename M8, typename M9>
1092inline typename internal::AllOfResult9<M1, M2, M3, M4, M5, M6, M7, M8, M9>::type
1093AllOf(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));
zhanyong.wan02c15052010-06-09 19:21:30 +00001098}
1099
jgm79a367e2012-04-10 16:02:11 +00001100template <typename M1, typename M2, typename M3, typename M4, typename M5,
1101 typename M6, typename M7, typename M8, typename M9, typename M10>
1102inline typename internal::AllOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
1103 M10>::type
1104AllOf(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));
zhanyong.wan02c15052010-06-09 19:21:30 +00001109}
1110
1111// AnyOf(m1, m2, ..., mk) matches any value that matches any of the given
zhanyong.wan86d2eeb2011-03-16 17:10:39 +00001112// sub-matchers. AnyOf is called fully qualified to prevent ADL from firing.
zhanyong.wan02c15052010-06-09 19:21:30 +00001113
jgm79a367e2012-04-10 16:02:11 +00001114template <typename M1, typename M2>
1115inline typename internal::AnyOfResult2<M1, M2>::type
1116AnyOf(M1 m1, M2 m2) {
1117 return typename internal::AnyOfResult2<M1, M2>::type(
1118 m1,
1119 m2);
zhanyong.wan02c15052010-06-09 19:21:30 +00001120}
1121
jgm79a367e2012-04-10 16:02:11 +00001122template <typename M1, typename M2, typename M3>
1123inline typename internal::AnyOfResult3<M1, M2, M3>::type
1124AnyOf(M1 m1, M2 m2, M3 m3) {
1125 return typename internal::AnyOfResult3<M1, M2, M3>::type(
1126 m1,
1127 ::testing::AnyOf(m2, m3));
zhanyong.wan02c15052010-06-09 19:21:30 +00001128}
1129
jgm79a367e2012-04-10 16:02:11 +00001130template <typename M1, typename M2, typename M3, typename M4>
1131inline typename internal::AnyOfResult4<M1, M2, M3, M4>::type
1132AnyOf(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));
zhanyong.wan02c15052010-06-09 19:21:30 +00001136}
1137
jgm79a367e2012-04-10 16:02:11 +00001138template <typename M1, typename M2, typename M3, typename M4, typename M5>
1139inline typename internal::AnyOfResult5<M1, M2, M3, M4, M5>::type
1140AnyOf(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));
zhanyong.wan02c15052010-06-09 19:21:30 +00001144}
1145
jgm79a367e2012-04-10 16:02:11 +00001146template <typename M1, typename M2, typename M3, typename M4, typename M5,
1147 typename M6>
1148inline typename internal::AnyOfResult6<M1, M2, M3, M4, M5, M6>::type
1149AnyOf(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));
zhanyong.wan02c15052010-06-09 19:21:30 +00001153}
1154
jgm79a367e2012-04-10 16:02:11 +00001155template <typename M1, typename M2, typename M3, typename M4, typename M5,
1156 typename M6, typename M7>
1157inline typename internal::AnyOfResult7<M1, M2, M3, M4, M5, M6, M7>::type
1158AnyOf(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));
zhanyong.wan02c15052010-06-09 19:21:30 +00001162}
1163
jgm79a367e2012-04-10 16:02:11 +00001164template <typename M1, typename M2, typename M3, typename M4, typename M5,
1165 typename M6, typename M7, typename M8>
1166inline typename internal::AnyOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type
1167AnyOf(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));
zhanyong.wan02c15052010-06-09 19:21:30 +00001171}
1172
jgm79a367e2012-04-10 16:02:11 +00001173template <typename M1, typename M2, typename M3, typename M4, typename M5,
1174 typename M6, typename M7, typename M8, typename M9>
1175inline typename internal::AnyOfResult9<M1, M2, M3, M4, M5, M6, M7, M8, M9>::type
1176AnyOf(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));
zhanyong.wan02c15052010-06-09 19:21:30 +00001181}
1182
jgm79a367e2012-04-10 16:02:11 +00001183template <typename M1, typename M2, typename M3, typename M4, typename M5,
1184 typename M6, typename M7, typename M8, typename M9, typename M10>
1185inline typename internal::AnyOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
1186 M10>::type
1187AnyOf(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));
zhanyong.wan02c15052010-06-09 19:21:30 +00001192}
1193
shiqiane35fdd92008-12-10 05:08:54 +00001194} // namespace testing
1195
zhanyong.wan86d2eeb2011-03-16 17:10:39 +00001196
zhanyong.wance198ff2009-02-12 01:34:27 +00001197// The MATCHER* family of macros can be used in a namespace scope to
zhanyong.wan82113312010-01-08 21:55:40 +00001198// define custom matchers easily.
1199//
1200// Basic Usage
1201// ===========
1202//
1203// The syntax
zhanyong.wance198ff2009-02-12 01:34:27 +00001204//
1205// MATCHER(name, description_string) { statements; }
1206//
zhanyong.wan82113312010-01-08 21:55:40 +00001207// 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'.
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001211//
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:
zhanyong.wance198ff2009-02-12 01:34:27 +00001221//
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//
zhanyong.wan82113312010-01-08 21:55:40 +00001243// Argument Type
1244// =============
1245//
zhanyong.wance198ff2009-02-12 01:34:27 +00001246// 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//
zhanyong.wan82113312010-01-08 21:55:40 +00001256// Parameterizing Matchers
1257// =======================
1258//
zhanyong.wance198ff2009-02-12 01:34:27 +00001259// 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//
zhanyong.wan82113312010-01-08 21:55:40 +00001289// Describing Parameterized Matchers
1290// =================================
1291//
zhanyong.wanb4140802010-06-08 22:53:57 +00001292// 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,
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001298//
zhanyong.wanb4140802010-06-08 22:53:57 +00001299// using testing::PrintToString;
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001300//
zhanyong.wanb4140802010-06-08 22:53:57 +00001301// MATCHER_P2(InClosedRange, low, hi,
1302// string(negation ? "is not" : "is") + " in range [" +
1303// PrintToString(low) + ", " + PrintToString(hi) + "]") {
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001304// return low <= arg && arg <= hi;
1305// }
1306// ...
1307// EXPECT_THAT(3, InClosedRange(4, 6));
zhanyong.wanb4140802010-06-08 22:53:57 +00001308// EXPECT_THAT(3, Not(InClosedRange(2, 4)));
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001309//
zhanyong.wanb4140802010-06-08 22:53:57 +00001310// would generate two failures that contain the text:
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001311//
1312// Expected: is in range [4, 6]
zhanyong.wanb4140802010-06-08 22:53:57 +00001313// ...
1314// Expected: is not in range [2, 4]
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001315//
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));
zhanyong.wanb4140802010-06-08 22:53:57 +00001323// EXPECT_THAT(3, Not(InClosedRange(2, 4)));
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001324//
zhanyong.wanb4140802010-06-08 22:53:57 +00001325// would generate two failures that contain the text:
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001326//
1327// Expected: in closed range (4, 6)
zhanyong.wanb4140802010-06-08 22:53:57 +00001328// ...
1329// Expected: not (in closed range (2, 4))
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001330//
zhanyong.wan82113312010-01-08 21:55:40 +00001331// Types of Matcher Parameters
1332// ===========================
1333//
zhanyong.wance198ff2009-02-12 01:34:27 +00001334// 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//
zhanyong.wan82113312010-01-08 21:55:40 +00001361// 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//
zhanyong.wance198ff2009-02-12 01:34:27 +00001383// 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//
zhanyong.wan82113312010-01-08 21:55:40 +00001388// Caveats
1389// =======
zhanyong.wance198ff2009-02-12 01:34:27 +00001390//
zhanyong.wan82113312010-01-08 21:55:40 +00001391// 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).
zhanyong.wance198ff2009-02-12 01:34:27 +00001399//
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//
zhanyong.wan82113312010-01-08 21:55:40 +00001406// More Information
1407// ================
zhanyong.wance198ff2009-02-12 01:34:27 +00001408//
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:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001418 gmock_Impl()\
1419 {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001420 virtual bool MatchAndExplain(\
1421 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001422 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001423 *gmock_os << FormatDescription(false);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001424 }\
zhanyong.wanb4140802010-06-08 22:53:57 +00001425 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1426 *gmock_os << FormatDescription(true);\
1427 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001428 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001429 ::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(\
jgm79a367e2012-04-10 16:02:11 +00001434 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001435 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1436 ::std::tr1::tuple<>()));\
1437 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001438 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001439 };\
1440 template <typename arg_type>\
1441 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001442 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001443 new gmock_Impl<arg_type>());\
zhanyong.wance198ff2009-02-12 01:34:27 +00001444 }\
1445 name##Matcher() {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001446 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001447 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001448 GTEST_DISALLOW_ASSIGN_(name##Matcher);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001449 };\
1450 inline name##Matcher name() {\
1451 return name##Matcher();\
1452 }\
1453 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001454 bool name##Matcher::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00001455 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00001456 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1457 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001458
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:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001466 explicit gmock_Impl(p0##_type gmock_p0)\
1467 : p0(gmock_p0) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001468 virtual bool MatchAndExplain(\
1469 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001470 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001471 *gmock_os << FormatDescription(false);\
1472 }\
1473 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1474 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001475 }\
1476 p0##_type p0;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001477 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001478 ::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(\
jgm79a367e2012-04-10 16:02:11 +00001483 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001484 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1485 ::std::tr1::tuple<p0##_type>(p0)));\
1486 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001487 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001488 };\
1489 template <typename arg_type>\
1490 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001491 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001492 new gmock_Impl<arg_type>(p0));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001493 }\
1494 name##MatcherP(p0##_type gmock_p0) : p0(gmock_p0) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001495 }\
1496 p0##_type p0;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001497 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001498 GTEST_DISALLOW_ASSIGN_(name##MatcherP);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001499 };\
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>\
zhanyong.wan82113312010-01-08 21:55:40 +00001506 bool name##MatcherP<p0##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00001507 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00001508 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1509 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001510
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:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001518 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1)\
1519 : p0(gmock_p0), p1(gmock_p1) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001520 virtual bool MatchAndExplain(\
1521 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001522 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001523 *gmock_os << FormatDescription(false);\
1524 }\
1525 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1526 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001527 }\
1528 p0##_type p0;\
1529 p1##_type p1;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001530 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001531 ::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(\
jgm79a367e2012-04-10 16:02:11 +00001536 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001537 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1538 ::std::tr1::tuple<p0##_type, p1##_type>(p0, p1)));\
1539 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001540 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001541 };\
1542 template <typename arg_type>\
1543 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001544 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001545 new gmock_Impl<arg_type>(p0, p1));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001546 }\
1547 name##MatcherP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
1548 p1(gmock_p1) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001549 }\
1550 p0##_type p0;\
1551 p1##_type p1;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001552 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001553 GTEST_DISALLOW_ASSIGN_(name##MatcherP2);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001554 };\
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>\
zhanyong.wan82113312010-01-08 21:55:40 +00001562 bool name##MatcherP2<p0##_type, \
1563 p1##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00001564 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00001565 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1566 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001567
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:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001575 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2)\
1576 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001577 virtual bool MatchAndExplain(\
1578 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001579 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001580 *gmock_os << FormatDescription(false);\
1581 }\
1582 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1583 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001584 }\
1585 p0##_type p0;\
1586 p1##_type p1;\
1587 p2##_type p2;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001588 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001589 ::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(\
jgm79a367e2012-04-10 16:02:11 +00001594 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001595 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1596 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type>(p0, p1, \
1597 p2)));\
1598 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001599 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001600 };\
1601 template <typename arg_type>\
1602 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001603 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001604 new gmock_Impl<arg_type>(p0, p1, p2));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001605 }\
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) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001608 }\
1609 p0##_type p0;\
1610 p1##_type p1;\
1611 p2##_type p2;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001612 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001613 GTEST_DISALLOW_ASSIGN_(name##MatcherP3);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001614 };\
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>\
zhanyong.wan82113312010-01-08 21:55:40 +00001622 bool name##MatcherP3<p0##_type, p1##_type, \
1623 p2##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00001624 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00001625 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1626 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001627
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, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001637 p3##_type gmock_p3)\
1638 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001639 virtual bool MatchAndExplain(\
1640 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001641 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001642 *gmock_os << FormatDescription(false);\
1643 }\
1644 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1645 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001646 }\
1647 p0##_type p0;\
1648 p1##_type p1;\
1649 p2##_type p2;\
1650 p3##_type p3;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001651 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001652 ::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(\
jgm79a367e2012-04-10 16:02:11 +00001657 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001658 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1659 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, \
1660 p3##_type>(p0, p1, p2, p3)));\
1661 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001662 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001663 };\
1664 template <typename arg_type>\
1665 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001666 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001667 new gmock_Impl<arg_type>(p0, p1, p2, p3));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001668 }\
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) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001672 }\
1673 p0##_type p0;\
1674 p1##_type p1;\
1675 p2##_type p2;\
1676 p3##_type p3;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001677 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001678 GTEST_DISALLOW_ASSIGN_(name##MatcherP4);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001679 };\
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>\
zhanyong.wan82113312010-01-08 21:55:40 +00001691 bool name##MatcherP4<p0##_type, p1##_type, p2##_type, \
1692 p3##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00001693 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00001694 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1695 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001696
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, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001706 p3##_type gmock_p3, p4##_type gmock_p4)\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001707 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
zhanyong.wanb4140802010-06-08 22:53:57 +00001708 p4(gmock_p4) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001709 virtual bool MatchAndExplain(\
1710 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001711 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001712 *gmock_os << FormatDescription(false);\
1713 }\
1714 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1715 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001716 }\
1717 p0##_type p0;\
1718 p1##_type p1;\
1719 p2##_type p2;\
1720 p3##_type p3;\
1721 p4##_type p4;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001722 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001723 ::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(\
jgm79a367e2012-04-10 16:02:11 +00001728 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001729 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1730 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1731 p4##_type>(p0, p1, p2, p3, p4)));\
1732 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001733 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001734 };\
1735 template <typename arg_type>\
1736 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001737 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001738 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001739 }\
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) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001744 }\
1745 p0##_type p0;\
1746 p1##_type p1;\
1747 p2##_type p2;\
1748 p3##_type p3;\
1749 p4##_type p4;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001750 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001751 GTEST_DISALLOW_ASSIGN_(name##MatcherP5);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001752 };\
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>\
zhanyong.wan82113312010-01-08 21:55:40 +00001764 bool name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1765 p4##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00001766 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00001767 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1768 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001769
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, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001779 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5)\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001780 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
zhanyong.wanb4140802010-06-08 22:53:57 +00001781 p4(gmock_p4), p5(gmock_p5) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001782 virtual bool MatchAndExplain(\
1783 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001784 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001785 *gmock_os << FormatDescription(false);\
1786 }\
1787 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1788 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001789 }\
1790 p0##_type p0;\
1791 p1##_type p1;\
1792 p2##_type p2;\
1793 p3##_type p3;\
1794 p4##_type p4;\
1795 p5##_type p5;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001796 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001797 ::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(\
jgm79a367e2012-04-10 16:02:11 +00001802 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001803 ::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 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001807 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001808 };\
1809 template <typename arg_type>\
1810 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001811 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001812 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001813 }\
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) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001818 }\
1819 p0##_type p0;\
1820 p1##_type p1;\
1821 p2##_type p2;\
1822 p3##_type p3;\
1823 p4##_type p4;\
1824 p5##_type p5;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001825 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001826 GTEST_DISALLOW_ASSIGN_(name##MatcherP6);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001827 };\
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, \
zhanyong.wan82113312010-01-08 21:55:40 +00001840 p5##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00001841 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00001842 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1843 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001844
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, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001856 p6##_type gmock_p6)\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001857 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
zhanyong.wanb4140802010-06-08 22:53:57 +00001858 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001859 virtual bool MatchAndExplain(\
1860 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001861 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001862 *gmock_os << FormatDescription(false);\
1863 }\
1864 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1865 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001866 }\
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;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001874 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001875 ::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(\
jgm79a367e2012-04-10 16:02:11 +00001880 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001881 ::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 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001886 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001887 };\
1888 template <typename arg_type>\
1889 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001890 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001891 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001892 }\
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) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001898 }\
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;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001906 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001907 GTEST_DISALLOW_ASSIGN_(name##MatcherP7);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001908 };\
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, \
zhanyong.wan82113312010-01-08 21:55:40 +00001924 p5##_type, p6##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00001925 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00001926 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1927 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001928
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, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001940 p6##_type gmock_p6, p7##_type gmock_p7)\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001941 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
zhanyong.wanb4140802010-06-08 22:53:57 +00001942 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001943 virtual bool MatchAndExplain(\
1944 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001945 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001946 *gmock_os << FormatDescription(false);\
1947 }\
1948 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1949 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001950 }\
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;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001959 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001960 ::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(\
jgm79a367e2012-04-10 16:02:11 +00001965 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001966 ::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 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001971 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001972 };\
1973 template <typename arg_type>\
1974 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001975 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001976 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001977 }\
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) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001984 }\
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;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001993 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001994 GTEST_DISALLOW_ASSIGN_(name##MatcherP8);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001995 };\
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, \
zhanyong.wan82113312010-01-08 21:55:40 +00002012 p5##_type, p6##_type, \
2013 p7##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00002014 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00002015 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
2016 const
zhanyong.wance198ff2009-02-12 01:34:27 +00002017
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, \
zhanyong.wanb4140802010-06-08 22:53:57 +00002029 p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8)\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00002030 : 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), \
zhanyong.wanb4140802010-06-08 22:53:57 +00002032 p8(gmock_p8) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00002033 virtual bool MatchAndExplain(\
2034 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00002035 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00002036 *gmock_os << FormatDescription(false);\
2037 }\
2038 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
2039 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00002040 }\
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;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002050 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00002051 ::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(\
jgm79a367e2012-04-10 16:02:11 +00002056 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00002057 ::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 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002062 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00002063 };\
2064 template <typename arg_type>\
2065 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00002066 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00002067 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8));\
zhanyong.wance198ff2009-02-12 01:34:27 +00002068 }\
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) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00002075 }\
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;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002085 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002086 GTEST_DISALLOW_ASSIGN_(name##MatcherP9);\
zhanyong.wance198ff2009-02-12 01:34:27 +00002087 };\
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, \
zhanyong.wan82113312010-01-08 21:55:40 +00002105 p5##_type, p6##_type, p7##_type, \
2106 p8##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00002107 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00002108 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
2109 const
zhanyong.wance198ff2009-02-12 01:34:27 +00002110
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, \
zhanyong.wanb4140802010-06-08 22:53:57 +00002124 p9##_type gmock_p9)\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00002125 : 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), \
zhanyong.wanb4140802010-06-08 22:53:57 +00002127 p8(gmock_p8), p9(gmock_p9) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00002128 virtual bool MatchAndExplain(\
2129 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00002130 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00002131 *gmock_os << FormatDescription(false);\
2132 }\
2133 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
2134 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00002135 }\
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;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002146 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00002147 ::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(\
jgm79a367e2012-04-10 16:02:11 +00002152 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00002153 ::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 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002158 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00002159 };\
2160 template <typename arg_type>\
2161 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00002162 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00002163 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9));\
zhanyong.wance198ff2009-02-12 01:34:27 +00002164 }\
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) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00002171 }\
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;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002182 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002183 GTEST_DISALLOW_ASSIGN_(name##MatcherP10);\
zhanyong.wance198ff2009-02-12 01:34:27 +00002184 };\
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, \
zhanyong.wan82113312010-01-08 21:55:40 +00002204 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
2205 p9##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00002206 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00002207 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
2208 const
zhanyong.wance198ff2009-02-12 01:34:27 +00002209
shiqiane35fdd92008-12-10 05:08:54 +00002210#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_