blob: cb6105430fc47ad2408ec127e12b9a949483e924 [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
zhanyong.wan02c15052010-06-09 19:21:30 +0000852// AllOf(m1, m2, ..., mk) matches any value that matches all of the given
853// sub-matchers.
854
855template <typename Matcher1, typename Matcher2>
856inline internal::BothOfMatcher<Matcher1, Matcher2>
857AllOf(Matcher1 m1, Matcher2 m2) {
858 return internal::BothOfMatcher<Matcher1, Matcher2>(m1, m2);
859}
860
861template <typename Matcher1, typename Matcher2, typename Matcher3>
862inline internal::BothOfMatcher<Matcher1, internal::BothOfMatcher<Matcher2,
863 Matcher3> >
864AllOf(Matcher1 m1, Matcher2 m2, Matcher3 m3) {
865 return AllOf(m1, AllOf(m2, m3));
866}
867
868template <typename Matcher1, typename Matcher2, typename Matcher3,
869 typename Matcher4>
870inline internal::BothOfMatcher<Matcher1, internal::BothOfMatcher<Matcher2,
871 internal::BothOfMatcher<Matcher3, Matcher4> > >
872AllOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4) {
873 return AllOf(m1, AllOf(m2, m3, m4));
874}
875
876template <typename Matcher1, typename Matcher2, typename Matcher3,
877 typename Matcher4, typename Matcher5>
878inline internal::BothOfMatcher<Matcher1, internal::BothOfMatcher<Matcher2,
879 internal::BothOfMatcher<Matcher3, internal::BothOfMatcher<Matcher4,
880 Matcher5> > > >
881AllOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5) {
882 return AllOf(m1, AllOf(m2, m3, m4, m5));
883}
884
885template <typename Matcher1, typename Matcher2, typename Matcher3,
886 typename Matcher4, typename Matcher5, typename Matcher6>
887inline internal::BothOfMatcher<Matcher1, internal::BothOfMatcher<Matcher2,
888 internal::BothOfMatcher<Matcher3, internal::BothOfMatcher<Matcher4,
889 internal::BothOfMatcher<Matcher5, Matcher6> > > > >
890AllOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
891 Matcher6 m6) {
892 return AllOf(m1, AllOf(m2, m3, m4, m5, m6));
893}
894
895template <typename Matcher1, typename Matcher2, typename Matcher3,
896 typename Matcher4, typename Matcher5, typename Matcher6, typename Matcher7>
897inline internal::BothOfMatcher<Matcher1, internal::BothOfMatcher<Matcher2,
898 internal::BothOfMatcher<Matcher3, internal::BothOfMatcher<Matcher4,
899 internal::BothOfMatcher<Matcher5, internal::BothOfMatcher<Matcher6,
900 Matcher7> > > > > >
901AllOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
902 Matcher6 m6, Matcher7 m7) {
903 return AllOf(m1, AllOf(m2, m3, m4, m5, m6, m7));
904}
905
906template <typename Matcher1, typename Matcher2, typename Matcher3,
907 typename Matcher4, typename Matcher5, typename Matcher6, typename Matcher7,
908 typename Matcher8>
909inline internal::BothOfMatcher<Matcher1, internal::BothOfMatcher<Matcher2,
910 internal::BothOfMatcher<Matcher3, internal::BothOfMatcher<Matcher4,
911 internal::BothOfMatcher<Matcher5, internal::BothOfMatcher<Matcher6,
912 internal::BothOfMatcher<Matcher7, Matcher8> > > > > > >
913AllOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
914 Matcher6 m6, Matcher7 m7, Matcher8 m8) {
915 return AllOf(m1, AllOf(m2, m3, m4, m5, m6, m7, m8));
916}
917
918template <typename Matcher1, typename Matcher2, typename Matcher3,
919 typename Matcher4, typename Matcher5, typename Matcher6, typename Matcher7,
920 typename Matcher8, typename Matcher9>
921inline internal::BothOfMatcher<Matcher1, internal::BothOfMatcher<Matcher2,
922 internal::BothOfMatcher<Matcher3, internal::BothOfMatcher<Matcher4,
923 internal::BothOfMatcher<Matcher5, internal::BothOfMatcher<Matcher6,
924 internal::BothOfMatcher<Matcher7, internal::BothOfMatcher<Matcher8,
925 Matcher9> > > > > > > >
926AllOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
927 Matcher6 m6, Matcher7 m7, Matcher8 m8, Matcher9 m9) {
928 return AllOf(m1, AllOf(m2, m3, m4, m5, m6, m7, m8, m9));
929}
930
931template <typename Matcher1, typename Matcher2, typename Matcher3,
932 typename Matcher4, typename Matcher5, typename Matcher6, typename Matcher7,
933 typename Matcher8, typename Matcher9, typename Matcher10>
934inline internal::BothOfMatcher<Matcher1, internal::BothOfMatcher<Matcher2,
935 internal::BothOfMatcher<Matcher3, internal::BothOfMatcher<Matcher4,
936 internal::BothOfMatcher<Matcher5, internal::BothOfMatcher<Matcher6,
937 internal::BothOfMatcher<Matcher7, internal::BothOfMatcher<Matcher8,
938 internal::BothOfMatcher<Matcher9, Matcher10> > > > > > > > >
939AllOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
940 Matcher6 m6, Matcher7 m7, Matcher8 m8, Matcher9 m9, Matcher10 m10) {
941 return AllOf(m1, AllOf(m2, m3, m4, m5, m6, m7, m8, m9, m10));
942}
943
944// AnyOf(m1, m2, ..., mk) matches any value that matches any of the given
945// sub-matchers.
946
947template <typename Matcher1, typename Matcher2>
948inline internal::EitherOfMatcher<Matcher1, Matcher2>
949AnyOf(Matcher1 m1, Matcher2 m2) {
950 return internal::EitherOfMatcher<Matcher1, Matcher2>(m1, m2);
951}
952
953template <typename Matcher1, typename Matcher2, typename Matcher3>
954inline internal::EitherOfMatcher<Matcher1, internal::EitherOfMatcher<Matcher2,
955 Matcher3> >
956AnyOf(Matcher1 m1, Matcher2 m2, Matcher3 m3) {
957 return AnyOf(m1, AnyOf(m2, m3));
958}
959
960template <typename Matcher1, typename Matcher2, typename Matcher3,
961 typename Matcher4>
962inline internal::EitherOfMatcher<Matcher1, internal::EitherOfMatcher<Matcher2,
963 internal::EitherOfMatcher<Matcher3, Matcher4> > >
964AnyOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4) {
965 return AnyOf(m1, AnyOf(m2, m3, m4));
966}
967
968template <typename Matcher1, typename Matcher2, typename Matcher3,
969 typename Matcher4, typename Matcher5>
970inline internal::EitherOfMatcher<Matcher1, internal::EitherOfMatcher<Matcher2,
971 internal::EitherOfMatcher<Matcher3, internal::EitherOfMatcher<Matcher4,
972 Matcher5> > > >
973AnyOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5) {
974 return AnyOf(m1, AnyOf(m2, m3, m4, m5));
975}
976
977template <typename Matcher1, typename Matcher2, typename Matcher3,
978 typename Matcher4, typename Matcher5, typename Matcher6>
979inline internal::EitherOfMatcher<Matcher1, internal::EitherOfMatcher<Matcher2,
980 internal::EitherOfMatcher<Matcher3, internal::EitherOfMatcher<Matcher4,
981 internal::EitherOfMatcher<Matcher5, Matcher6> > > > >
982AnyOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
983 Matcher6 m6) {
984 return AnyOf(m1, AnyOf(m2, m3, m4, m5, m6));
985}
986
987template <typename Matcher1, typename Matcher2, typename Matcher3,
988 typename Matcher4, typename Matcher5, typename Matcher6, typename Matcher7>
989inline internal::EitherOfMatcher<Matcher1, internal::EitherOfMatcher<Matcher2,
990 internal::EitherOfMatcher<Matcher3, internal::EitherOfMatcher<Matcher4,
991 internal::EitherOfMatcher<Matcher5, internal::EitherOfMatcher<Matcher6,
992 Matcher7> > > > > >
993AnyOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
994 Matcher6 m6, Matcher7 m7) {
995 return AnyOf(m1, AnyOf(m2, m3, m4, m5, m6, m7));
996}
997
998template <typename Matcher1, typename Matcher2, typename Matcher3,
999 typename Matcher4, typename Matcher5, typename Matcher6, typename Matcher7,
1000 typename Matcher8>
1001inline internal::EitherOfMatcher<Matcher1, internal::EitherOfMatcher<Matcher2,
1002 internal::EitherOfMatcher<Matcher3, internal::EitherOfMatcher<Matcher4,
1003 internal::EitherOfMatcher<Matcher5, internal::EitherOfMatcher<Matcher6,
1004 internal::EitherOfMatcher<Matcher7, Matcher8> > > > > > >
1005AnyOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
1006 Matcher6 m6, Matcher7 m7, Matcher8 m8) {
1007 return AnyOf(m1, AnyOf(m2, m3, m4, m5, m6, m7, m8));
1008}
1009
1010template <typename Matcher1, typename Matcher2, typename Matcher3,
1011 typename Matcher4, typename Matcher5, typename Matcher6, typename Matcher7,
1012 typename Matcher8, typename Matcher9>
1013inline internal::EitherOfMatcher<Matcher1, internal::EitherOfMatcher<Matcher2,
1014 internal::EitherOfMatcher<Matcher3, internal::EitherOfMatcher<Matcher4,
1015 internal::EitherOfMatcher<Matcher5, internal::EitherOfMatcher<Matcher6,
1016 internal::EitherOfMatcher<Matcher7, internal::EitherOfMatcher<Matcher8,
1017 Matcher9> > > > > > > >
1018AnyOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
1019 Matcher6 m6, Matcher7 m7, Matcher8 m8, Matcher9 m9) {
1020 return AnyOf(m1, AnyOf(m2, m3, m4, m5, m6, m7, m8, m9));
1021}
1022
1023template <typename Matcher1, typename Matcher2, typename Matcher3,
1024 typename Matcher4, typename Matcher5, typename Matcher6, typename Matcher7,
1025 typename Matcher8, typename Matcher9, typename Matcher10>
1026inline internal::EitherOfMatcher<Matcher1, internal::EitherOfMatcher<Matcher2,
1027 internal::EitherOfMatcher<Matcher3, internal::EitherOfMatcher<Matcher4,
1028 internal::EitherOfMatcher<Matcher5, internal::EitherOfMatcher<Matcher6,
1029 internal::EitherOfMatcher<Matcher7, internal::EitherOfMatcher<Matcher8,
1030 internal::EitherOfMatcher<Matcher9, Matcher10> > > > > > > > >
1031AnyOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
1032 Matcher6 m6, Matcher7 m7, Matcher8 m8, Matcher9 m9, Matcher10 m10) {
1033 return AnyOf(m1, AnyOf(m2, m3, m4, m5, m6, m7, m8, m9, m10));
1034}
1035
shiqiane35fdd92008-12-10 05:08:54 +00001036} // namespace testing
1037
zhanyong.wance198ff2009-02-12 01:34:27 +00001038// The MATCHER* family of macros can be used in a namespace scope to
zhanyong.wan82113312010-01-08 21:55:40 +00001039// define custom matchers easily.
1040//
1041// Basic Usage
1042// ===========
1043//
1044// The syntax
zhanyong.wance198ff2009-02-12 01:34:27 +00001045//
1046// MATCHER(name, description_string) { statements; }
1047//
zhanyong.wan82113312010-01-08 21:55:40 +00001048// defines a matcher with the given name that executes the statements,
1049// which must return a bool to indicate if the match succeeds. Inside
1050// the statements, you can refer to the value being matched by 'arg',
1051// and refer to its type by 'arg_type'.
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001052//
1053// The description string documents what the matcher does, and is used
1054// to generate the failure message when the match fails. Since a
1055// MATCHER() is usually defined in a header file shared by multiple
1056// C++ source files, we require the description to be a C-string
1057// literal to avoid possible side effects. It can be empty, in which
1058// case we'll use the sequence of words in the matcher name as the
1059// description.
1060//
1061// For example:
zhanyong.wance198ff2009-02-12 01:34:27 +00001062//
1063// MATCHER(IsEven, "") { return (arg % 2) == 0; }
1064//
1065// allows you to write
1066//
1067// // Expects mock_foo.Bar(n) to be called where n is even.
1068// EXPECT_CALL(mock_foo, Bar(IsEven()));
1069//
1070// or,
1071//
1072// // Verifies that the value of some_expression is even.
1073// EXPECT_THAT(some_expression, IsEven());
1074//
1075// If the above assertion fails, it will print something like:
1076//
1077// Value of: some_expression
1078// Expected: is even
1079// Actual: 7
1080//
1081// where the description "is even" is automatically calculated from the
1082// matcher name IsEven.
1083//
zhanyong.wan82113312010-01-08 21:55:40 +00001084// Argument Type
1085// =============
1086//
zhanyong.wance198ff2009-02-12 01:34:27 +00001087// Note that the type of the value being matched (arg_type) is
1088// determined by the context in which you use the matcher and is
1089// supplied to you by the compiler, so you don't need to worry about
1090// declaring it (nor can you). This allows the matcher to be
1091// polymorphic. For example, IsEven() can be used to match any type
1092// where the value of "(arg % 2) == 0" can be implicitly converted to
1093// a bool. In the "Bar(IsEven())" example above, if method Bar()
1094// takes an int, 'arg_type' will be int; if it takes an unsigned long,
1095// 'arg_type' will be unsigned long; and so on.
1096//
zhanyong.wan82113312010-01-08 21:55:40 +00001097// Parameterizing Matchers
1098// =======================
1099//
zhanyong.wance198ff2009-02-12 01:34:27 +00001100// Sometimes you'll want to parameterize the matcher. For that you
1101// can use another macro:
1102//
1103// MATCHER_P(name, param_name, description_string) { statements; }
1104//
1105// For example:
1106//
1107// MATCHER_P(HasAbsoluteValue, value, "") { return abs(arg) == value; }
1108//
1109// will allow you to write:
1110//
1111// EXPECT_THAT(Blah("a"), HasAbsoluteValue(n));
1112//
1113// which may lead to this message (assuming n is 10):
1114//
1115// Value of: Blah("a")
1116// Expected: has absolute value 10
1117// Actual: -9
1118//
1119// Note that both the matcher description and its parameter are
1120// printed, making the message human-friendly.
1121//
1122// In the matcher definition body, you can write 'foo_type' to
1123// reference the type of a parameter named 'foo'. For example, in the
1124// body of MATCHER_P(HasAbsoluteValue, value) above, you can write
1125// 'value_type' to refer to the type of 'value'.
1126//
1127// We also provide MATCHER_P2, MATCHER_P3, ..., up to MATCHER_P10 to
1128// support multi-parameter matchers.
1129//
zhanyong.wan82113312010-01-08 21:55:40 +00001130// Describing Parameterized Matchers
1131// =================================
1132//
zhanyong.wanb4140802010-06-08 22:53:57 +00001133// The last argument to MATCHER*() is a string-typed expression. The
1134// expression can reference all of the matcher's parameters and a
1135// special bool-typed variable named 'negation'. When 'negation' is
1136// false, the expression should evaluate to the matcher's description;
1137// otherwise it should evaluate to the description of the negation of
1138// the matcher. For example,
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001139//
zhanyong.wanb4140802010-06-08 22:53:57 +00001140// using testing::PrintToString;
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001141//
zhanyong.wanb4140802010-06-08 22:53:57 +00001142// MATCHER_P2(InClosedRange, low, hi,
1143// string(negation ? "is not" : "is") + " in range [" +
1144// PrintToString(low) + ", " + PrintToString(hi) + "]") {
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001145// return low <= arg && arg <= hi;
1146// }
1147// ...
1148// EXPECT_THAT(3, InClosedRange(4, 6));
zhanyong.wanb4140802010-06-08 22:53:57 +00001149// EXPECT_THAT(3, Not(InClosedRange(2, 4)));
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001150//
zhanyong.wanb4140802010-06-08 22:53:57 +00001151// would generate two failures that contain the text:
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001152//
1153// Expected: is in range [4, 6]
zhanyong.wanb4140802010-06-08 22:53:57 +00001154// ...
1155// Expected: is not in range [2, 4]
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001156//
1157// If you specify "" as the description, the failure message will
1158// contain the sequence of words in the matcher name followed by the
1159// parameter values printed as a tuple. For example,
1160//
1161// MATCHER_P2(InClosedRange, low, hi, "") { ... }
1162// ...
1163// EXPECT_THAT(3, InClosedRange(4, 6));
zhanyong.wanb4140802010-06-08 22:53:57 +00001164// EXPECT_THAT(3, Not(InClosedRange(2, 4)));
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001165//
zhanyong.wanb4140802010-06-08 22:53:57 +00001166// would generate two failures that contain the text:
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001167//
1168// Expected: in closed range (4, 6)
zhanyong.wanb4140802010-06-08 22:53:57 +00001169// ...
1170// Expected: not (in closed range (2, 4))
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001171//
zhanyong.wan82113312010-01-08 21:55:40 +00001172// Types of Matcher Parameters
1173// ===========================
1174//
zhanyong.wance198ff2009-02-12 01:34:27 +00001175// For the purpose of typing, you can view
1176//
1177// MATCHER_Pk(Foo, p1, ..., pk, description_string) { ... }
1178//
1179// as shorthand for
1180//
1181// template <typename p1_type, ..., typename pk_type>
1182// FooMatcherPk<p1_type, ..., pk_type>
1183// Foo(p1_type p1, ..., pk_type pk) { ... }
1184//
1185// When you write Foo(v1, ..., vk), the compiler infers the types of
1186// the parameters v1, ..., and vk for you. If you are not happy with
1187// the result of the type inference, you can specify the types by
1188// explicitly instantiating the template, as in Foo<long, bool>(5,
1189// false). As said earlier, you don't get to (or need to) specify
1190// 'arg_type' as that's determined by the context in which the matcher
1191// is used. You can assign the result of expression Foo(p1, ..., pk)
1192// to a variable of type FooMatcherPk<p1_type, ..., pk_type>. This
1193// can be useful when composing matchers.
1194//
1195// While you can instantiate a matcher template with reference types,
1196// passing the parameters by pointer usually makes your code more
1197// readable. If, however, you still want to pass a parameter by
1198// reference, be aware that in the failure message generated by the
1199// matcher you will see the value of the referenced object but not its
1200// address.
1201//
zhanyong.wan82113312010-01-08 21:55:40 +00001202// Explaining Match Results
1203// ========================
1204//
1205// Sometimes the matcher description alone isn't enough to explain why
1206// the match has failed or succeeded. For example, when expecting a
1207// long string, it can be very helpful to also print the diff between
1208// the expected string and the actual one. To achieve that, you can
1209// optionally stream additional information to a special variable
1210// named result_listener, whose type is a pointer to class
1211// MatchResultListener:
1212//
1213// MATCHER_P(EqualsLongString, str, "") {
1214// if (arg == str) return true;
1215//
1216// *result_listener << "the difference: "
1217/// << DiffStrings(str, arg);
1218// return false;
1219// }
1220//
1221// Overloading Matchers
1222// ====================
1223//
zhanyong.wance198ff2009-02-12 01:34:27 +00001224// You can overload matchers with different numbers of parameters:
1225//
1226// MATCHER_P(Blah, a, description_string1) { ... }
1227// MATCHER_P2(Blah, a, b, description_string2) { ... }
1228//
zhanyong.wan82113312010-01-08 21:55:40 +00001229// Caveats
1230// =======
zhanyong.wance198ff2009-02-12 01:34:27 +00001231//
zhanyong.wan82113312010-01-08 21:55:40 +00001232// When defining a new matcher, you should also consider implementing
1233// MatcherInterface or using MakePolymorphicMatcher(). These
1234// approaches require more work than the MATCHER* macros, but also
1235// give you more control on the types of the value being matched and
1236// the matcher parameters, which may leads to better compiler error
1237// messages when the matcher is used wrong. They also allow
1238// overloading matchers based on parameter types (as opposed to just
1239// based on the number of parameters).
zhanyong.wance198ff2009-02-12 01:34:27 +00001240//
1241// MATCHER*() can only be used in a namespace scope. The reason is
1242// that C++ doesn't yet allow function-local types to be used to
1243// instantiate templates. The up-coming C++0x standard will fix this.
1244// Once that's done, we'll consider supporting using MATCHER*() inside
1245// a function.
1246//
zhanyong.wan82113312010-01-08 21:55:40 +00001247// More Information
1248// ================
zhanyong.wance198ff2009-02-12 01:34:27 +00001249//
1250// To learn more about using these macros, please search for 'MATCHER'
1251// on http://code.google.com/p/googlemock/wiki/CookBook.
1252
1253#define MATCHER(name, description)\
1254 class name##Matcher {\
1255 public:\
1256 template <typename arg_type>\
1257 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1258 public:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001259 gmock_Impl()\
1260 {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001261 virtual bool MatchAndExplain(\
1262 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001263 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001264 *gmock_os << FormatDescription(false);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001265 }\
zhanyong.wanb4140802010-06-08 22:53:57 +00001266 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1267 *gmock_os << FormatDescription(true);\
1268 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001269 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001270 ::testing::internal::string FormatDescription(bool negation) const {\
1271 const ::testing::internal::string gmock_description = (description);\
1272 if (!gmock_description.empty())\
1273 return gmock_description;\
1274 return ::testing::internal::FormatMatcherDescription(\
1275 negation, #name,\
1276 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1277 ::std::tr1::tuple<>()));\
1278 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001279 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001280 };\
1281 template <typename arg_type>\
1282 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001283 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001284 new gmock_Impl<arg_type>());\
zhanyong.wance198ff2009-02-12 01:34:27 +00001285 }\
1286 name##Matcher() {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001287 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001288 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001289 GTEST_DISALLOW_ASSIGN_(name##Matcher);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001290 };\
1291 inline name##Matcher name() {\
1292 return name##Matcher();\
1293 }\
1294 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001295 bool name##Matcher::gmock_Impl<arg_type>::MatchAndExplain(\
1296 arg_type arg,\
1297 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1298 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001299
1300#define MATCHER_P(name, p0, description)\
1301 template <typename p0##_type>\
1302 class name##MatcherP {\
1303 public:\
1304 template <typename arg_type>\
1305 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1306 public:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001307 explicit gmock_Impl(p0##_type gmock_p0)\
1308 : p0(gmock_p0) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001309 virtual bool MatchAndExplain(\
1310 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001311 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001312 *gmock_os << FormatDescription(false);\
1313 }\
1314 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1315 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001316 }\
1317 p0##_type p0;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001318 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001319 ::testing::internal::string FormatDescription(bool negation) const {\
1320 const ::testing::internal::string gmock_description = (description);\
1321 if (!gmock_description.empty())\
1322 return gmock_description;\
1323 return ::testing::internal::FormatMatcherDescription(\
1324 negation, #name,\
1325 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1326 ::std::tr1::tuple<p0##_type>(p0)));\
1327 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001328 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001329 };\
1330 template <typename arg_type>\
1331 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001332 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001333 new gmock_Impl<arg_type>(p0));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001334 }\
1335 name##MatcherP(p0##_type gmock_p0) : p0(gmock_p0) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001336 }\
1337 p0##_type p0;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001338 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001339 GTEST_DISALLOW_ASSIGN_(name##MatcherP);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001340 };\
1341 template <typename p0##_type>\
1342 inline name##MatcherP<p0##_type> name(p0##_type p0) {\
1343 return name##MatcherP<p0##_type>(p0);\
1344 }\
1345 template <typename p0##_type>\
1346 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001347 bool name##MatcherP<p0##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1348 arg_type arg,\
1349 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1350 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001351
1352#define MATCHER_P2(name, p0, p1, description)\
1353 template <typename p0##_type, typename p1##_type>\
1354 class name##MatcherP2 {\
1355 public:\
1356 template <typename arg_type>\
1357 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1358 public:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001359 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1)\
1360 : p0(gmock_p0), p1(gmock_p1) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001361 virtual bool MatchAndExplain(\
1362 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001363 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001364 *gmock_os << FormatDescription(false);\
1365 }\
1366 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1367 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001368 }\
1369 p0##_type p0;\
1370 p1##_type p1;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001371 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001372 ::testing::internal::string FormatDescription(bool negation) const {\
1373 const ::testing::internal::string gmock_description = (description);\
1374 if (!gmock_description.empty())\
1375 return gmock_description;\
1376 return ::testing::internal::FormatMatcherDescription(\
1377 negation, #name,\
1378 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1379 ::std::tr1::tuple<p0##_type, p1##_type>(p0, p1)));\
1380 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001381 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001382 };\
1383 template <typename arg_type>\
1384 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001385 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001386 new gmock_Impl<arg_type>(p0, p1));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001387 }\
1388 name##MatcherP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
1389 p1(gmock_p1) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001390 }\
1391 p0##_type p0;\
1392 p1##_type p1;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001393 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001394 GTEST_DISALLOW_ASSIGN_(name##MatcherP2);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001395 };\
1396 template <typename p0##_type, typename p1##_type>\
1397 inline name##MatcherP2<p0##_type, p1##_type> name(p0##_type p0, \
1398 p1##_type p1) {\
1399 return name##MatcherP2<p0##_type, p1##_type>(p0, p1);\
1400 }\
1401 template <typename p0##_type, typename p1##_type>\
1402 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001403 bool name##MatcherP2<p0##_type, \
1404 p1##_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_P3(name, p0, p1, p2, description)\
1410 template <typename p0##_type, typename p1##_type, typename p2##_type>\
1411 class name##MatcherP3 {\
1412 public:\
1413 template <typename arg_type>\
1414 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1415 public:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001416 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2)\
1417 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001418 virtual bool MatchAndExplain(\
1419 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001420 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001421 *gmock_os << FormatDescription(false);\
1422 }\
1423 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1424 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001425 }\
1426 p0##_type p0;\
1427 p1##_type p1;\
1428 p2##_type p2;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001429 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001430 ::testing::internal::string FormatDescription(bool negation) const {\
1431 const ::testing::internal::string gmock_description = (description);\
1432 if (!gmock_description.empty())\
1433 return gmock_description;\
1434 return ::testing::internal::FormatMatcherDescription(\
1435 negation, #name,\
1436 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1437 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type>(p0, p1, \
1438 p2)));\
1439 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001440 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>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001445 new gmock_Impl<arg_type>(p0, p1, p2));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001446 }\
1447 name##MatcherP3(p0##_type gmock_p0, p1##_type gmock_p1, \
1448 p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001449 }\
1450 p0##_type p0;\
1451 p1##_type p1;\
1452 p2##_type p2;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001453 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001454 GTEST_DISALLOW_ASSIGN_(name##MatcherP3);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001455 };\
1456 template <typename p0##_type, typename p1##_type, typename p2##_type>\
1457 inline name##MatcherP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0, \
1458 p1##_type p1, p2##_type p2) {\
1459 return name##MatcherP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\
1460 }\
1461 template <typename p0##_type, typename p1##_type, typename p2##_type>\
1462 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001463 bool name##MatcherP3<p0##_type, p1##_type, \
1464 p2##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1465 arg_type arg,\
1466 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1467 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001468
1469#define MATCHER_P4(name, p0, p1, p2, p3, description)\
1470 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1471 typename p3##_type>\
1472 class name##MatcherP4 {\
1473 public:\
1474 template <typename arg_type>\
1475 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1476 public:\
1477 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001478 p3##_type gmock_p3)\
1479 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001480 virtual bool MatchAndExplain(\
1481 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001482 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001483 *gmock_os << FormatDescription(false);\
1484 }\
1485 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1486 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001487 }\
1488 p0##_type p0;\
1489 p1##_type p1;\
1490 p2##_type p2;\
1491 p3##_type p3;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001492 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001493 ::testing::internal::string FormatDescription(bool negation) const {\
1494 const ::testing::internal::string gmock_description = (description);\
1495 if (!gmock_description.empty())\
1496 return gmock_description;\
1497 return ::testing::internal::FormatMatcherDescription(\
1498 negation, #name,\
1499 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1500 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, \
1501 p3##_type>(p0, p1, p2, p3)));\
1502 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001503 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001504 };\
1505 template <typename arg_type>\
1506 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001507 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001508 new gmock_Impl<arg_type>(p0, p1, p2, p3));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001509 }\
1510 name##MatcherP4(p0##_type gmock_p0, p1##_type gmock_p1, \
1511 p2##_type gmock_p2, p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), \
1512 p2(gmock_p2), p3(gmock_p3) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001513 }\
1514 p0##_type p0;\
1515 p1##_type p1;\
1516 p2##_type p2;\
1517 p3##_type p3;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001518 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001519 GTEST_DISALLOW_ASSIGN_(name##MatcherP4);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001520 };\
1521 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1522 typename p3##_type>\
1523 inline name##MatcherP4<p0##_type, p1##_type, p2##_type, \
1524 p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
1525 p3##_type p3) {\
1526 return name##MatcherP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, \
1527 p1, p2, p3);\
1528 }\
1529 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1530 typename p3##_type>\
1531 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001532 bool name##MatcherP4<p0##_type, p1##_type, p2##_type, \
1533 p3##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1534 arg_type arg,\
1535 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1536 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001537
1538#define MATCHER_P5(name, p0, p1, p2, p3, p4, description)\
1539 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1540 typename p3##_type, typename p4##_type>\
1541 class name##MatcherP5 {\
1542 public:\
1543 template <typename arg_type>\
1544 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1545 public:\
1546 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001547 p3##_type gmock_p3, p4##_type gmock_p4)\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001548 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
zhanyong.wanb4140802010-06-08 22:53:57 +00001549 p4(gmock_p4) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001550 virtual bool MatchAndExplain(\
1551 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001552 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001553 *gmock_os << FormatDescription(false);\
1554 }\
1555 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1556 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001557 }\
1558 p0##_type p0;\
1559 p1##_type p1;\
1560 p2##_type p2;\
1561 p3##_type p3;\
1562 p4##_type p4;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001563 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001564 ::testing::internal::string FormatDescription(bool negation) const {\
1565 const ::testing::internal::string gmock_description = (description);\
1566 if (!gmock_description.empty())\
1567 return gmock_description;\
1568 return ::testing::internal::FormatMatcherDescription(\
1569 negation, #name,\
1570 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1571 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1572 p4##_type>(p0, p1, p2, p3, p4)));\
1573 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001574 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001575 };\
1576 template <typename arg_type>\
1577 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001578 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001579 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001580 }\
1581 name##MatcherP5(p0##_type gmock_p0, p1##_type gmock_p1, \
1582 p2##_type gmock_p2, p3##_type gmock_p3, \
1583 p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1584 p3(gmock_p3), p4(gmock_p4) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001585 }\
1586 p0##_type p0;\
1587 p1##_type p1;\
1588 p2##_type p2;\
1589 p3##_type p3;\
1590 p4##_type p4;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001591 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001592 GTEST_DISALLOW_ASSIGN_(name##MatcherP5);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001593 };\
1594 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1595 typename p3##_type, typename p4##_type>\
1596 inline name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1597 p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
1598 p4##_type p4) {\
1599 return name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1600 p4##_type>(p0, p1, p2, p3, p4);\
1601 }\
1602 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1603 typename p3##_type, typename p4##_type>\
1604 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001605 bool name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1606 p4##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1607 arg_type arg,\
1608 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1609 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001610
1611#define MATCHER_P6(name, p0, p1, p2, p3, p4, p5, description)\
1612 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1613 typename p3##_type, typename p4##_type, typename p5##_type>\
1614 class name##MatcherP6 {\
1615 public:\
1616 template <typename arg_type>\
1617 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1618 public:\
1619 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001620 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5)\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001621 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
zhanyong.wanb4140802010-06-08 22:53:57 +00001622 p4(gmock_p4), p5(gmock_p5) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001623 virtual bool MatchAndExplain(\
1624 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001625 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001626 *gmock_os << FormatDescription(false);\
1627 }\
1628 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1629 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001630 }\
1631 p0##_type p0;\
1632 p1##_type p1;\
1633 p2##_type p2;\
1634 p3##_type p3;\
1635 p4##_type p4;\
1636 p5##_type p5;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001637 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001638 ::testing::internal::string FormatDescription(bool negation) const {\
1639 const ::testing::internal::string gmock_description = (description);\
1640 if (!gmock_description.empty())\
1641 return gmock_description;\
1642 return ::testing::internal::FormatMatcherDescription(\
1643 negation, #name,\
1644 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1645 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1646 p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5)));\
1647 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001648 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001649 };\
1650 template <typename arg_type>\
1651 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001652 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001653 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001654 }\
1655 name##MatcherP6(p0##_type gmock_p0, p1##_type gmock_p1, \
1656 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1657 p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1658 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001659 }\
1660 p0##_type p0;\
1661 p1##_type p1;\
1662 p2##_type p2;\
1663 p3##_type p3;\
1664 p4##_type p4;\
1665 p5##_type p5;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001666 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001667 GTEST_DISALLOW_ASSIGN_(name##MatcherP6);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001668 };\
1669 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1670 typename p3##_type, typename p4##_type, typename p5##_type>\
1671 inline name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
1672 p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
1673 p3##_type p3, p4##_type p4, p5##_type p5) {\
1674 return name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
1675 p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\
1676 }\
1677 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1678 typename p3##_type, typename p4##_type, typename p5##_type>\
1679 template <typename arg_type>\
1680 bool name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00001681 p5##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1682 arg_type arg,\
1683 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1684 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001685
1686#define MATCHER_P7(name, p0, p1, p2, p3, p4, p5, p6, description)\
1687 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1688 typename p3##_type, typename p4##_type, typename p5##_type, \
1689 typename p6##_type>\
1690 class name##MatcherP7 {\
1691 public:\
1692 template <typename arg_type>\
1693 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1694 public:\
1695 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1696 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001697 p6##_type gmock_p6)\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001698 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
zhanyong.wanb4140802010-06-08 22:53:57 +00001699 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001700 virtual bool MatchAndExplain(\
1701 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001702 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001703 *gmock_os << FormatDescription(false);\
1704 }\
1705 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1706 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001707 }\
1708 p0##_type p0;\
1709 p1##_type p1;\
1710 p2##_type p2;\
1711 p3##_type p3;\
1712 p4##_type p4;\
1713 p5##_type p5;\
1714 p6##_type p6;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001715 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001716 ::testing::internal::string FormatDescription(bool negation) const {\
1717 const ::testing::internal::string gmock_description = (description);\
1718 if (!gmock_description.empty())\
1719 return gmock_description;\
1720 return ::testing::internal::FormatMatcherDescription(\
1721 negation, #name,\
1722 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1723 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1724 p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, \
1725 p6)));\
1726 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001727 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001728 };\
1729 template <typename arg_type>\
1730 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001731 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001732 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001733 }\
1734 name##MatcherP7(p0##_type gmock_p0, p1##_type gmock_p1, \
1735 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1736 p5##_type gmock_p5, p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), \
1737 p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), \
1738 p6(gmock_p6) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001739 }\
1740 p0##_type p0;\
1741 p1##_type p1;\
1742 p2##_type p2;\
1743 p3##_type p3;\
1744 p4##_type p4;\
1745 p5##_type p5;\
1746 p6##_type p6;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001747 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001748 GTEST_DISALLOW_ASSIGN_(name##MatcherP7);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001749 };\
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>\
1753 inline name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
1754 p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \
1755 p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
1756 p6##_type p6) {\
1757 return name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
1758 p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\
1759 }\
1760 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1761 typename p3##_type, typename p4##_type, typename p5##_type, \
1762 typename p6##_type>\
1763 template <typename arg_type>\
1764 bool name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00001765 p5##_type, p6##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1766 arg_type arg,\
1767 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1768 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001769
1770#define MATCHER_P8(name, p0, p1, p2, p3, p4, p5, p6, p7, description)\
1771 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1772 typename p3##_type, typename p4##_type, typename p5##_type, \
1773 typename p6##_type, typename p7##_type>\
1774 class name##MatcherP8 {\
1775 public:\
1776 template <typename arg_type>\
1777 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1778 public:\
1779 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1780 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001781 p6##_type gmock_p6, p7##_type gmock_p7)\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001782 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
zhanyong.wanb4140802010-06-08 22:53:57 +00001783 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001784 virtual bool MatchAndExplain(\
1785 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001786 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001787 *gmock_os << FormatDescription(false);\
1788 }\
1789 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1790 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001791 }\
1792 p0##_type p0;\
1793 p1##_type p1;\
1794 p2##_type p2;\
1795 p3##_type p3;\
1796 p4##_type p4;\
1797 p5##_type p5;\
1798 p6##_type p6;\
1799 p7##_type p7;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001800 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001801 ::testing::internal::string FormatDescription(bool negation) const {\
1802 const ::testing::internal::string gmock_description = (description);\
1803 if (!gmock_description.empty())\
1804 return gmock_description;\
1805 return ::testing::internal::FormatMatcherDescription(\
1806 negation, #name,\
1807 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1808 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1809 p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, \
1810 p3, p4, p5, p6, p7)));\
1811 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001812 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001813 };\
1814 template <typename arg_type>\
1815 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001816 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001817 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001818 }\
1819 name##MatcherP8(p0##_type gmock_p0, p1##_type gmock_p1, \
1820 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1821 p5##_type gmock_p5, p6##_type gmock_p6, \
1822 p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1823 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
1824 p7(gmock_p7) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001825 }\
1826 p0##_type p0;\
1827 p1##_type p1;\
1828 p2##_type p2;\
1829 p3##_type p3;\
1830 p4##_type p4;\
1831 p5##_type p5;\
1832 p6##_type p6;\
1833 p7##_type p7;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001834 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001835 GTEST_DISALLOW_ASSIGN_(name##MatcherP8);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001836 };\
1837 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1838 typename p3##_type, typename p4##_type, typename p5##_type, \
1839 typename p6##_type, typename p7##_type>\
1840 inline name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
1841 p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \
1842 p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
1843 p6##_type p6, p7##_type p7) {\
1844 return name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
1845 p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5, \
1846 p6, p7);\
1847 }\
1848 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1849 typename p3##_type, typename p4##_type, typename p5##_type, \
1850 typename p6##_type, typename p7##_type>\
1851 template <typename arg_type>\
1852 bool name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00001853 p5##_type, p6##_type, \
1854 p7##_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
1859#define MATCHER_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, description)\
1860 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1861 typename p3##_type, typename p4##_type, typename p5##_type, \
1862 typename p6##_type, typename p7##_type, typename p8##_type>\
1863 class name##MatcherP9 {\
1864 public:\
1865 template <typename arg_type>\
1866 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1867 public:\
1868 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1869 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001870 p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8)\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001871 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1872 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
zhanyong.wanb4140802010-06-08 22:53:57 +00001873 p8(gmock_p8) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001874 virtual bool MatchAndExplain(\
1875 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001876 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001877 *gmock_os << FormatDescription(false);\
1878 }\
1879 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1880 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001881 }\
1882 p0##_type p0;\
1883 p1##_type p1;\
1884 p2##_type p2;\
1885 p3##_type p3;\
1886 p4##_type p4;\
1887 p5##_type p5;\
1888 p6##_type p6;\
1889 p7##_type p7;\
1890 p8##_type p8;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001891 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001892 ::testing::internal::string FormatDescription(bool negation) const {\
1893 const ::testing::internal::string gmock_description = (description);\
1894 if (!gmock_description.empty())\
1895 return gmock_description;\
1896 return ::testing::internal::FormatMatcherDescription(\
1897 negation, #name,\
1898 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1899 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1900 p4##_type, p5##_type, p6##_type, p7##_type, \
1901 p8##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8)));\
1902 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001903 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001904 };\
1905 template <typename arg_type>\
1906 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001907 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001908 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001909 }\
1910 name##MatcherP9(p0##_type gmock_p0, p1##_type gmock_p1, \
1911 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1912 p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
1913 p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1914 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
1915 p8(gmock_p8) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001916 }\
1917 p0##_type p0;\
1918 p1##_type p1;\
1919 p2##_type p2;\
1920 p3##_type p3;\
1921 p4##_type p4;\
1922 p5##_type p5;\
1923 p6##_type p6;\
1924 p7##_type p7;\
1925 p8##_type p8;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001926 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001927 GTEST_DISALLOW_ASSIGN_(name##MatcherP9);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001928 };\
1929 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1930 typename p3##_type, typename p4##_type, typename p5##_type, \
1931 typename p6##_type, typename p7##_type, typename p8##_type>\
1932 inline name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \
1933 p4##_type, p5##_type, p6##_type, p7##_type, \
1934 p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
1935 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \
1936 p8##_type p8) {\
1937 return name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \
1938 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type>(p0, p1, p2, \
1939 p3, p4, p5, p6, p7, p8);\
1940 }\
1941 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1942 typename p3##_type, typename p4##_type, typename p5##_type, \
1943 typename p6##_type, typename p7##_type, typename p8##_type>\
1944 template <typename arg_type>\
1945 bool name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00001946 p5##_type, p6##_type, p7##_type, \
1947 p8##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1948 arg_type arg,\
1949 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1950 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001951
1952#define MATCHER_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, description)\
1953 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1954 typename p3##_type, typename p4##_type, typename p5##_type, \
1955 typename p6##_type, typename p7##_type, typename p8##_type, \
1956 typename p9##_type>\
1957 class name##MatcherP10 {\
1958 public:\
1959 template <typename arg_type>\
1960 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1961 public:\
1962 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1963 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
1964 p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001965 p9##_type gmock_p9)\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001966 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1967 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
zhanyong.wanb4140802010-06-08 22:53:57 +00001968 p8(gmock_p8), p9(gmock_p9) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001969 virtual bool MatchAndExplain(\
1970 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001971 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001972 *gmock_os << FormatDescription(false);\
1973 }\
1974 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1975 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001976 }\
1977 p0##_type p0;\
1978 p1##_type p1;\
1979 p2##_type p2;\
1980 p3##_type p3;\
1981 p4##_type p4;\
1982 p5##_type p5;\
1983 p6##_type p6;\
1984 p7##_type p7;\
1985 p8##_type p8;\
1986 p9##_type p9;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001987 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001988 ::testing::internal::string FormatDescription(bool negation) const {\
1989 const ::testing::internal::string gmock_description = (description);\
1990 if (!gmock_description.empty())\
1991 return gmock_description;\
1992 return ::testing::internal::FormatMatcherDescription(\
1993 negation, #name,\
1994 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1995 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1996 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
1997 p9##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)));\
1998 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001999 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00002000 };\
2001 template <typename arg_type>\
2002 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00002003 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00002004 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9));\
zhanyong.wance198ff2009-02-12 01:34:27 +00002005 }\
2006 name##MatcherP10(p0##_type gmock_p0, p1##_type gmock_p1, \
2007 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
2008 p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
2009 p8##_type gmock_p8, p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), \
2010 p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
2011 p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00002012 }\
2013 p0##_type p0;\
2014 p1##_type p1;\
2015 p2##_type p2;\
2016 p3##_type p3;\
2017 p4##_type p4;\
2018 p5##_type p5;\
2019 p6##_type p6;\
2020 p7##_type p7;\
2021 p8##_type p8;\
2022 p9##_type p9;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002023 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002024 GTEST_DISALLOW_ASSIGN_(name##MatcherP10);\
zhanyong.wance198ff2009-02-12 01:34:27 +00002025 };\
2026 template <typename p0##_type, typename p1##_type, typename p2##_type, \
2027 typename p3##_type, typename p4##_type, typename p5##_type, \
2028 typename p6##_type, typename p7##_type, typename p8##_type, \
2029 typename p9##_type>\
2030 inline name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
2031 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
2032 p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
2033 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
2034 p9##_type p9) {\
2035 return name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
2036 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>(p0, \
2037 p1, p2, p3, p4, p5, p6, p7, p8, p9);\
2038 }\
2039 template <typename p0##_type, typename p1##_type, typename p2##_type, \
2040 typename p3##_type, typename p4##_type, typename p5##_type, \
2041 typename p6##_type, typename p7##_type, typename p8##_type, \
2042 typename p9##_type>\
2043 template <typename arg_type>\
2044 bool name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00002045 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
2046 p9##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
2047 arg_type arg,\
2048 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
2049 const
zhanyong.wance198ff2009-02-12 01:34:27 +00002050
shiqiane35fdd92008-12-10 05:08:54 +00002051#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_