blob: 2790e06cf6be80b8cc0a38faed13911c38c6d690 [file] [log] [blame]
zhanyong.wanb1c7f932010-03-24 17:35:11 +00001// This file was GENERATED by command:
2// pump.py gmock-generated-matchers.h.pump
3// DO NOT EDIT BY HAND!!!
shiqiane35fdd92008-12-10 05:08:54 +00004
5// Copyright 2008, Google Inc.
6// All rights reserved.
7//
8// Redistribution and use in source and binary forms, with or without
9// modification, are permitted provided that the following conditions are
10// met:
11//
12// * Redistributions of source code must retain the above copyright
13// notice, this list of conditions and the following disclaimer.
14// * Redistributions in binary form must reproduce the above
15// copyright notice, this list of conditions and the following disclaimer
16// in the documentation and/or other materials provided with the
17// distribution.
18// * Neither the name of Google Inc. nor the names of its
19// contributors may be used to endorse or promote products derived from
20// this software without specific prior written permission.
21//
22// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
34// Google Mock - a framework for writing C++ mock classes.
35//
36// This file implements some commonly used variadic matchers.
37
38#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
39#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
40
41#include <sstream>
42#include <string>
43#include <vector>
44#include <gmock/gmock-matchers.h>
45
46namespace testing {
47namespace internal {
48
zhanyong.wan2661c682009-06-09 05:42:12 +000049// The type of the i-th (0-based) field of Tuple.
50#define GMOCK_FIELD_TYPE_(Tuple, i) \
51 typename ::std::tr1::tuple_element<i, Tuple>::type
52
53// TupleFields<Tuple, k0, ..., kn> is for selecting fields from a
54// tuple of type Tuple. It has two members:
55//
56// type: a tuple type whose i-th field is the ki-th field of Tuple.
57// GetSelectedFields(t): returns fields k0, ..., and kn of t as a tuple.
58//
59// For example, in class TupleFields<tuple<bool, char, int>, 2, 0>, we have:
60//
61// type is tuple<int, bool>, and
62// GetSelectedFields(make_tuple(true, 'a', 42)) is (42, true).
63
64template <class Tuple, int k0 = -1, int k1 = -1, int k2 = -1, int k3 = -1,
65 int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
66 int k9 = -1>
67class TupleFields;
68
69// This generic version is used when there are 10 selectors.
70template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
71 int k7, int k8, int k9>
72class TupleFields {
73 public:
74 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
75 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
76 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
77 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
78 GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8),
79 GMOCK_FIELD_TYPE_(Tuple, k9)> type;
80 static type GetSelectedFields(const Tuple& t) {
81 using ::std::tr1::get;
82 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
83 get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t), get<k9>(t));
84 }
85};
86
87// The following specialization is used for 0 ~ 9 selectors.
88
89template <class Tuple>
90class TupleFields<Tuple, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
91 public:
92 typedef ::std::tr1::tuple<> type;
zhanyong.wan32de5f52009-12-23 00:13:23 +000093 static type GetSelectedFields(const Tuple& /* t */) {
zhanyong.wan2661c682009-06-09 05:42:12 +000094 using ::std::tr1::get;
95 return type();
96 }
97};
98
99template <class Tuple, int k0>
100class TupleFields<Tuple, k0, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
101 public:
102 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0)> type;
103 static type GetSelectedFields(const Tuple& t) {
104 using ::std::tr1::get;
105 return type(get<k0>(t));
106 }
107};
108
109template <class Tuple, int k0, int k1>
110class TupleFields<Tuple, k0, k1, -1, -1, -1, -1, -1, -1, -1, -1> {
111 public:
112 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
113 GMOCK_FIELD_TYPE_(Tuple, k1)> type;
114 static type GetSelectedFields(const Tuple& t) {
115 using ::std::tr1::get;
116 return type(get<k0>(t), get<k1>(t));
117 }
118};
119
120template <class Tuple, int k0, int k1, int k2>
121class TupleFields<Tuple, k0, k1, k2, -1, -1, -1, -1, -1, -1, -1> {
122 public:
123 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
124 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2)> type;
125 static type GetSelectedFields(const Tuple& t) {
126 using ::std::tr1::get;
127 return type(get<k0>(t), get<k1>(t), get<k2>(t));
128 }
129};
130
131template <class Tuple, int k0, int k1, int k2, int k3>
132class TupleFields<Tuple, k0, k1, k2, k3, -1, -1, -1, -1, -1, -1> {
133 public:
134 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
135 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
136 GMOCK_FIELD_TYPE_(Tuple, k3)> type;
137 static type GetSelectedFields(const Tuple& t) {
138 using ::std::tr1::get;
139 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t));
140 }
141};
142
143template <class Tuple, int k0, int k1, int k2, int k3, int k4>
144class TupleFields<Tuple, k0, k1, k2, k3, k4, -1, -1, -1, -1, -1> {
145 public:
146 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
147 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
148 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4)> type;
149 static type GetSelectedFields(const Tuple& t) {
150 using ::std::tr1::get;
151 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t));
152 }
153};
154
155template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5>
156class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, -1, -1, -1, -1> {
157 public:
158 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
159 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
160 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
161 GMOCK_FIELD_TYPE_(Tuple, k5)> type;
162 static type GetSelectedFields(const Tuple& t) {
163 using ::std::tr1::get;
164 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
165 get<k5>(t));
166 }
167};
168
169template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6>
170class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, -1, -1, -1> {
171 public:
172 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
173 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
174 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
175 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6)> type;
176 static type GetSelectedFields(const Tuple& t) {
177 using ::std::tr1::get;
178 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
179 get<k5>(t), get<k6>(t));
180 }
181};
182
183template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
184 int k7>
185class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, -1, -1> {
186 public:
187 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
188 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
189 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
190 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
191 GMOCK_FIELD_TYPE_(Tuple, k7)> type;
192 static type GetSelectedFields(const Tuple& t) {
193 using ::std::tr1::get;
194 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
195 get<k5>(t), get<k6>(t), get<k7>(t));
196 }
197};
198
199template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
200 int k7, int k8>
201class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, k8, -1> {
202 public:
203 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
204 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
205 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
206 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
207 GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8)> type;
208 static type GetSelectedFields(const Tuple& t) {
209 using ::std::tr1::get;
210 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
211 get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t));
212 }
213};
214
215#undef GMOCK_FIELD_TYPE_
216
217// Implements the Args() matcher.
218template <class ArgsTuple, int k0 = -1, int k1 = -1, int k2 = -1, int k3 = -1,
219 int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
220 int k9 = -1>
221class ArgsMatcherImpl : public MatcherInterface<ArgsTuple> {
222 public:
223 // ArgsTuple may have top-level const or reference modifiers.
zhanyong.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
shiqiane35fdd92008-12-10 05:08:54 +0000664} // namespace internal
665
zhanyong.wan2661c682009-06-09 05:42:12 +0000666// Args<N1, N2, ..., Nk>(a_matcher) matches a tuple if the selected
667// fields of it matches a_matcher. C++ doesn't support default
668// arguments for function templates, so we have to overload it.
669template <typename InnerMatcher>
670inline internal::ArgsMatcher<InnerMatcher>
671Args(const InnerMatcher& matcher) {
672 return internal::ArgsMatcher<InnerMatcher>(matcher);
673}
674
675template <int k1, typename InnerMatcher>
676inline internal::ArgsMatcher<InnerMatcher, k1>
677Args(const InnerMatcher& matcher) {
678 return internal::ArgsMatcher<InnerMatcher, k1>(matcher);
679}
680
681template <int k1, int k2, typename InnerMatcher>
682inline internal::ArgsMatcher<InnerMatcher, k1, k2>
683Args(const InnerMatcher& matcher) {
684 return internal::ArgsMatcher<InnerMatcher, k1, k2>(matcher);
685}
686
687template <int k1, int k2, int k3, typename InnerMatcher>
688inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3>
689Args(const InnerMatcher& matcher) {
690 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3>(matcher);
691}
692
693template <int k1, int k2, int k3, int k4, typename InnerMatcher>
694inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>
695Args(const InnerMatcher& matcher) {
696 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>(matcher);
697}
698
699template <int k1, int k2, int k3, int k4, int k5, typename InnerMatcher>
700inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>
701Args(const InnerMatcher& matcher) {
702 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>(matcher);
703}
704
705template <int k1, int k2, int k3, int k4, int k5, int k6, typename InnerMatcher>
706inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>
707Args(const InnerMatcher& matcher) {
708 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>(matcher);
709}
710
711template <int k1, int k2, int k3, int k4, int k5, int k6, int k7,
712 typename InnerMatcher>
713inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7>
714Args(const InnerMatcher& matcher) {
715 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6,
716 k7>(matcher);
717}
718
719template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
720 typename InnerMatcher>
721inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8>
722Args(const InnerMatcher& matcher) {
723 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7,
724 k8>(matcher);
725}
726
727template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
728 int k9, typename InnerMatcher>
729inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9>
730Args(const InnerMatcher& matcher) {
731 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
732 k9>(matcher);
733}
734
735template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
736 int k9, int k10, typename InnerMatcher>
737inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9,
738 k10>
739Args(const InnerMatcher& matcher) {
740 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
741 k9, k10>(matcher);
742}
743
shiqiane35fdd92008-12-10 05:08:54 +0000744// ElementsAre(e0, e1, ..., e_n) matches an STL-style container with
745// (n + 1) elements, where the i-th element in the container must
746// match the i-th argument in the list. Each argument of
747// ElementsAre() can be either a value or a matcher. We support up to
748// 10 arguments.
749//
750// NOTE: Since ElementsAre() cares about the order of the elements, it
751// must not be used with containers whose elements's order is
752// undefined (e.g. hash_map).
753
754inline internal::ElementsAreMatcher0 ElementsAre() {
755 return internal::ElementsAreMatcher0();
756}
757
758template <typename T1>
759inline internal::ElementsAreMatcher1<T1> ElementsAre(const T1& e1) {
760 return internal::ElementsAreMatcher1<T1>(e1);
761}
762
763template <typename T1, typename T2>
764inline internal::ElementsAreMatcher2<T1, T2> ElementsAre(const T1& e1,
765 const T2& e2) {
766 return internal::ElementsAreMatcher2<T1, T2>(e1, e2);
767}
768
769template <typename T1, typename T2, typename T3>
770inline internal::ElementsAreMatcher3<T1, T2, T3> ElementsAre(const T1& e1,
771 const T2& e2, const T3& e3) {
772 return internal::ElementsAreMatcher3<T1, T2, T3>(e1, e2, e3);
773}
774
775template <typename T1, typename T2, typename T3, typename T4>
776inline internal::ElementsAreMatcher4<T1, T2, T3, T4> ElementsAre(const T1& e1,
777 const T2& e2, const T3& e3, const T4& e4) {
778 return internal::ElementsAreMatcher4<T1, T2, T3, T4>(e1, e2, e3, e4);
779}
780
781template <typename T1, typename T2, typename T3, typename T4, typename T5>
782inline internal::ElementsAreMatcher5<T1, T2, T3, T4,
783 T5> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
784 const T5& e5) {
785 return internal::ElementsAreMatcher5<T1, T2, T3, T4, T5>(e1, e2, e3, e4, e5);
786}
787
788template <typename T1, typename T2, typename T3, typename T4, typename T5,
789 typename T6>
790inline internal::ElementsAreMatcher6<T1, T2, T3, T4, T5,
791 T6> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
792 const T5& e5, const T6& e6) {
793 return internal::ElementsAreMatcher6<T1, T2, T3, T4, T5, T6>(e1, e2, e3, e4,
794 e5, e6);
795}
796
797template <typename T1, typename T2, typename T3, typename T4, typename T5,
798 typename T6, typename T7>
799inline internal::ElementsAreMatcher7<T1, T2, T3, T4, T5, T6,
800 T7> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
801 const T5& e5, const T6& e6, const T7& e7) {
802 return internal::ElementsAreMatcher7<T1, T2, T3, T4, T5, T6, T7>(e1, e2, e3,
803 e4, e5, e6, e7);
804}
805
806template <typename T1, typename T2, typename T3, typename T4, typename T5,
807 typename T6, typename T7, typename T8>
808inline internal::ElementsAreMatcher8<T1, T2, T3, T4, T5, T6, T7,
809 T8> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
810 const T5& e5, const T6& e6, const T7& e7, const T8& e8) {
811 return internal::ElementsAreMatcher8<T1, T2, T3, T4, T5, T6, T7, T8>(e1, e2,
812 e3, e4, e5, e6, e7, e8);
813}
814
815template <typename T1, typename T2, typename T3, typename T4, typename T5,
816 typename T6, typename T7, typename T8, typename T9>
817inline internal::ElementsAreMatcher9<T1, T2, T3, T4, T5, T6, T7, T8,
818 T9> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
819 const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9) {
820 return internal::ElementsAreMatcher9<T1, T2, T3, T4, T5, T6, T7, T8, T9>(e1,
821 e2, e3, e4, e5, e6, e7, e8, e9);
822}
823
824template <typename T1, typename T2, typename T3, typename T4, typename T5,
825 typename T6, typename T7, typename T8, typename T9, typename T10>
826inline internal::ElementsAreMatcher10<T1, T2, T3, T4, T5, T6, T7, T8, T9,
827 T10> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
828 const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,
829 const T10& e10) {
830 return internal::ElementsAreMatcher10<T1, T2, T3, T4, T5, T6, T7, T8, T9,
831 T10>(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10);
832}
833
834// ElementsAreArray(array) and ElementAreArray(array, count) are like
835// ElementsAre(), except that they take an array of values or
836// matchers. The former form infers the size of 'array', which must
837// be a static C-style array. In the latter form, 'array' can either
838// be a static array or a pointer to a dynamically created array.
839
840template <typename T>
841inline internal::ElementsAreArrayMatcher<T> ElementsAreArray(
842 const T* first, size_t count) {
843 return internal::ElementsAreArrayMatcher<T>(first, count);
844}
845
846template <typename T, size_t N>
847inline internal::ElementsAreArrayMatcher<T>
848ElementsAreArray(const T (&array)[N]) {
849 return internal::ElementsAreArrayMatcher<T>(array, N);
850}
851
852} // namespace testing
853
zhanyong.wance198ff2009-02-12 01:34:27 +0000854// The MATCHER* family of macros can be used in a namespace scope to
zhanyong.wan82113312010-01-08 21:55:40 +0000855// define custom matchers easily.
856//
857// Basic Usage
858// ===========
859//
860// The syntax
zhanyong.wance198ff2009-02-12 01:34:27 +0000861//
862// MATCHER(name, description_string) { statements; }
863//
zhanyong.wan82113312010-01-08 21:55:40 +0000864// defines a matcher with the given name that executes the statements,
865// which must return a bool to indicate if the match succeeds. Inside
866// the statements, you can refer to the value being matched by 'arg',
867// and refer to its type by 'arg_type'.
zhanyong.wan4a5330d2009-02-19 00:36:44 +0000868//
869// The description string documents what the matcher does, and is used
870// to generate the failure message when the match fails. Since a
871// MATCHER() is usually defined in a header file shared by multiple
872// C++ source files, we require the description to be a C-string
873// literal to avoid possible side effects. It can be empty, in which
874// case we'll use the sequence of words in the matcher name as the
875// description.
876//
877// For example:
zhanyong.wance198ff2009-02-12 01:34:27 +0000878//
879// MATCHER(IsEven, "") { return (arg % 2) == 0; }
880//
881// allows you to write
882//
883// // Expects mock_foo.Bar(n) to be called where n is even.
884// EXPECT_CALL(mock_foo, Bar(IsEven()));
885//
886// or,
887//
888// // Verifies that the value of some_expression is even.
889// EXPECT_THAT(some_expression, IsEven());
890//
891// If the above assertion fails, it will print something like:
892//
893// Value of: some_expression
894// Expected: is even
895// Actual: 7
896//
897// where the description "is even" is automatically calculated from the
898// matcher name IsEven.
899//
zhanyong.wan82113312010-01-08 21:55:40 +0000900// Argument Type
901// =============
902//
zhanyong.wance198ff2009-02-12 01:34:27 +0000903// Note that the type of the value being matched (arg_type) is
904// determined by the context in which you use the matcher and is
905// supplied to you by the compiler, so you don't need to worry about
906// declaring it (nor can you). This allows the matcher to be
907// polymorphic. For example, IsEven() can be used to match any type
908// where the value of "(arg % 2) == 0" can be implicitly converted to
909// a bool. In the "Bar(IsEven())" example above, if method Bar()
910// takes an int, 'arg_type' will be int; if it takes an unsigned long,
911// 'arg_type' will be unsigned long; and so on.
912//
zhanyong.wan82113312010-01-08 21:55:40 +0000913// Parameterizing Matchers
914// =======================
915//
zhanyong.wance198ff2009-02-12 01:34:27 +0000916// Sometimes you'll want to parameterize the matcher. For that you
917// can use another macro:
918//
919// MATCHER_P(name, param_name, description_string) { statements; }
920//
921// For example:
922//
923// MATCHER_P(HasAbsoluteValue, value, "") { return abs(arg) == value; }
924//
925// will allow you to write:
926//
927// EXPECT_THAT(Blah("a"), HasAbsoluteValue(n));
928//
929// which may lead to this message (assuming n is 10):
930//
931// Value of: Blah("a")
932// Expected: has absolute value 10
933// Actual: -9
934//
935// Note that both the matcher description and its parameter are
936// printed, making the message human-friendly.
937//
938// In the matcher definition body, you can write 'foo_type' to
939// reference the type of a parameter named 'foo'. For example, in the
940// body of MATCHER_P(HasAbsoluteValue, value) above, you can write
941// 'value_type' to refer to the type of 'value'.
942//
943// We also provide MATCHER_P2, MATCHER_P3, ..., up to MATCHER_P10 to
944// support multi-parameter matchers.
945//
zhanyong.wan82113312010-01-08 21:55:40 +0000946// Describing Parameterized Matchers
947// =================================
948//
zhanyong.wan4a5330d2009-02-19 00:36:44 +0000949// When defining a parameterized matcher, you can use Python-style
950// interpolations in the description string to refer to the parameter
951// values. We support the following syntax currently:
952//
953// %% a single '%' character
954// %(*)s all parameters of the matcher printed as a tuple
955// %(foo)s value of the matcher parameter named 'foo'
956//
957// For example,
958//
959// MATCHER_P2(InClosedRange, low, hi, "is in range [%(low)s, %(hi)s]") {
960// return low <= arg && arg <= hi;
961// }
962// ...
963// EXPECT_THAT(3, InClosedRange(4, 6));
964//
965// would generate a failure that contains the message:
966//
967// Expected: is in range [4, 6]
968//
969// If you specify "" as the description, the failure message will
970// contain the sequence of words in the matcher name followed by the
971// parameter values printed as a tuple. For example,
972//
973// MATCHER_P2(InClosedRange, low, hi, "") { ... }
974// ...
975// EXPECT_THAT(3, InClosedRange(4, 6));
976//
977// would generate a failure that contains the text:
978//
979// Expected: in closed range (4, 6)
980//
zhanyong.wan82113312010-01-08 21:55:40 +0000981// Types of Matcher Parameters
982// ===========================
983//
zhanyong.wance198ff2009-02-12 01:34:27 +0000984// For the purpose of typing, you can view
985//
986// MATCHER_Pk(Foo, p1, ..., pk, description_string) { ... }
987//
988// as shorthand for
989//
990// template <typename p1_type, ..., typename pk_type>
991// FooMatcherPk<p1_type, ..., pk_type>
992// Foo(p1_type p1, ..., pk_type pk) { ... }
993//
994// When you write Foo(v1, ..., vk), the compiler infers the types of
995// the parameters v1, ..., and vk for you. If you are not happy with
996// the result of the type inference, you can specify the types by
997// explicitly instantiating the template, as in Foo<long, bool>(5,
998// false). As said earlier, you don't get to (or need to) specify
999// 'arg_type' as that's determined by the context in which the matcher
1000// is used. You can assign the result of expression Foo(p1, ..., pk)
1001// to a variable of type FooMatcherPk<p1_type, ..., pk_type>. This
1002// can be useful when composing matchers.
1003//
1004// While you can instantiate a matcher template with reference types,
1005// passing the parameters by pointer usually makes your code more
1006// readable. If, however, you still want to pass a parameter by
1007// reference, be aware that in the failure message generated by the
1008// matcher you will see the value of the referenced object but not its
1009// address.
1010//
zhanyong.wan82113312010-01-08 21:55:40 +00001011// Explaining Match Results
1012// ========================
1013//
1014// Sometimes the matcher description alone isn't enough to explain why
1015// the match has failed or succeeded. For example, when expecting a
1016// long string, it can be very helpful to also print the diff between
1017// the expected string and the actual one. To achieve that, you can
1018// optionally stream additional information to a special variable
1019// named result_listener, whose type is a pointer to class
1020// MatchResultListener:
1021//
1022// MATCHER_P(EqualsLongString, str, "") {
1023// if (arg == str) return true;
1024//
1025// *result_listener << "the difference: "
1026/// << DiffStrings(str, arg);
1027// return false;
1028// }
1029//
1030// Overloading Matchers
1031// ====================
1032//
zhanyong.wance198ff2009-02-12 01:34:27 +00001033// You can overload matchers with different numbers of parameters:
1034//
1035// MATCHER_P(Blah, a, description_string1) { ... }
1036// MATCHER_P2(Blah, a, b, description_string2) { ... }
1037//
zhanyong.wan82113312010-01-08 21:55:40 +00001038// Caveats
1039// =======
zhanyong.wance198ff2009-02-12 01:34:27 +00001040//
zhanyong.wan82113312010-01-08 21:55:40 +00001041// When defining a new matcher, you should also consider implementing
1042// MatcherInterface or using MakePolymorphicMatcher(). These
1043// approaches require more work than the MATCHER* macros, but also
1044// give you more control on the types of the value being matched and
1045// the matcher parameters, which may leads to better compiler error
1046// messages when the matcher is used wrong. They also allow
1047// overloading matchers based on parameter types (as opposed to just
1048// based on the number of parameters).
zhanyong.wance198ff2009-02-12 01:34:27 +00001049//
1050// MATCHER*() can only be used in a namespace scope. The reason is
1051// that C++ doesn't yet allow function-local types to be used to
1052// instantiate templates. The up-coming C++0x standard will fix this.
1053// Once that's done, we'll consider supporting using MATCHER*() inside
1054// a function.
1055//
zhanyong.wan82113312010-01-08 21:55:40 +00001056// More Information
1057// ================
zhanyong.wance198ff2009-02-12 01:34:27 +00001058//
1059// To learn more about using these macros, please search for 'MATCHER'
1060// on http://code.google.com/p/googlemock/wiki/CookBook.
1061
1062#define MATCHER(name, description)\
1063 class name##Matcher {\
1064 public:\
1065 template <typename arg_type>\
1066 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1067 public:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001068 gmock_Impl(const ::testing::internal::Interpolations& gmock_interp)\
1069 : gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001070 virtual bool MatchAndExplain(\
1071 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001072 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1073 const ::testing::internal::Strings& gmock_printed_params = \
1074 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1075 ::std::tr1::tuple<>());\
1076 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1077 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001078 }\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001079 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001080 private:\
1081 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001082 };\
1083 template <typename arg_type>\
1084 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001085 return ::testing::Matcher<arg_type>(\
1086 new gmock_Impl<arg_type>(gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001087 }\
1088 name##Matcher() {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001089 const char* gmock_param_names[] = { NULL };\
1090 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1091 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001092 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001093 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001094 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001095 GTEST_DISALLOW_ASSIGN_(name##Matcher);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001096 };\
1097 inline name##Matcher name() {\
1098 return name##Matcher();\
1099 }\
1100 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001101 bool name##Matcher::gmock_Impl<arg_type>::MatchAndExplain(\
1102 arg_type arg,\
1103 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1104 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001105
1106#define MATCHER_P(name, p0, description)\
1107 template <typename p0##_type>\
1108 class name##MatcherP {\
1109 public:\
1110 template <typename arg_type>\
1111 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1112 public:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001113 explicit gmock_Impl(p0##_type gmock_p0, \
1114 const ::testing::internal::Interpolations& gmock_interp)\
1115 : p0(gmock_p0), gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001116 virtual bool MatchAndExplain(\
1117 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001118 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1119 const ::testing::internal::Strings& gmock_printed_params = \
1120 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1121 ::std::tr1::tuple<p0##_type>(p0));\
1122 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1123 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001124 }\
1125 p0##_type p0;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001126 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001127 private:\
1128 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001129 };\
1130 template <typename arg_type>\
1131 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001132 return ::testing::Matcher<arg_type>(\
1133 new gmock_Impl<arg_type>(p0, gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001134 }\
1135 name##MatcherP(p0##_type gmock_p0) : p0(gmock_p0) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001136 const char* gmock_param_names[] = { #p0, NULL };\
1137 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1138 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001139 }\
1140 p0##_type p0;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001141 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001142 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001143 GTEST_DISALLOW_ASSIGN_(name##MatcherP);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001144 };\
1145 template <typename p0##_type>\
1146 inline name##MatcherP<p0##_type> name(p0##_type p0) {\
1147 return name##MatcherP<p0##_type>(p0);\
1148 }\
1149 template <typename p0##_type>\
1150 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001151 bool name##MatcherP<p0##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1152 arg_type arg,\
1153 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1154 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001155
1156#define MATCHER_P2(name, p0, p1, description)\
1157 template <typename p0##_type, typename p1##_type>\
1158 class name##MatcherP2 {\
1159 public:\
1160 template <typename arg_type>\
1161 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1162 public:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001163 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, \
1164 const ::testing::internal::Interpolations& gmock_interp)\
1165 : p0(gmock_p0), p1(gmock_p1), gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001166 virtual bool MatchAndExplain(\
1167 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001168 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1169 const ::testing::internal::Strings& gmock_printed_params = \
1170 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1171 ::std::tr1::tuple<p0##_type, p1##_type>(p0, p1));\
1172 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1173 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001174 }\
1175 p0##_type p0;\
1176 p1##_type p1;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001177 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001178 private:\
1179 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001180 };\
1181 template <typename arg_type>\
1182 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001183 return ::testing::Matcher<arg_type>(\
1184 new gmock_Impl<arg_type>(p0, p1, gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001185 }\
1186 name##MatcherP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
1187 p1(gmock_p1) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001188 const char* gmock_param_names[] = { #p0, #p1, NULL };\
1189 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1190 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001191 }\
1192 p0##_type p0;\
1193 p1##_type p1;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001194 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001195 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001196 GTEST_DISALLOW_ASSIGN_(name##MatcherP2);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001197 };\
1198 template <typename p0##_type, typename p1##_type>\
1199 inline name##MatcherP2<p0##_type, p1##_type> name(p0##_type p0, \
1200 p1##_type p1) {\
1201 return name##MatcherP2<p0##_type, p1##_type>(p0, p1);\
1202 }\
1203 template <typename p0##_type, typename p1##_type>\
1204 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001205 bool name##MatcherP2<p0##_type, \
1206 p1##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1207 arg_type arg,\
1208 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1209 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001210
1211#define MATCHER_P3(name, p0, p1, p2, description)\
1212 template <typename p0##_type, typename p1##_type, typename p2##_type>\
1213 class name##MatcherP3 {\
1214 public:\
1215 template <typename arg_type>\
1216 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1217 public:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001218 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1219 const ::testing::internal::Interpolations& gmock_interp)\
1220 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1221 gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001222 virtual bool MatchAndExplain(\
1223 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001224 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1225 const ::testing::internal::Strings& gmock_printed_params = \
1226 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1227 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type>(p0, p1, \
1228 p2));\
1229 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1230 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001231 }\
1232 p0##_type p0;\
1233 p1##_type p1;\
1234 p2##_type p2;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001235 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001236 private:\
1237 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001238 };\
1239 template <typename arg_type>\
1240 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001241 return ::testing::Matcher<arg_type>(\
1242 new gmock_Impl<arg_type>(p0, p1, p2, gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001243 }\
1244 name##MatcherP3(p0##_type gmock_p0, p1##_type gmock_p1, \
1245 p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001246 const char* gmock_param_names[] = { #p0, #p1, #p2, NULL };\
1247 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1248 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001249 }\
1250 p0##_type p0;\
1251 p1##_type p1;\
1252 p2##_type p2;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001253 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001254 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001255 GTEST_DISALLOW_ASSIGN_(name##MatcherP3);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001256 };\
1257 template <typename p0##_type, typename p1##_type, typename p2##_type>\
1258 inline name##MatcherP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0, \
1259 p1##_type p1, p2##_type p2) {\
1260 return name##MatcherP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\
1261 }\
1262 template <typename p0##_type, typename p1##_type, typename p2##_type>\
1263 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001264 bool name##MatcherP3<p0##_type, p1##_type, \
1265 p2##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1266 arg_type arg,\
1267 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1268 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001269
1270#define MATCHER_P4(name, p0, p1, p2, p3, description)\
1271 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1272 typename p3##_type>\
1273 class name##MatcherP4 {\
1274 public:\
1275 template <typename arg_type>\
1276 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1277 public:\
1278 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001279 p3##_type gmock_p3, \
1280 const ::testing::internal::Interpolations& gmock_interp)\
1281 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1282 gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001283 virtual bool MatchAndExplain(\
1284 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001285 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1286 const ::testing::internal::Strings& gmock_printed_params = \
1287 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1288 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, \
1289 p3##_type>(p0, p1, p2, p3));\
1290 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1291 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001292 }\
1293 p0##_type p0;\
1294 p1##_type p1;\
1295 p2##_type p2;\
1296 p3##_type p3;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001297 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001298 private:\
1299 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001300 };\
1301 template <typename arg_type>\
1302 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001303 return ::testing::Matcher<arg_type>(\
1304 new gmock_Impl<arg_type>(p0, p1, p2, p3, gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001305 }\
1306 name##MatcherP4(p0##_type gmock_p0, p1##_type gmock_p1, \
1307 p2##_type gmock_p2, p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), \
1308 p2(gmock_p2), p3(gmock_p3) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001309 const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, NULL };\
1310 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1311 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001312 }\
1313 p0##_type p0;\
1314 p1##_type p1;\
1315 p2##_type p2;\
1316 p3##_type p3;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001317 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001318 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001319 GTEST_DISALLOW_ASSIGN_(name##MatcherP4);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001320 };\
1321 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1322 typename p3##_type>\
1323 inline name##MatcherP4<p0##_type, p1##_type, p2##_type, \
1324 p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
1325 p3##_type p3) {\
1326 return name##MatcherP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, \
1327 p1, p2, p3);\
1328 }\
1329 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1330 typename p3##_type>\
1331 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001332 bool name##MatcherP4<p0##_type, p1##_type, p2##_type, \
1333 p3##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1334 arg_type arg,\
1335 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1336 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001337
1338#define MATCHER_P5(name, p0, p1, p2, p3, p4, description)\
1339 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1340 typename p3##_type, typename p4##_type>\
1341 class name##MatcherP5 {\
1342 public:\
1343 template <typename arg_type>\
1344 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1345 public:\
1346 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001347 p3##_type gmock_p3, p4##_type gmock_p4, \
1348 const ::testing::internal::Interpolations& gmock_interp)\
1349 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1350 p4(gmock_p4), gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001351 virtual bool MatchAndExplain(\
1352 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001353 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1354 const ::testing::internal::Strings& gmock_printed_params = \
1355 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1356 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1357 p4##_type>(p0, p1, p2, p3, p4));\
1358 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1359 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001360 }\
1361 p0##_type p0;\
1362 p1##_type p1;\
1363 p2##_type p2;\
1364 p3##_type p3;\
1365 p4##_type p4;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001366 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001367 private:\
1368 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001369 };\
1370 template <typename arg_type>\
1371 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001372 return ::testing::Matcher<arg_type>(\
1373 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001374 }\
1375 name##MatcherP5(p0##_type gmock_p0, p1##_type gmock_p1, \
1376 p2##_type gmock_p2, p3##_type gmock_p3, \
1377 p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1378 p3(gmock_p3), p4(gmock_p4) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001379 const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, NULL };\
1380 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1381 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001382 }\
1383 p0##_type p0;\
1384 p1##_type p1;\
1385 p2##_type p2;\
1386 p3##_type p3;\
1387 p4##_type p4;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001388 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001389 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001390 GTEST_DISALLOW_ASSIGN_(name##MatcherP5);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001391 };\
1392 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1393 typename p3##_type, typename p4##_type>\
1394 inline name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1395 p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
1396 p4##_type p4) {\
1397 return name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1398 p4##_type>(p0, p1, p2, p3, p4);\
1399 }\
1400 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1401 typename p3##_type, typename p4##_type>\
1402 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001403 bool name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1404 p4##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1405 arg_type arg,\
1406 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1407 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001408
1409#define MATCHER_P6(name, p0, p1, p2, p3, p4, p5, description)\
1410 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1411 typename p3##_type, typename p4##_type, typename p5##_type>\
1412 class name##MatcherP6 {\
1413 public:\
1414 template <typename arg_type>\
1415 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1416 public:\
1417 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001418 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
1419 const ::testing::internal::Interpolations& gmock_interp)\
1420 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1421 p4(gmock_p4), p5(gmock_p5), gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001422 virtual bool MatchAndExplain(\
1423 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001424 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1425 const ::testing::internal::Strings& gmock_printed_params = \
1426 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1427 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1428 p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5));\
1429 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1430 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001431 }\
1432 p0##_type p0;\
1433 p1##_type p1;\
1434 p2##_type p2;\
1435 p3##_type p3;\
1436 p4##_type p4;\
1437 p5##_type p5;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001438 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001439 private:\
1440 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001441 };\
1442 template <typename arg_type>\
1443 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001444 return ::testing::Matcher<arg_type>(\
1445 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001446 }\
1447 name##MatcherP6(p0##_type gmock_p0, p1##_type gmock_p1, \
1448 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1449 p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1450 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001451 const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, #p5, NULL };\
1452 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1453 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001454 }\
1455 p0##_type p0;\
1456 p1##_type p1;\
1457 p2##_type p2;\
1458 p3##_type p3;\
1459 p4##_type p4;\
1460 p5##_type p5;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001461 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001462 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001463 GTEST_DISALLOW_ASSIGN_(name##MatcherP6);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001464 };\
1465 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1466 typename p3##_type, typename p4##_type, typename p5##_type>\
1467 inline name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
1468 p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
1469 p3##_type p3, p4##_type p4, p5##_type p5) {\
1470 return name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
1471 p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\
1472 }\
1473 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1474 typename p3##_type, typename p4##_type, typename p5##_type>\
1475 template <typename arg_type>\
1476 bool name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00001477 p5##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1478 arg_type arg,\
1479 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1480 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001481
1482#define MATCHER_P7(name, p0, p1, p2, p3, p4, p5, p6, description)\
1483 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1484 typename p3##_type, typename p4##_type, typename p5##_type, \
1485 typename p6##_type>\
1486 class name##MatcherP7 {\
1487 public:\
1488 template <typename arg_type>\
1489 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1490 public:\
1491 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1492 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001493 p6##_type gmock_p6, \
1494 const ::testing::internal::Interpolations& gmock_interp)\
1495 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1496 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
1497 gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001498 virtual bool MatchAndExplain(\
1499 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001500 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1501 const ::testing::internal::Strings& gmock_printed_params = \
1502 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1503 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1504 p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, \
1505 p6));\
1506 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1507 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001508 }\
1509 p0##_type p0;\
1510 p1##_type p1;\
1511 p2##_type p2;\
1512 p3##_type p3;\
1513 p4##_type p4;\
1514 p5##_type p5;\
1515 p6##_type p6;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001516 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001517 private:\
1518 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001519 };\
1520 template <typename arg_type>\
1521 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001522 return ::testing::Matcher<arg_type>(\
1523 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001524 }\
1525 name##MatcherP7(p0##_type gmock_p0, p1##_type gmock_p1, \
1526 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1527 p5##_type gmock_p5, p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), \
1528 p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), \
1529 p6(gmock_p6) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001530 const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, #p5, #p6, \
1531 NULL };\
1532 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1533 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001534 }\
1535 p0##_type p0;\
1536 p1##_type p1;\
1537 p2##_type p2;\
1538 p3##_type p3;\
1539 p4##_type p4;\
1540 p5##_type p5;\
1541 p6##_type p6;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001542 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001543 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001544 GTEST_DISALLOW_ASSIGN_(name##MatcherP7);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001545 };\
1546 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1547 typename p3##_type, typename p4##_type, typename p5##_type, \
1548 typename p6##_type>\
1549 inline name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
1550 p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \
1551 p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
1552 p6##_type p6) {\
1553 return name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
1554 p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\
1555 }\
1556 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1557 typename p3##_type, typename p4##_type, typename p5##_type, \
1558 typename p6##_type>\
1559 template <typename arg_type>\
1560 bool name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00001561 p5##_type, p6##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1562 arg_type arg,\
1563 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1564 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001565
1566#define MATCHER_P8(name, p0, p1, p2, p3, p4, p5, p6, p7, description)\
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, typename p7##_type>\
1570 class name##MatcherP8 {\
1571 public:\
1572 template <typename arg_type>\
1573 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1574 public:\
1575 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1576 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001577 p6##_type gmock_p6, p7##_type gmock_p7, \
1578 const ::testing::internal::Interpolations& gmock_interp)\
1579 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1580 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
1581 gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001582 virtual bool MatchAndExplain(\
1583 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001584 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1585 const ::testing::internal::Strings& gmock_printed_params = \
1586 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1587 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1588 p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, \
1589 p3, p4, p5, p6, p7));\
1590 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1591 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001592 }\
1593 p0##_type p0;\
1594 p1##_type p1;\
1595 p2##_type p2;\
1596 p3##_type p3;\
1597 p4##_type p4;\
1598 p5##_type p5;\
1599 p6##_type p6;\
1600 p7##_type p7;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001601 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001602 private:\
1603 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001604 };\
1605 template <typename arg_type>\
1606 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001607 return ::testing::Matcher<arg_type>(\
1608 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, \
1609 gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001610 }\
1611 name##MatcherP8(p0##_type gmock_p0, p1##_type gmock_p1, \
1612 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1613 p5##_type gmock_p5, p6##_type gmock_p6, \
1614 p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1615 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
1616 p7(gmock_p7) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001617 const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, #p5, #p6, \
1618 #p7, NULL };\
1619 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1620 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001621 }\
1622 p0##_type p0;\
1623 p1##_type p1;\
1624 p2##_type p2;\
1625 p3##_type p3;\
1626 p4##_type p4;\
1627 p5##_type p5;\
1628 p6##_type p6;\
1629 p7##_type p7;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001630 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001631 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001632 GTEST_DISALLOW_ASSIGN_(name##MatcherP8);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001633 };\
1634 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1635 typename p3##_type, typename p4##_type, typename p5##_type, \
1636 typename p6##_type, typename p7##_type>\
1637 inline name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
1638 p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \
1639 p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
1640 p6##_type p6, p7##_type p7) {\
1641 return name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
1642 p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5, \
1643 p6, p7);\
1644 }\
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 template <typename arg_type>\
1649 bool name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00001650 p5##_type, p6##_type, \
1651 p7##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1652 arg_type arg,\
1653 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1654 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001655
1656#define MATCHER_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, description)\
1657 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1658 typename p3##_type, typename p4##_type, typename p5##_type, \
1659 typename p6##_type, typename p7##_type, typename p8##_type>\
1660 class name##MatcherP9 {\
1661 public:\
1662 template <typename arg_type>\
1663 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1664 public:\
1665 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1666 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001667 p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
1668 const ::testing::internal::Interpolations& gmock_interp)\
1669 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1670 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
1671 p8(gmock_p8), gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001672 virtual bool MatchAndExplain(\
1673 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001674 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1675 const ::testing::internal::Strings& gmock_printed_params = \
1676 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1677 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1678 p4##_type, p5##_type, p6##_type, p7##_type, \
1679 p8##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8));\
1680 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1681 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001682 }\
1683 p0##_type p0;\
1684 p1##_type p1;\
1685 p2##_type p2;\
1686 p3##_type p3;\
1687 p4##_type p4;\
1688 p5##_type p5;\
1689 p6##_type p6;\
1690 p7##_type p7;\
1691 p8##_type p8;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001692 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001693 private:\
1694 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001695 };\
1696 template <typename arg_type>\
1697 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001698 return ::testing::Matcher<arg_type>(\
1699 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, \
1700 gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001701 }\
1702 name##MatcherP9(p0##_type gmock_p0, p1##_type gmock_p1, \
1703 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1704 p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
1705 p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1706 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
1707 p8(gmock_p8) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001708 const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, #p5, #p6, \
1709 #p7, #p8, NULL };\
1710 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1711 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001712 }\
1713 p0##_type p0;\
1714 p1##_type p1;\
1715 p2##_type p2;\
1716 p3##_type p3;\
1717 p4##_type p4;\
1718 p5##_type p5;\
1719 p6##_type p6;\
1720 p7##_type p7;\
1721 p8##_type p8;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001722 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001723 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001724 GTEST_DISALLOW_ASSIGN_(name##MatcherP9);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001725 };\
1726 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1727 typename p3##_type, typename p4##_type, typename p5##_type, \
1728 typename p6##_type, typename p7##_type, typename p8##_type>\
1729 inline name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \
1730 p4##_type, p5##_type, p6##_type, p7##_type, \
1731 p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
1732 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \
1733 p8##_type p8) {\
1734 return name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \
1735 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type>(p0, p1, p2, \
1736 p3, p4, p5, p6, p7, p8);\
1737 }\
1738 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1739 typename p3##_type, typename p4##_type, typename p5##_type, \
1740 typename p6##_type, typename p7##_type, typename p8##_type>\
1741 template <typename arg_type>\
1742 bool name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00001743 p5##_type, p6##_type, p7##_type, \
1744 p8##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1745 arg_type arg,\
1746 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1747 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001748
1749#define MATCHER_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, description)\
1750 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1751 typename p3##_type, typename p4##_type, typename p5##_type, \
1752 typename p6##_type, typename p7##_type, typename p8##_type, \
1753 typename p9##_type>\
1754 class name##MatcherP10 {\
1755 public:\
1756 template <typename arg_type>\
1757 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1758 public:\
1759 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1760 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
1761 p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001762 p9##_type gmock_p9, \
1763 const ::testing::internal::Interpolations& gmock_interp)\
1764 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1765 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
1766 p8(gmock_p8), p9(gmock_p9), gmock_interp_(gmock_interp) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001767 virtual bool MatchAndExplain(\
1768 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001769 virtual void DescribeTo(::std::ostream* gmock_os) const {\
1770 const ::testing::internal::Strings& gmock_printed_params = \
1771 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1772 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1773 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
1774 p9##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9));\
1775 *gmock_os << ::testing::internal::FormatMatcherDescription(\
1776 #name, description, gmock_interp_, gmock_printed_params);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001777 }\
1778 p0##_type p0;\
1779 p1##_type p1;\
1780 p2##_type p2;\
1781 p3##_type p3;\
1782 p4##_type p4;\
1783 p5##_type p5;\
1784 p6##_type p6;\
1785 p7##_type p7;\
1786 p8##_type p8;\
1787 p9##_type p9;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001788 const ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001789 private:\
1790 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001791 };\
1792 template <typename arg_type>\
1793 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001794 return ::testing::Matcher<arg_type>(\
1795 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, \
1796 gmock_interp_));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001797 }\
1798 name##MatcherP10(p0##_type gmock_p0, p1##_type gmock_p1, \
1799 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1800 p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
1801 p8##_type gmock_p8, p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), \
1802 p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
1803 p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001804 const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, #p5, #p6, \
1805 #p7, #p8, #p9, NULL };\
1806 gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
1807 gmock_param_names, ("" description ""));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001808 }\
1809 p0##_type p0;\
1810 p1##_type p1;\
1811 p2##_type p2;\
1812 p3##_type p3;\
1813 p4##_type p4;\
1814 p5##_type p5;\
1815 p6##_type p6;\
1816 p7##_type p7;\
1817 p8##_type p8;\
1818 p9##_type p9;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001819 private:\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001820 ::testing::internal::Interpolations gmock_interp_;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001821 GTEST_DISALLOW_ASSIGN_(name##MatcherP10);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001822 };\
1823 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1824 typename p3##_type, typename p4##_type, typename p5##_type, \
1825 typename p6##_type, typename p7##_type, typename p8##_type, \
1826 typename p9##_type>\
1827 inline name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
1828 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
1829 p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
1830 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
1831 p9##_type p9) {\
1832 return name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
1833 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>(p0, \
1834 p1, p2, p3, p4, p5, p6, p7, p8, p9);\
1835 }\
1836 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1837 typename p3##_type, typename p4##_type, typename p5##_type, \
1838 typename p6##_type, typename p7##_type, typename p8##_type, \
1839 typename p9##_type>\
1840 template <typename arg_type>\
1841 bool name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00001842 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
1843 p9##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1844 arg_type arg,\
1845 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1846 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001847
shiqiane35fdd92008-12-10 05:08:54 +00001848#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_