blob: 9e5bedea4cdd2c6dd9e6a73351afacf8d18b6c2e [file] [log] [blame]
zhanyong.wanb1c7f932010-03-24 17:35:11 +00001// This file was GENERATED by command:
2// pump.py gmock-generated-matchers.h.pump
3// DO NOT EDIT BY HAND!!!
shiqiane35fdd92008-12-10 05:08:54 +00004
5// Copyright 2008, Google Inc.
6// All rights reserved.
7//
8// Redistribution and use in source and binary forms, with or without
9// modification, are permitted provided that the following conditions are
10// met:
11//
12// * Redistributions of source code must retain the above copyright
13// notice, this list of conditions and the following disclaimer.
14// * Redistributions in binary form must reproduce the above
15// copyright notice, this list of conditions and the following disclaimer
16// in the documentation and/or other materials provided with the
17// distribution.
18// * Neither the name of Google Inc. nor the names of its
19// contributors may be used to endorse or promote products derived from
20// this software without specific prior written permission.
21//
22// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
34// Google Mock - a framework for writing C++ mock classes.
35//
36// This file implements some commonly used variadic matchers.
37
38#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
39#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
40
41#include <sstream>
42#include <string>
43#include <vector>
44#include <gmock/gmock-matchers.h>
zhanyong.wan4a5330d2009-02-19 00:36:44 +000045#include <gmock/gmock-printers.h>
shiqiane35fdd92008-12-10 05:08:54 +000046
47namespace testing {
48namespace internal {
49
zhanyong.wan2661c682009-06-09 05:42:12 +000050// The type of the i-th (0-based) field of Tuple.
51#define GMOCK_FIELD_TYPE_(Tuple, i) \
52 typename ::std::tr1::tuple_element<i, Tuple>::type
53
54// TupleFields<Tuple, k0, ..., kn> is for selecting fields from a
55// tuple of type Tuple. It has two members:
56//
57// type: a tuple type whose i-th field is the ki-th field of Tuple.
58// GetSelectedFields(t): returns fields k0, ..., and kn of t as a tuple.
59//
60// For example, in class TupleFields<tuple<bool, char, int>, 2, 0>, we have:
61//
62// type is tuple<int, bool>, and
63// GetSelectedFields(make_tuple(true, 'a', 42)) is (42, true).
64
65template <class Tuple, int k0 = -1, int k1 = -1, int k2 = -1, int k3 = -1,
66 int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
67 int k9 = -1>
68class TupleFields;
69
70// This generic version is used when there are 10 selectors.
71template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
72 int k7, int k8, int k9>
73class TupleFields {
74 public:
75 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
76 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
77 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
78 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
79 GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8),
80 GMOCK_FIELD_TYPE_(Tuple, k9)> type;
81 static type GetSelectedFields(const Tuple& t) {
82 using ::std::tr1::get;
83 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
84 get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t), get<k9>(t));
85 }
86};
87
88// The following specialization is used for 0 ~ 9 selectors.
89
90template <class Tuple>
91class TupleFields<Tuple, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
92 public:
93 typedef ::std::tr1::tuple<> type;
zhanyong.wan32de5f52009-12-23 00:13:23 +000094 static type GetSelectedFields(const Tuple& /* t */) {
zhanyong.wan2661c682009-06-09 05:42:12 +000095 using ::std::tr1::get;
96 return type();
97 }
98};
99
100template <class Tuple, int k0>
101class TupleFields<Tuple, k0, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
102 public:
103 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0)> type;
104 static type GetSelectedFields(const Tuple& t) {
105 using ::std::tr1::get;
106 return type(get<k0>(t));
107 }
108};
109
110template <class Tuple, int k0, int k1>
111class TupleFields<Tuple, k0, k1, -1, -1, -1, -1, -1, -1, -1, -1> {
112 public:
113 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
114 GMOCK_FIELD_TYPE_(Tuple, k1)> type;
115 static type GetSelectedFields(const Tuple& t) {
116 using ::std::tr1::get;
117 return type(get<k0>(t), get<k1>(t));
118 }
119};
120
121template <class Tuple, int k0, int k1, int k2>
122class TupleFields<Tuple, k0, k1, k2, -1, -1, -1, -1, -1, -1, -1> {
123 public:
124 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
125 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2)> type;
126 static type GetSelectedFields(const Tuple& t) {
127 using ::std::tr1::get;
128 return type(get<k0>(t), get<k1>(t), get<k2>(t));
129 }
130};
131
132template <class Tuple, int k0, int k1, int k2, int k3>
133class TupleFields<Tuple, k0, k1, k2, k3, -1, -1, -1, -1, -1, -1> {
134 public:
135 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
136 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
137 GMOCK_FIELD_TYPE_(Tuple, k3)> type;
138 static type GetSelectedFields(const Tuple& t) {
139 using ::std::tr1::get;
140 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t));
141 }
142};
143
144template <class Tuple, int k0, int k1, int k2, int k3, int k4>
145class TupleFields<Tuple, k0, k1, k2, k3, k4, -1, -1, -1, -1, -1> {
146 public:
147 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
148 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
149 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4)> type;
150 static type GetSelectedFields(const Tuple& t) {
151 using ::std::tr1::get;
152 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t));
153 }
154};
155
156template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5>
157class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, -1, -1, -1, -1> {
158 public:
159 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
160 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
161 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
162 GMOCK_FIELD_TYPE_(Tuple, k5)> type;
163 static type GetSelectedFields(const Tuple& t) {
164 using ::std::tr1::get;
165 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
166 get<k5>(t));
167 }
168};
169
170template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6>
171class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, -1, -1, -1> {
172 public:
173 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
174 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
175 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
176 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6)> type;
177 static type GetSelectedFields(const Tuple& t) {
178 using ::std::tr1::get;
179 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
180 get<k5>(t), get<k6>(t));
181 }
182};
183
184template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
185 int k7>
186class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, -1, -1> {
187 public:
188 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
189 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
190 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
191 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
192 GMOCK_FIELD_TYPE_(Tuple, k7)> type;
193 static type GetSelectedFields(const Tuple& t) {
194 using ::std::tr1::get;
195 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
196 get<k5>(t), get<k6>(t), get<k7>(t));
197 }
198};
199
200template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
201 int k7, int k8>
202class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, k8, -1> {
203 public:
204 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
205 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
206 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
207 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
208 GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8)> type;
209 static type GetSelectedFields(const Tuple& t) {
210 using ::std::tr1::get;
211 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
212 get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t));
213 }
214};
215
216#undef GMOCK_FIELD_TYPE_
217
218// Implements the Args() matcher.
219template <class ArgsTuple, int k0 = -1, int k1 = -1, int k2 = -1, int k3 = -1,
220 int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
221 int k9 = -1>
222class ArgsMatcherImpl : public MatcherInterface<ArgsTuple> {
223 public:
224 // ArgsTuple may have top-level const or reference modifiers.
225 typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(ArgsTuple)) RawArgsTuple;
226 typedef typename internal::TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5,
227 k6, k7, k8, k9>::type SelectedArgs;
228 typedef Matcher<const SelectedArgs&> MonomorphicInnerMatcher;
229
230 template <typename InnerMatcher>
231 explicit ArgsMatcherImpl(const InnerMatcher& inner_matcher)
232 : inner_matcher_(SafeMatcherCast<const SelectedArgs&>(inner_matcher)) {}
233
zhanyong.wan82113312010-01-08 21:55:40 +0000234 virtual bool MatchAndExplain(ArgsTuple args,
235 MatchResultListener* listener) const {
zhanyong.wanb1c7f932010-03-24 17:35:11 +0000236 const SelectedArgs& selected_args = GetSelectedArgs(args);
237 if (!listener->IsInterested())
238 return inner_matcher_.Matches(selected_args);
239
240 PrintIndices(listener->stream());
241 *listener << "are " << PrintToString(selected_args);
242
243 StringMatchResultListener inner_listener;
244 const bool match = inner_matcher_.MatchAndExplain(selected_args,
245 &inner_listener);
246 PrintIfNotEmpty(inner_listener.str(), listener->stream());
247 return match;
zhanyong.wan2661c682009-06-09 05:42:12 +0000248 }
249
250 virtual void DescribeTo(::std::ostream* os) const {
zhanyong.wanb1c7f932010-03-24 17:35:11 +0000251 *os << "are a tuple ";
zhanyong.wan2661c682009-06-09 05:42:12 +0000252 PrintIndices(os);
253 inner_matcher_.DescribeTo(os);
254 }
255
256 virtual void DescribeNegationTo(::std::ostream* os) const {
zhanyong.wanb1c7f932010-03-24 17:35:11 +0000257 *os << "are a tuple ";
zhanyong.wan2661c682009-06-09 05:42:12 +0000258 PrintIndices(os);
259 inner_matcher_.DescribeNegationTo(os);
260 }
261
zhanyong.wan2661c682009-06-09 05:42:12 +0000262 private:
263 static SelectedArgs GetSelectedArgs(ArgsTuple args) {
264 return TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5, k6, k7, k8,
265 k9>::GetSelectedFields(args);
266 }
267
268 // Prints the indices of the selected fields.
269 static void PrintIndices(::std::ostream* os) {
zhanyong.wanb1c7f932010-03-24 17:35:11 +0000270 *os << "whose fields (";
zhanyong.wan2661c682009-06-09 05:42:12 +0000271 const int indices[10] = { k0, k1, k2, k3, k4, k5, k6, k7, k8, k9 };
272 for (int i = 0; i < 10; i++) {
273 if (indices[i] < 0)
274 break;
275
276 if (i >= 1)
277 *os << ", ";
278
279 *os << "#" << indices[i];
280 }
281 *os << ") ";
282 }
283
284 const MonomorphicInnerMatcher inner_matcher_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000285
286 GTEST_DISALLOW_ASSIGN_(ArgsMatcherImpl);
zhanyong.wan2661c682009-06-09 05:42:12 +0000287};
288
289template <class InnerMatcher, int k0 = -1, int k1 = -1, int k2 = -1,
290 int k3 = -1, int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1,
291 int k8 = -1, int k9 = -1>
292class ArgsMatcher {
293 public:
294 explicit ArgsMatcher(const InnerMatcher& inner_matcher)
295 : inner_matcher_(inner_matcher) {}
296
297 template <typename ArgsTuple>
298 operator Matcher<ArgsTuple>() const {
299 return MakeMatcher(new ArgsMatcherImpl<ArgsTuple, k0, k1, k2, k3, k4, k5,
300 k6, k7, k8, k9>(inner_matcher_));
301 }
302
zhanyong.wan32de5f52009-12-23 00:13:23 +0000303 private:
zhanyong.wan2661c682009-06-09 05:42:12 +0000304 const InnerMatcher inner_matcher_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000305
306 GTEST_DISALLOW_ASSIGN_(ArgsMatcher);
zhanyong.wan2661c682009-06-09 05:42:12 +0000307};
308
zhanyong.wan1afe1c72009-07-21 23:26:31 +0000309// Implements ElementsAre() of 1-10 arguments.
shiqiane35fdd92008-12-10 05:08:54 +0000310
311template <typename T1>
312class ElementsAreMatcher1 {
313 public:
314 explicit ElementsAreMatcher1(const T1& e1) : e1_(e1) {}
315
316 template <typename Container>
317 operator Matcher<Container>() const {
zhanyong.wane0d051e2009-02-19 00:33:37 +0000318 typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
319 RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000320 typedef typename internal::StlContainerView<RawContainer>::type::value_type
321 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000322
zhanyong.wan95b12332009-09-25 18:55:50 +0000323 // Nokia's Symbian Compiler has a nasty bug where the object put
324 // in a one-element local array is not destructed when the array
325 // goes out of scope. This leads to obvious badness as we've
326 // added the linked_ptr in it to our other linked_ptrs list.
327 // Hence we implement ElementsAreMatcher1 specially to avoid using
328 // a local array.
329 const Matcher<const Element&> matcher =
330 MatcherCast<const Element&>(e1_);
331 return MakeMatcher(new ElementsAreMatcherImpl<Container>(&matcher, 1));
shiqiane35fdd92008-12-10 05:08:54 +0000332 }
333
334 private:
335 const T1& e1_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000336
337 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher1);
shiqiane35fdd92008-12-10 05:08:54 +0000338};
339
340template <typename T1, typename T2>
341class ElementsAreMatcher2 {
342 public:
343 ElementsAreMatcher2(const T1& e1, const T2& e2) : e1_(e1), e2_(e2) {}
344
345 template <typename Container>
346 operator Matcher<Container>() const {
zhanyong.wane0d051e2009-02-19 00:33:37 +0000347 typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
348 RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000349 typedef typename internal::StlContainerView<RawContainer>::type::value_type
350 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000351
352 const Matcher<const Element&> matchers[] = {
353 MatcherCast<const Element&>(e1_),
354 MatcherCast<const Element&>(e2_),
355 };
356
357 return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 2));
358 }
359
360 private:
361 const T1& e1_;
362 const T2& e2_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000363
364 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher2);
shiqiane35fdd92008-12-10 05:08:54 +0000365};
366
367template <typename T1, typename T2, typename T3>
368class ElementsAreMatcher3 {
369 public:
370 ElementsAreMatcher3(const T1& e1, const T2& e2, const T3& e3) : e1_(e1),
371 e2_(e2), e3_(e3) {}
372
373 template <typename Container>
374 operator Matcher<Container>() const {
zhanyong.wane0d051e2009-02-19 00:33:37 +0000375 typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
376 RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000377 typedef typename internal::StlContainerView<RawContainer>::type::value_type
378 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000379
380 const Matcher<const Element&> matchers[] = {
381 MatcherCast<const Element&>(e1_),
382 MatcherCast<const Element&>(e2_),
383 MatcherCast<const Element&>(e3_),
384 };
385
386 return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 3));
387 }
388
389 private:
390 const T1& e1_;
391 const T2& e2_;
392 const T3& e3_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000393
394 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher3);
shiqiane35fdd92008-12-10 05:08:54 +0000395};
396
397template <typename T1, typename T2, typename T3, typename T4>
398class ElementsAreMatcher4 {
399 public:
400 ElementsAreMatcher4(const T1& e1, const T2& e2, const T3& e3,
401 const T4& e4) : e1_(e1), e2_(e2), e3_(e3), e4_(e4) {}
402
403 template <typename Container>
404 operator Matcher<Container>() const {
zhanyong.wane0d051e2009-02-19 00:33:37 +0000405 typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
406 RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000407 typedef typename internal::StlContainerView<RawContainer>::type::value_type
408 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000409
410 const Matcher<const Element&> matchers[] = {
411 MatcherCast<const Element&>(e1_),
412 MatcherCast<const Element&>(e2_),
413 MatcherCast<const Element&>(e3_),
414 MatcherCast<const Element&>(e4_),
415 };
416
417 return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 4));
418 }
419
420 private:
421 const T1& e1_;
422 const T2& e2_;
423 const T3& e3_;
424 const T4& e4_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000425
426 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher4);
shiqiane35fdd92008-12-10 05:08:54 +0000427};
428
429template <typename T1, typename T2, typename T3, typename T4, typename T5>
430class ElementsAreMatcher5 {
431 public:
432 ElementsAreMatcher5(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
433 const T5& e5) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5) {}
434
435 template <typename Container>
436 operator Matcher<Container>() const {
zhanyong.wane0d051e2009-02-19 00:33:37 +0000437 typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
438 RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000439 typedef typename internal::StlContainerView<RawContainer>::type::value_type
440 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000441
442 const Matcher<const Element&> matchers[] = {
443 MatcherCast<const Element&>(e1_),
444 MatcherCast<const Element&>(e2_),
445 MatcherCast<const Element&>(e3_),
446 MatcherCast<const Element&>(e4_),
447 MatcherCast<const Element&>(e5_),
448 };
449
450 return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 5));
451 }
452
453 private:
454 const T1& e1_;
455 const T2& e2_;
456 const T3& e3_;
457 const T4& e4_;
458 const T5& e5_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000459
460 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher5);
shiqiane35fdd92008-12-10 05:08:54 +0000461};
462
463template <typename T1, typename T2, typename T3, typename T4, typename T5,
464 typename T6>
465class ElementsAreMatcher6 {
466 public:
467 ElementsAreMatcher6(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
468 const T5& e5, const T6& e6) : e1_(e1), e2_(e2), e3_(e3), e4_(e4),
469 e5_(e5), e6_(e6) {}
470
471 template <typename Container>
472 operator Matcher<Container>() const {
zhanyong.wane0d051e2009-02-19 00:33:37 +0000473 typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
474 RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000475 typedef typename internal::StlContainerView<RawContainer>::type::value_type
476 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000477
478 const Matcher<const Element&> matchers[] = {
479 MatcherCast<const Element&>(e1_),
480 MatcherCast<const Element&>(e2_),
481 MatcherCast<const Element&>(e3_),
482 MatcherCast<const Element&>(e4_),
483 MatcherCast<const Element&>(e5_),
484 MatcherCast<const Element&>(e6_),
485 };
486
487 return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 6));
488 }
489
490 private:
491 const T1& e1_;
492 const T2& e2_;
493 const T3& e3_;
494 const T4& e4_;
495 const T5& e5_;
496 const T6& e6_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000497
498 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher6);
shiqiane35fdd92008-12-10 05:08:54 +0000499};
500
501template <typename T1, typename T2, typename T3, typename T4, typename T5,
502 typename T6, typename T7>
503class ElementsAreMatcher7 {
504 public:
505 ElementsAreMatcher7(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
506 const T5& e5, const T6& e6, const T7& e7) : e1_(e1), e2_(e2), e3_(e3),
507 e4_(e4), e5_(e5), e6_(e6), e7_(e7) {}
508
509 template <typename Container>
510 operator Matcher<Container>() const {
zhanyong.wane0d051e2009-02-19 00:33:37 +0000511 typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
512 RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000513 typedef typename internal::StlContainerView<RawContainer>::type::value_type
514 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000515
516 const Matcher<const Element&> matchers[] = {
517 MatcherCast<const Element&>(e1_),
518 MatcherCast<const Element&>(e2_),
519 MatcherCast<const Element&>(e3_),
520 MatcherCast<const Element&>(e4_),
521 MatcherCast<const Element&>(e5_),
522 MatcherCast<const Element&>(e6_),
523 MatcherCast<const Element&>(e7_),
524 };
525
526 return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 7));
527 }
528
529 private:
530 const T1& e1_;
531 const T2& e2_;
532 const T3& e3_;
533 const T4& e4_;
534 const T5& e5_;
535 const T6& e6_;
536 const T7& e7_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000537
538 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher7);
shiqiane35fdd92008-12-10 05:08:54 +0000539};
540
541template <typename T1, typename T2, typename T3, typename T4, typename T5,
542 typename T6, typename T7, typename T8>
543class ElementsAreMatcher8 {
544 public:
545 ElementsAreMatcher8(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
546 const T5& e5, const T6& e6, const T7& e7, const T8& e8) : e1_(e1),
547 e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6), e7_(e7), e8_(e8) {}
548
549 template <typename Container>
550 operator Matcher<Container>() const {
zhanyong.wane0d051e2009-02-19 00:33:37 +0000551 typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
552 RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000553 typedef typename internal::StlContainerView<RawContainer>::type::value_type
554 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000555
556 const Matcher<const Element&> matchers[] = {
557 MatcherCast<const Element&>(e1_),
558 MatcherCast<const Element&>(e2_),
559 MatcherCast<const Element&>(e3_),
560 MatcherCast<const Element&>(e4_),
561 MatcherCast<const Element&>(e5_),
562 MatcherCast<const Element&>(e6_),
563 MatcherCast<const Element&>(e7_),
564 MatcherCast<const Element&>(e8_),
565 };
566
567 return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 8));
568 }
569
570 private:
571 const T1& e1_;
572 const T2& e2_;
573 const T3& e3_;
574 const T4& e4_;
575 const T5& e5_;
576 const T6& e6_;
577 const T7& e7_;
578 const T8& e8_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000579
580 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher8);
shiqiane35fdd92008-12-10 05:08:54 +0000581};
582
583template <typename T1, typename T2, typename T3, typename T4, typename T5,
584 typename T6, typename T7, typename T8, typename T9>
585class ElementsAreMatcher9 {
586 public:
587 ElementsAreMatcher9(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
588 const T5& e5, const T6& e6, const T7& e7, const T8& e8,
589 const T9& e9) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6),
590 e7_(e7), e8_(e8), e9_(e9) {}
591
592 template <typename Container>
593 operator Matcher<Container>() const {
zhanyong.wane0d051e2009-02-19 00:33:37 +0000594 typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
595 RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000596 typedef typename internal::StlContainerView<RawContainer>::type::value_type
597 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000598
599 const Matcher<const Element&> matchers[] = {
600 MatcherCast<const Element&>(e1_),
601 MatcherCast<const Element&>(e2_),
602 MatcherCast<const Element&>(e3_),
603 MatcherCast<const Element&>(e4_),
604 MatcherCast<const Element&>(e5_),
605 MatcherCast<const Element&>(e6_),
606 MatcherCast<const Element&>(e7_),
607 MatcherCast<const Element&>(e8_),
608 MatcherCast<const Element&>(e9_),
609 };
610
611 return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 9));
612 }
613
614 private:
615 const T1& e1_;
616 const T2& e2_;
617 const T3& e3_;
618 const T4& e4_;
619 const T5& e5_;
620 const T6& e6_;
621 const T7& e7_;
622 const T8& e8_;
623 const T9& e9_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000624
625 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher9);
shiqiane35fdd92008-12-10 05:08:54 +0000626};
627
628template <typename T1, typename T2, typename T3, typename T4, typename T5,
629 typename T6, typename T7, typename T8, typename T9, typename T10>
630class ElementsAreMatcher10 {
631 public:
632 ElementsAreMatcher10(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
633 const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,
634 const T10& e10) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6),
635 e7_(e7), e8_(e8), e9_(e9), e10_(e10) {}
636
637 template <typename Container>
638 operator Matcher<Container>() const {
zhanyong.wane0d051e2009-02-19 00:33:37 +0000639 typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
640 RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000641 typedef typename internal::StlContainerView<RawContainer>::type::value_type
642 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000643
644 const Matcher<const Element&> matchers[] = {
645 MatcherCast<const Element&>(e1_),
646 MatcherCast<const Element&>(e2_),
647 MatcherCast<const Element&>(e3_),
648 MatcherCast<const Element&>(e4_),
649 MatcherCast<const Element&>(e5_),
650 MatcherCast<const Element&>(e6_),
651 MatcherCast<const Element&>(e7_),
652 MatcherCast<const Element&>(e8_),
653 MatcherCast<const Element&>(e9_),
654 MatcherCast<const Element&>(e10_),
655 };
656
657 return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 10));
658 }
659
660 private:
661 const T1& e1_;
662 const T2& e2_;
663 const T3& e3_;
664 const T4& e4_;
665 const T5& e5_;
666 const T6& e6_;
667 const T7& e7_;
668 const T8& e8_;
669 const T9& e9_;
670 const T10& e10_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000671
672 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher10);
shiqiane35fdd92008-12-10 05:08:54 +0000673};
674
shiqiane35fdd92008-12-10 05:08:54 +0000675} // namespace internal
676
zhanyong.wan2661c682009-06-09 05:42:12 +0000677// Args<N1, N2, ..., Nk>(a_matcher) matches a tuple if the selected
678// fields of it matches a_matcher. C++ doesn't support default
679// arguments for function templates, so we have to overload it.
680template <typename InnerMatcher>
681inline internal::ArgsMatcher<InnerMatcher>
682Args(const InnerMatcher& matcher) {
683 return internal::ArgsMatcher<InnerMatcher>(matcher);
684}
685
686template <int k1, typename InnerMatcher>
687inline internal::ArgsMatcher<InnerMatcher, k1>
688Args(const InnerMatcher& matcher) {
689 return internal::ArgsMatcher<InnerMatcher, k1>(matcher);
690}
691
692template <int k1, int k2, typename InnerMatcher>
693inline internal::ArgsMatcher<InnerMatcher, k1, k2>
694Args(const InnerMatcher& matcher) {
695 return internal::ArgsMatcher<InnerMatcher, k1, k2>(matcher);
696}
697
698template <int k1, int k2, int k3, typename InnerMatcher>
699inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3>
700Args(const InnerMatcher& matcher) {
701 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3>(matcher);
702}
703
704template <int k1, int k2, int k3, int k4, typename InnerMatcher>
705inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>
706Args(const InnerMatcher& matcher) {
707 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>(matcher);
708}
709
710template <int k1, int k2, int k3, int k4, int k5, typename InnerMatcher>
711inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>
712Args(const InnerMatcher& matcher) {
713 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>(matcher);
714}
715
716template <int k1, int k2, int k3, int k4, int k5, int k6, typename InnerMatcher>
717inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>
718Args(const InnerMatcher& matcher) {
719 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>(matcher);
720}
721
722template <int k1, int k2, int k3, int k4, int k5, int k6, int k7,
723 typename InnerMatcher>
724inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7>
725Args(const InnerMatcher& matcher) {
726 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6,
727 k7>(matcher);
728}
729
730template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
731 typename InnerMatcher>
732inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8>
733Args(const InnerMatcher& matcher) {
734 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7,
735 k8>(matcher);
736}
737
738template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
739 int k9, typename InnerMatcher>
740inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9>
741Args(const InnerMatcher& matcher) {
742 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
743 k9>(matcher);
744}
745
746template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
747 int k9, int k10, typename InnerMatcher>
748inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9,
749 k10>
750Args(const InnerMatcher& matcher) {
751 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
752 k9, k10>(matcher);
753}
754
shiqiane35fdd92008-12-10 05:08:54 +0000755// ElementsAre(e0, e1, ..., e_n) matches an STL-style container with
756// (n + 1) elements, where the i-th element in the container must
757// match the i-th argument in the list. Each argument of
758// ElementsAre() can be either a value or a matcher. We support up to
759// 10 arguments.
760//
761// NOTE: Since ElementsAre() cares about the order of the elements, it
762// must not be used with containers whose elements's order is
763// undefined (e.g. hash_map).
764
765inline internal::ElementsAreMatcher0 ElementsAre() {
766 return internal::ElementsAreMatcher0();
767}
768
769template <typename T1>
770inline internal::ElementsAreMatcher1<T1> ElementsAre(const T1& e1) {
771 return internal::ElementsAreMatcher1<T1>(e1);
772}
773
774template <typename T1, typename T2>
775inline internal::ElementsAreMatcher2<T1, T2> ElementsAre(const T1& e1,
776 const T2& e2) {
777 return internal::ElementsAreMatcher2<T1, T2>(e1, e2);
778}
779
780template <typename T1, typename T2, typename T3>
781inline internal::ElementsAreMatcher3<T1, T2, T3> ElementsAre(const T1& e1,
782 const T2& e2, const T3& e3) {
783 return internal::ElementsAreMatcher3<T1, T2, T3>(e1, e2, e3);
784}
785
786template <typename T1, typename T2, typename T3, typename T4>
787inline internal::ElementsAreMatcher4<T1, T2, T3, T4> ElementsAre(const T1& e1,
788 const T2& e2, const T3& e3, const T4& e4) {
789 return internal::ElementsAreMatcher4<T1, T2, T3, T4>(e1, e2, e3, e4);
790}
791
792template <typename T1, typename T2, typename T3, typename T4, typename T5>
793inline internal::ElementsAreMatcher5<T1, T2, T3, T4,
794 T5> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
795 const T5& e5) {
796 return internal::ElementsAreMatcher5<T1, T2, T3, T4, T5>(e1, e2, e3, e4, e5);
797}
798
799template <typename T1, typename T2, typename T3, typename T4, typename T5,
800 typename T6>
801inline internal::ElementsAreMatcher6<T1, T2, T3, T4, T5,
802 T6> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
803 const T5& e5, const T6& e6) {
804 return internal::ElementsAreMatcher6<T1, T2, T3, T4, T5, T6>(e1, e2, e3, e4,
805 e5, e6);
806}
807
808template <typename T1, typename T2, typename T3, typename T4, typename T5,
809 typename T6, typename T7>
810inline internal::ElementsAreMatcher7<T1, T2, T3, T4, T5, T6,
811 T7> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
812 const T5& e5, const T6& e6, const T7& e7) {
813 return internal::ElementsAreMatcher7<T1, T2, T3, T4, T5, T6, T7>(e1, e2, e3,
814 e4, e5, e6, e7);
815}
816
817template <typename T1, typename T2, typename T3, typename T4, typename T5,
818 typename T6, typename T7, typename T8>
819inline internal::ElementsAreMatcher8<T1, T2, T3, T4, T5, T6, T7,
820 T8> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
821 const T5& e5, const T6& e6, const T7& e7, const T8& e8) {
822 return internal::ElementsAreMatcher8<T1, T2, T3, T4, T5, T6, T7, T8>(e1, e2,
823 e3, e4, e5, e6, e7, e8);
824}
825
826template <typename T1, typename T2, typename T3, typename T4, typename T5,
827 typename T6, typename T7, typename T8, typename T9>
828inline internal::ElementsAreMatcher9<T1, T2, T3, T4, T5, T6, T7, T8,
829 T9> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
830 const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9) {
831 return internal::ElementsAreMatcher9<T1, T2, T3, T4, T5, T6, T7, T8, T9>(e1,
832 e2, e3, e4, e5, e6, e7, e8, e9);
833}
834
835template <typename T1, typename T2, typename T3, typename T4, typename T5,
836 typename T6, typename T7, typename T8, typename T9, typename T10>
837inline internal::ElementsAreMatcher10<T1, T2, T3, T4, T5, T6, T7, T8, T9,
838 T10> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
839 const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,
840 const T10& e10) {
841 return internal::ElementsAreMatcher10<T1, T2, T3, T4, T5, T6, T7, T8, T9,
842 T10>(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10);
843}
844
845// ElementsAreArray(array) and ElementAreArray(array, count) are like
846// ElementsAre(), except that they take an array of values or
847// matchers. The former form infers the size of 'array', which must
848// be a static C-style array. In the latter form, 'array' can either
849// be a static array or a pointer to a dynamically created array.
850
851template <typename T>
852inline internal::ElementsAreArrayMatcher<T> ElementsAreArray(
853 const T* first, size_t count) {
854 return internal::ElementsAreArrayMatcher<T>(first, count);
855}
856
857template <typename T, size_t N>
858inline internal::ElementsAreArrayMatcher<T>
859ElementsAreArray(const T (&array)[N]) {
860 return internal::ElementsAreArrayMatcher<T>(array, N);
861}
862
863} // namespace testing
864
zhanyong.wance198ff2009-02-12 01:34:27 +0000865// The MATCHER* family of macros can be used in a namespace scope to
zhanyong.wan82113312010-01-08 21:55:40 +0000866// define custom matchers easily.
867//
868// Basic Usage
869// ===========
870//
871// The syntax
zhanyong.wance198ff2009-02-12 01:34:27 +0000872//
873// MATCHER(name, description_string) { statements; }
874//
zhanyong.wan82113312010-01-08 21:55:40 +0000875// defines a matcher with the given name that executes the statements,
876// which must return a bool to indicate if the match succeeds. Inside
877// the statements, you can refer to the value being matched by 'arg',
878// and refer to its type by 'arg_type'.
zhanyong.wan4a5330d2009-02-19 00:36:44 +0000879//
880// The description string documents what the matcher does, and is used
881// to generate the failure message when the match fails. Since a
882// MATCHER() is usually defined in a header file shared by multiple
883// C++ source files, we require the description to be a C-string
884// literal to avoid possible side effects. It can be empty, in which
885// case we'll use the sequence of words in the matcher name as the
886// description.
887//
888// For example:
zhanyong.wance198ff2009-02-12 01:34:27 +0000889//
890// MATCHER(IsEven, "") { return (arg % 2) == 0; }
891//
892// allows you to write
893//
894// // Expects mock_foo.Bar(n) to be called where n is even.
895// EXPECT_CALL(mock_foo, Bar(IsEven()));
896//
897// or,
898//
899// // Verifies that the value of some_expression is even.
900// EXPECT_THAT(some_expression, IsEven());
901//
902// If the above assertion fails, it will print something like:
903//
904// Value of: some_expression
905// Expected: is even
906// Actual: 7
907//
908// where the description "is even" is automatically calculated from the
909// matcher name IsEven.
910//
zhanyong.wan82113312010-01-08 21:55:40 +0000911// Argument Type
912// =============
913//
zhanyong.wance198ff2009-02-12 01:34:27 +0000914// Note that the type of the value being matched (arg_type) is
915// determined by the context in which you use the matcher and is
916// supplied to you by the compiler, so you don't need to worry about
917// declaring it (nor can you). This allows the matcher to be
918// polymorphic. For example, IsEven() can be used to match any type
919// where the value of "(arg % 2) == 0" can be implicitly converted to
920// a bool. In the "Bar(IsEven())" example above, if method Bar()
921// takes an int, 'arg_type' will be int; if it takes an unsigned long,
922// 'arg_type' will be unsigned long; and so on.
923//
zhanyong.wan82113312010-01-08 21:55:40 +0000924// Parameterizing Matchers
925// =======================
926//
zhanyong.wance198ff2009-02-12 01:34:27 +0000927// Sometimes you'll want to parameterize the matcher. For that you
928// can use another macro:
929//
930// MATCHER_P(name, param_name, description_string) { statements; }
931//
932// For example:
933//
934// MATCHER_P(HasAbsoluteValue, value, "") { return abs(arg) == value; }
935//
936// will allow you to write:
937//
938// EXPECT_THAT(Blah("a"), HasAbsoluteValue(n));
939//
940// which may lead to this message (assuming n is 10):
941//
942// Value of: Blah("a")
943// Expected: has absolute value 10
944// Actual: -9
945//
946// Note that both the matcher description and its parameter are
947// printed, making the message human-friendly.
948//
949// In the matcher definition body, you can write 'foo_type' to
950// reference the type of a parameter named 'foo'. For example, in the
951// body of MATCHER_P(HasAbsoluteValue, value) above, you can write
952// 'value_type' to refer to the type of 'value'.
953//
954// We also provide MATCHER_P2, MATCHER_P3, ..., up to MATCHER_P10 to
955// support multi-parameter matchers.
956//
zhanyong.wan82113312010-01-08 21:55:40 +0000957// Describing Parameterized Matchers
958// =================================
959//
zhanyong.wan4a5330d2009-02-19 00:36:44 +0000960// When defining a parameterized matcher, you can use Python-style
961// interpolations in the description string to refer to the parameter
962// values. We support the following syntax currently:
963//
964// %% a single '%' character
965// %(*)s all parameters of the matcher printed as a tuple
966// %(foo)s value of the matcher parameter named 'foo'
967//
968// For example,
969//
970// MATCHER_P2(InClosedRange, low, hi, "is in range [%(low)s, %(hi)s]") {
971// return low <= arg && arg <= hi;
972// }
973// ...
974// EXPECT_THAT(3, InClosedRange(4, 6));
975//
976// would generate a failure that contains the message:
977//
978// Expected: is in range [4, 6]
979//
980// If you specify "" as the description, the failure message will
981// contain the sequence of words in the matcher name followed by the
982// parameter values printed as a tuple. For example,
983//
984// MATCHER_P2(InClosedRange, low, hi, "") { ... }
985// ...
986// EXPECT_THAT(3, InClosedRange(4, 6));
987//
988// would generate a failure that contains the text:
989//
990// Expected: in closed range (4, 6)
991//
zhanyong.wan82113312010-01-08 21:55:40 +0000992// Types of Matcher Parameters
993// ===========================
994//
zhanyong.wance198ff2009-02-12 01:34:27 +0000995// For the purpose of typing, you can view
996//
997// MATCHER_Pk(Foo, p1, ..., pk, description_string) { ... }
998//
999// as shorthand for
1000//
1001// template <typename p1_type, ..., typename pk_type>
1002// FooMatcherPk<p1_type, ..., pk_type>
1003// Foo(p1_type p1, ..., pk_type pk) { ... }
1004//
1005// When you write Foo(v1, ..., vk), the compiler infers the types of
1006// the parameters v1, ..., and vk for you. If you are not happy with
1007// the result of the type inference, you can specify the types by
1008// explicitly instantiating the template, as in Foo<long, bool>(5,
1009// false). As said earlier, you don't get to (or need to) specify
1010// 'arg_type' as that's determined by the context in which the matcher
1011// is used. You can assign the result of expression Foo(p1, ..., pk)
1012// to a variable of type FooMatcherPk<p1_type, ..., pk_type>. This
1013// can be useful when composing matchers.
1014//
1015// While you can instantiate a matcher template with reference types,
1016// passing the parameters by pointer usually makes your code more
1017// readable. If, however, you still want to pass a parameter by
1018// reference, be aware that in the failure message generated by the
1019// matcher you will see the value of the referenced object but not its
1020// address.
1021//
zhanyong.wan82113312010-01-08 21:55:40 +00001022// Explaining Match Results
1023// ========================
1024//
1025// Sometimes the matcher description alone isn't enough to explain why
1026// the match has failed or succeeded. For example, when expecting a
1027// long string, it can be very helpful to also print the diff between
1028// the expected string and the actual one. To achieve that, you can
1029// optionally stream additional information to a special variable
1030// named result_listener, whose type is a pointer to class
1031// MatchResultListener:
1032//
1033// MATCHER_P(EqualsLongString, str, "") {
1034// if (arg == str) return true;
1035//
1036// *result_listener << "the difference: "
1037/// << DiffStrings(str, arg);
1038// return false;
1039// }
1040//
1041// Overloading Matchers
1042// ====================
1043//
zhanyong.wance198ff2009-02-12 01:34:27 +00001044// You can overload matchers with different numbers of parameters:
1045//
1046// MATCHER_P(Blah, a, description_string1) { ... }
1047// MATCHER_P2(Blah, a, b, description_string2) { ... }
1048//
zhanyong.wan82113312010-01-08 21:55:40 +00001049// Caveats
1050// =======
zhanyong.wance198ff2009-02-12 01:34:27 +00001051//
zhanyong.wan82113312010-01-08 21:55:40 +00001052// When defining a new matcher, you should also consider implementing
1053// MatcherInterface or using MakePolymorphicMatcher(). These
1054// approaches require more work than the MATCHER* macros, but also
1055// give you more control on the types of the value being matched and
1056// the matcher parameters, which may leads to better compiler error
1057// messages when the matcher is used wrong. They also allow
1058// overloading matchers based on parameter types (as opposed to just
1059// based on the number of parameters).
zhanyong.wance198ff2009-02-12 01:34:27 +00001060//
1061// MATCHER*() can only be used in a namespace scope. The reason is
1062// that C++ doesn't yet allow function-local types to be used to
1063// instantiate templates. The up-coming C++0x standard will fix this.
1064// Once that's done, we'll consider supporting using MATCHER*() inside
1065// a function.
1066//
zhanyong.wan82113312010-01-08 21:55:40 +00001067// More Information
1068// ================
zhanyong.wance198ff2009-02-12 01:34:27 +00001069//
1070// To learn more about using these macros, please search for 'MATCHER'
1071// on http://code.google.com/p/googlemock/wiki/CookBook.
1072
1073#define MATCHER(name, description)\
1074 class name##Matcher {\
1075 public:\
1076 template <typename arg_type>\
1077 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1078 public:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001079 gmock_Impl(const ::testing::internal::Interpolations& gmock_interp)\
1080 : gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001081 virtual bool MatchAndExplain(\
1082 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001083 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1084 const ::testing::internal::Strings& gmock_printed_params = \
1085 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1086 ::std::tr1::tuple<>());\
1087 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1088 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001089 }\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001090 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001091 private:\
1092 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001093 };\
1094 template <typename arg_type>\
1095 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001096 return ::testing::Matcher<arg_type>(\
1097 new gmock_Impl<arg_type>(gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001098 }\
1099 name##Matcher() {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001100 const char* gmock_param_names[] = { NULL };\
1101 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1102 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001103 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001104 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001105 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001106 GTEST_DISALLOW_ASSIGN_(name##Matcher);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001107 };\
1108 inline name##Matcher name() {\
1109 return name##Matcher();\
1110 }\
1111 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001112 bool name##Matcher::gmock_Impl<arg_type>::MatchAndExplain(\
1113 arg_type arg,\
1114 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1115 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001116
1117#define MATCHER_P(name, p0, description)\
1118 template <typename p0##_type>\
1119 class name##MatcherP {\
1120 public:\
1121 template <typename arg_type>\
1122 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1123 public:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001124 explicit gmock_Impl(p0##_type gmock_p0, \
1125 const ::testing::internal::Interpolations& gmock_interp)\
1126 : p0(gmock_p0), gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001127 virtual bool MatchAndExplain(\
1128 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001129 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1130 const ::testing::internal::Strings& gmock_printed_params = \
1131 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1132 ::std::tr1::tuple<p0##_type>(p0));\
1133 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1134 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001135 }\
1136 p0##_type p0;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001137 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001138 private:\
1139 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001140 };\
1141 template <typename arg_type>\
1142 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001143 return ::testing::Matcher<arg_type>(\
1144 new gmock_Impl<arg_type>(p0, gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001145 }\
1146 name##MatcherP(p0##_type gmock_p0) : p0(gmock_p0) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001147 const char* gmock_param_names[] = { #p0, NULL };\
1148 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1149 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001150 }\
1151 p0##_type p0;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001152 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001153 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001154 GTEST_DISALLOW_ASSIGN_(name##MatcherP);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001155 };\
1156 template <typename p0##_type>\
1157 inline name##MatcherP<p0##_type> name(p0##_type p0) {\
1158 return name##MatcherP<p0##_type>(p0);\
1159 }\
1160 template <typename p0##_type>\
1161 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001162 bool name##MatcherP<p0##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1163 arg_type arg,\
1164 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1165 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001166
1167#define MATCHER_P2(name, p0, p1, description)\
1168 template <typename p0##_type, typename p1##_type>\
1169 class name##MatcherP2 {\
1170 public:\
1171 template <typename arg_type>\
1172 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1173 public:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001174 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, \
1175 const ::testing::internal::Interpolations& gmock_interp)\
1176 : p0(gmock_p0), p1(gmock_p1), gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001177 virtual bool MatchAndExplain(\
1178 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001179 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1180 const ::testing::internal::Strings& gmock_printed_params = \
1181 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1182 ::std::tr1::tuple<p0##_type, p1##_type>(p0, p1));\
1183 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1184 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001185 }\
1186 p0##_type p0;\
1187 p1##_type p1;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001188 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001189 private:\
1190 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001191 };\
1192 template <typename arg_type>\
1193 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001194 return ::testing::Matcher<arg_type>(\
1195 new gmock_Impl<arg_type>(p0, p1, gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001196 }\
1197 name##MatcherP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
1198 p1(gmock_p1) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001199 const char* gmock_param_names[] = { #p0, #p1, NULL };\
1200 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1201 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001202 }\
1203 p0##_type p0;\
1204 p1##_type p1;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001205 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001206 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001207 GTEST_DISALLOW_ASSIGN_(name##MatcherP2);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001208 };\
1209 template <typename p0##_type, typename p1##_type>\
1210 inline name##MatcherP2<p0##_type, p1##_type> name(p0##_type p0, \
1211 p1##_type p1) {\
1212 return name##MatcherP2<p0##_type, p1##_type>(p0, p1);\
1213 }\
1214 template <typename p0##_type, typename p1##_type>\
1215 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001216 bool name##MatcherP2<p0##_type, \
1217 p1##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1218 arg_type arg,\
1219 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1220 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001221
1222#define MATCHER_P3(name, p0, p1, p2, description)\
1223 template <typename p0##_type, typename p1##_type, typename p2##_type>\
1224 class name##MatcherP3 {\
1225 public:\
1226 template <typename arg_type>\
1227 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1228 public:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001229 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1230 const ::testing::internal::Interpolations& gmock_interp)\
1231 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1232 gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001233 virtual bool MatchAndExplain(\
1234 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001235 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1236 const ::testing::internal::Strings& gmock_printed_params = \
1237 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1238 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type>(p0, p1, \
1239 p2));\
1240 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1241 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001242 }\
1243 p0##_type p0;\
1244 p1##_type p1;\
1245 p2##_type p2;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001246 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001247 private:\
1248 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001249 };\
1250 template <typename arg_type>\
1251 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001252 return ::testing::Matcher<arg_type>(\
1253 new gmock_Impl<arg_type>(p0, p1, p2, gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001254 }\
1255 name##MatcherP3(p0##_type gmock_p0, p1##_type gmock_p1, \
1256 p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001257 const char* gmock_param_names[] = { #p0, #p1, #p2, NULL };\
1258 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1259 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001260 }\
1261 p0##_type p0;\
1262 p1##_type p1;\
1263 p2##_type p2;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001264 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001265 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001266 GTEST_DISALLOW_ASSIGN_(name##MatcherP3);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001267 };\
1268 template <typename p0##_type, typename p1##_type, typename p2##_type>\
1269 inline name##MatcherP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0, \
1270 p1##_type p1, p2##_type p2) {\
1271 return name##MatcherP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\
1272 }\
1273 template <typename p0##_type, typename p1##_type, typename p2##_type>\
1274 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001275 bool name##MatcherP3<p0##_type, p1##_type, \
1276 p2##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1277 arg_type arg,\
1278 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1279 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001280
1281#define MATCHER_P4(name, p0, p1, p2, p3, description)\
1282 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1283 typename p3##_type>\
1284 class name##MatcherP4 {\
1285 public:\
1286 template <typename arg_type>\
1287 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1288 public:\
1289 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001290 p3##_type gmock_p3, \
1291 const ::testing::internal::Interpolations& gmock_interp)\
1292 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1293 gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001294 virtual bool MatchAndExplain(\
1295 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001296 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1297 const ::testing::internal::Strings& gmock_printed_params = \
1298 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1299 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, \
1300 p3##_type>(p0, p1, p2, p3));\
1301 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1302 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001303 }\
1304 p0##_type p0;\
1305 p1##_type p1;\
1306 p2##_type p2;\
1307 p3##_type p3;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001308 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001309 private:\
1310 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001311 };\
1312 template <typename arg_type>\
1313 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001314 return ::testing::Matcher<arg_type>(\
1315 new gmock_Impl<arg_type>(p0, p1, p2, p3, gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001316 }\
1317 name##MatcherP4(p0##_type gmock_p0, p1##_type gmock_p1, \
1318 p2##_type gmock_p2, p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), \
1319 p2(gmock_p2), p3(gmock_p3) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001320 const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, NULL };\
1321 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1322 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001323 }\
1324 p0##_type p0;\
1325 p1##_type p1;\
1326 p2##_type p2;\
1327 p3##_type p3;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001328 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001329 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001330 GTEST_DISALLOW_ASSIGN_(name##MatcherP4);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001331 };\
1332 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1333 typename p3##_type>\
1334 inline name##MatcherP4<p0##_type, p1##_type, p2##_type, \
1335 p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
1336 p3##_type p3) {\
1337 return name##MatcherP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, \
1338 p1, p2, p3);\
1339 }\
1340 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1341 typename p3##_type>\
1342 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001343 bool name##MatcherP4<p0##_type, p1##_type, p2##_type, \
1344 p3##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1345 arg_type arg,\
1346 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1347 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001348
1349#define MATCHER_P5(name, p0, p1, p2, p3, p4, description)\
1350 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1351 typename p3##_type, typename p4##_type>\
1352 class name##MatcherP5 {\
1353 public:\
1354 template <typename arg_type>\
1355 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1356 public:\
1357 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001358 p3##_type gmock_p3, p4##_type gmock_p4, \
1359 const ::testing::internal::Interpolations& gmock_interp)\
1360 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1361 p4(gmock_p4), gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001362 virtual bool MatchAndExplain(\
1363 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001364 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1365 const ::testing::internal::Strings& gmock_printed_params = \
1366 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1367 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1368 p4##_type>(p0, p1, p2, p3, p4));\
1369 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1370 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001371 }\
1372 p0##_type p0;\
1373 p1##_type p1;\
1374 p2##_type p2;\
1375 p3##_type p3;\
1376 p4##_type p4;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001377 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001378 private:\
1379 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001380 };\
1381 template <typename arg_type>\
1382 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001383 return ::testing::Matcher<arg_type>(\
1384 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001385 }\
1386 name##MatcherP5(p0##_type gmock_p0, p1##_type gmock_p1, \
1387 p2##_type gmock_p2, p3##_type gmock_p3, \
1388 p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1389 p3(gmock_p3), p4(gmock_p4) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001390 const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, NULL };\
1391 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1392 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001393 }\
1394 p0##_type p0;\
1395 p1##_type p1;\
1396 p2##_type p2;\
1397 p3##_type p3;\
1398 p4##_type p4;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001399 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001400 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001401 GTEST_DISALLOW_ASSIGN_(name##MatcherP5);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001402 };\
1403 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1404 typename p3##_type, typename p4##_type>\
1405 inline name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1406 p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
1407 p4##_type p4) {\
1408 return name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1409 p4##_type>(p0, p1, p2, p3, p4);\
1410 }\
1411 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1412 typename p3##_type, typename p4##_type>\
1413 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001414 bool name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1415 p4##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1416 arg_type arg,\
1417 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1418 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001419
1420#define MATCHER_P6(name, p0, p1, p2, p3, p4, p5, description)\
1421 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1422 typename p3##_type, typename p4##_type, typename p5##_type>\
1423 class name##MatcherP6 {\
1424 public:\
1425 template <typename arg_type>\
1426 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1427 public:\
1428 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001429 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
1430 const ::testing::internal::Interpolations& gmock_interp)\
1431 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1432 p4(gmock_p4), p5(gmock_p5), gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001433 virtual bool MatchAndExplain(\
1434 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001435 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1436 const ::testing::internal::Strings& gmock_printed_params = \
1437 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1438 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1439 p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5));\
1440 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1441 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001442 }\
1443 p0##_type p0;\
1444 p1##_type p1;\
1445 p2##_type p2;\
1446 p3##_type p3;\
1447 p4##_type p4;\
1448 p5##_type p5;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001449 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001450 private:\
1451 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001452 };\
1453 template <typename arg_type>\
1454 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001455 return ::testing::Matcher<arg_type>(\
1456 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001457 }\
1458 name##MatcherP6(p0##_type gmock_p0, p1##_type gmock_p1, \
1459 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1460 p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1461 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001462 const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, #p5, NULL };\
1463 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1464 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001465 }\
1466 p0##_type p0;\
1467 p1##_type p1;\
1468 p2##_type p2;\
1469 p3##_type p3;\
1470 p4##_type p4;\
1471 p5##_type p5;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001472 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001473 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001474 GTEST_DISALLOW_ASSIGN_(name##MatcherP6);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001475 };\
1476 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1477 typename p3##_type, typename p4##_type, typename p5##_type>\
1478 inline name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
1479 p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
1480 p3##_type p3, p4##_type p4, p5##_type p5) {\
1481 return name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
1482 p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\
1483 }\
1484 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1485 typename p3##_type, typename p4##_type, typename p5##_type>\
1486 template <typename arg_type>\
1487 bool name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00001488 p5##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1489 arg_type arg,\
1490 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1491 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001492
1493#define MATCHER_P7(name, p0, p1, p2, p3, p4, p5, p6, description)\
1494 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1495 typename p3##_type, typename p4##_type, typename p5##_type, \
1496 typename p6##_type>\
1497 class name##MatcherP7 {\
1498 public:\
1499 template <typename arg_type>\
1500 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1501 public:\
1502 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1503 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001504 p6##_type gmock_p6, \
1505 const ::testing::internal::Interpolations& gmock_interp)\
1506 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1507 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
1508 gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001509 virtual bool MatchAndExplain(\
1510 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001511 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1512 const ::testing::internal::Strings& gmock_printed_params = \
1513 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1514 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1515 p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, \
1516 p6));\
1517 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1518 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001519 }\
1520 p0##_type p0;\
1521 p1##_type p1;\
1522 p2##_type p2;\
1523 p3##_type p3;\
1524 p4##_type p4;\
1525 p5##_type p5;\
1526 p6##_type p6;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001527 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001528 private:\
1529 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001530 };\
1531 template <typename arg_type>\
1532 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001533 return ::testing::Matcher<arg_type>(\
1534 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001535 }\
1536 name##MatcherP7(p0##_type gmock_p0, p1##_type gmock_p1, \
1537 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1538 p5##_type gmock_p5, p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), \
1539 p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), \
1540 p6(gmock_p6) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001541 const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, #p5, #p6, \
1542 NULL };\
1543 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1544 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001545 }\
1546 p0##_type p0;\
1547 p1##_type p1;\
1548 p2##_type p2;\
1549 p3##_type p3;\
1550 p4##_type p4;\
1551 p5##_type p5;\
1552 p6##_type p6;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001553 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001554 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001555 GTEST_DISALLOW_ASSIGN_(name##MatcherP7);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001556 };\
1557 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1558 typename p3##_type, typename p4##_type, typename p5##_type, \
1559 typename p6##_type>\
1560 inline name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
1561 p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \
1562 p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
1563 p6##_type p6) {\
1564 return name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
1565 p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\
1566 }\
1567 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1568 typename p3##_type, typename p4##_type, typename p5##_type, \
1569 typename p6##_type>\
1570 template <typename arg_type>\
1571 bool name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00001572 p5##_type, p6##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1573 arg_type arg,\
1574 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1575 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001576
1577#define MATCHER_P8(name, p0, p1, p2, p3, p4, p5, p6, p7, description)\
1578 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1579 typename p3##_type, typename p4##_type, typename p5##_type, \
1580 typename p6##_type, typename p7##_type>\
1581 class name##MatcherP8 {\
1582 public:\
1583 template <typename arg_type>\
1584 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1585 public:\
1586 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1587 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001588 p6##_type gmock_p6, p7##_type gmock_p7, \
1589 const ::testing::internal::Interpolations& gmock_interp)\
1590 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1591 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
1592 gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001593 virtual bool MatchAndExplain(\
1594 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001595 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1596 const ::testing::internal::Strings& gmock_printed_params = \
1597 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1598 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1599 p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, \
1600 p3, p4, p5, p6, p7));\
1601 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1602 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001603 }\
1604 p0##_type p0;\
1605 p1##_type p1;\
1606 p2##_type p2;\
1607 p3##_type p3;\
1608 p4##_type p4;\
1609 p5##_type p5;\
1610 p6##_type p6;\
1611 p7##_type p7;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001612 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001613 private:\
1614 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001615 };\
1616 template <typename arg_type>\
1617 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001618 return ::testing::Matcher<arg_type>(\
1619 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, \
1620 gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001621 }\
1622 name##MatcherP8(p0##_type gmock_p0, p1##_type gmock_p1, \
1623 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1624 p5##_type gmock_p5, p6##_type gmock_p6, \
1625 p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1626 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
1627 p7(gmock_p7) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001628 const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, #p5, #p6, \
1629 #p7, NULL };\
1630 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1631 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001632 }\
1633 p0##_type p0;\
1634 p1##_type p1;\
1635 p2##_type p2;\
1636 p3##_type p3;\
1637 p4##_type p4;\
1638 p5##_type p5;\
1639 p6##_type p6;\
1640 p7##_type p7;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001641 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001642 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001643 GTEST_DISALLOW_ASSIGN_(name##MatcherP8);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001644 };\
1645 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1646 typename p3##_type, typename p4##_type, typename p5##_type, \
1647 typename p6##_type, typename p7##_type>\
1648 inline name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
1649 p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \
1650 p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
1651 p6##_type p6, p7##_type p7) {\
1652 return name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
1653 p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5, \
1654 p6, p7);\
1655 }\
1656 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1657 typename p3##_type, typename p4##_type, typename p5##_type, \
1658 typename p6##_type, typename p7##_type>\
1659 template <typename arg_type>\
1660 bool name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00001661 p5##_type, p6##_type, \
1662 p7##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1663 arg_type arg,\
1664 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1665 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001666
1667#define MATCHER_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, description)\
1668 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1669 typename p3##_type, typename p4##_type, typename p5##_type, \
1670 typename p6##_type, typename p7##_type, typename p8##_type>\
1671 class name##MatcherP9 {\
1672 public:\
1673 template <typename arg_type>\
1674 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1675 public:\
1676 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1677 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001678 p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
1679 const ::testing::internal::Interpolations& gmock_interp)\
1680 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1681 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
1682 p8(gmock_p8), gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001683 virtual bool MatchAndExplain(\
1684 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001685 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1686 const ::testing::internal::Strings& gmock_printed_params = \
1687 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1688 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1689 p4##_type, p5##_type, p6##_type, p7##_type, \
1690 p8##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8));\
1691 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1692 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001693 }\
1694 p0##_type p0;\
1695 p1##_type p1;\
1696 p2##_type p2;\
1697 p3##_type p3;\
1698 p4##_type p4;\
1699 p5##_type p5;\
1700 p6##_type p6;\
1701 p7##_type p7;\
1702 p8##_type p8;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001703 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001704 private:\
1705 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001706 };\
1707 template <typename arg_type>\
1708 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001709 return ::testing::Matcher<arg_type>(\
1710 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, \
1711 gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001712 }\
1713 name##MatcherP9(p0##_type gmock_p0, p1##_type gmock_p1, \
1714 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1715 p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
1716 p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1717 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
1718 p8(gmock_p8) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001719 const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, #p5, #p6, \
1720 #p7, #p8, NULL };\
1721 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1722 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001723 }\
1724 p0##_type p0;\
1725 p1##_type p1;\
1726 p2##_type p2;\
1727 p3##_type p3;\
1728 p4##_type p4;\
1729 p5##_type p5;\
1730 p6##_type p6;\
1731 p7##_type p7;\
1732 p8##_type p8;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001733 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001734 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001735 GTEST_DISALLOW_ASSIGN_(name##MatcherP9);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001736 };\
1737 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1738 typename p3##_type, typename p4##_type, typename p5##_type, \
1739 typename p6##_type, typename p7##_type, typename p8##_type>\
1740 inline name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \
1741 p4##_type, p5##_type, p6##_type, p7##_type, \
1742 p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
1743 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \
1744 p8##_type p8) {\
1745 return name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \
1746 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type>(p0, p1, p2, \
1747 p3, p4, p5, p6, p7, p8);\
1748 }\
1749 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1750 typename p3##_type, typename p4##_type, typename p5##_type, \
1751 typename p6##_type, typename p7##_type, typename p8##_type>\
1752 template <typename arg_type>\
1753 bool name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00001754 p5##_type, p6##_type, p7##_type, \
1755 p8##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1756 arg_type arg,\
1757 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1758 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001759
1760#define MATCHER_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, description)\
1761 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1762 typename p3##_type, typename p4##_type, typename p5##_type, \
1763 typename p6##_type, typename p7##_type, typename p8##_type, \
1764 typename p9##_type>\
1765 class name##MatcherP10 {\
1766 public:\
1767 template <typename arg_type>\
1768 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1769 public:\
1770 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1771 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
1772 p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001773 p9##_type gmock_p9, \
1774 const ::testing::internal::Interpolations& gmock_interp)\
1775 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1776 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
1777 p8(gmock_p8), p9(gmock_p9), gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001778 virtual bool MatchAndExplain(\
1779 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001780 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1781 const ::testing::internal::Strings& gmock_printed_params = \
1782 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1783 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1784 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
1785 p9##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9));\
1786 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1787 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001788 }\
1789 p0##_type p0;\
1790 p1##_type p1;\
1791 p2##_type p2;\
1792 p3##_type p3;\
1793 p4##_type p4;\
1794 p5##_type p5;\
1795 p6##_type p6;\
1796 p7##_type p7;\
1797 p8##_type p8;\
1798 p9##_type p9;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001799 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001800 private:\
1801 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001802 };\
1803 template <typename arg_type>\
1804 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001805 return ::testing::Matcher<arg_type>(\
1806 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, \
1807 gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001808 }\
1809 name##MatcherP10(p0##_type gmock_p0, p1##_type gmock_p1, \
1810 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1811 p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
1812 p8##_type gmock_p8, p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), \
1813 p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
1814 p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001815 const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, #p5, #p6, \
1816 #p7, #p8, #p9, NULL };\
1817 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1818 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001819 }\
1820 p0##_type p0;\
1821 p1##_type p1;\
1822 p2##_type p2;\
1823 p3##_type p3;\
1824 p4##_type p4;\
1825 p5##_type p5;\
1826 p6##_type p6;\
1827 p7##_type p7;\
1828 p8##_type p8;\
1829 p9##_type p9;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001830 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001831 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001832 GTEST_DISALLOW_ASSIGN_(name##MatcherP10);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001833 };\
1834 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1835 typename p3##_type, typename p4##_type, typename p5##_type, \
1836 typename p6##_type, typename p7##_type, typename p8##_type, \
1837 typename p9##_type>\
1838 inline name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
1839 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
1840 p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
1841 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
1842 p9##_type p9) {\
1843 return name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
1844 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>(p0, \
1845 p1, p2, p3, p4, p5, p6, p7, p8, p9);\
1846 }\
1847 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1848 typename p3##_type, typename p4##_type, typename p5##_type, \
1849 typename p6##_type, typename p7##_type, typename p8##_type, \
1850 typename p9##_type>\
1851 template <typename arg_type>\
1852 bool name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00001853 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
1854 p9##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1855 arg_type arg,\
1856 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1857 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001858
shiqiane35fdd92008-12-10 05:08:54 +00001859#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_