blob: bc3f610cefd598928ac418802de7fefa538f9dad [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
jgm38513a82012-11-15 15:50:36 +000041#include <iterator>
shiqiane35fdd92008-12-10 05:08:54 +000042#include <sstream>
43#include <string>
44#include <vector>
zhanyong.wan53e08c42010-09-14 05:38:21 +000045#include "gmock/gmock-matchers.h"
shiqiane35fdd92008-12-10 05:08:54 +000046
47namespace testing {
48namespace internal {
49
zhanyong.wan2661c682009-06-09 05:42:12 +000050// The type of the i-th (0-based) field of Tuple.
51#define GMOCK_FIELD_TYPE_(Tuple, i) \
52 typename ::std::tr1::tuple_element<i, Tuple>::type
53
54// TupleFields<Tuple, k0, ..., kn> is for selecting fields from a
55// tuple of type Tuple. It has two members:
56//
57// type: a tuple type whose i-th field is the ki-th field of Tuple.
58// GetSelectedFields(t): returns fields k0, ..., and kn of t as a tuple.
59//
60// For example, in class TupleFields<tuple<bool, char, int>, 2, 0>, we have:
61//
62// type is tuple<int, bool>, and
63// GetSelectedFields(make_tuple(true, 'a', 42)) is (42, true).
64
65template <class Tuple, int k0 = -1, int k1 = -1, int k2 = -1, int k3 = -1,
66 int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
67 int k9 = -1>
68class TupleFields;
69
70// This generic version is used when there are 10 selectors.
71template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
72 int k7, int k8, int k9>
73class TupleFields {
74 public:
75 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
76 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
77 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
78 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
79 GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8),
80 GMOCK_FIELD_TYPE_(Tuple, k9)> type;
81 static type GetSelectedFields(const Tuple& t) {
82 using ::std::tr1::get;
83 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
84 get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t), get<k9>(t));
85 }
86};
87
88// The following specialization is used for 0 ~ 9 selectors.
89
90template <class Tuple>
91class TupleFields<Tuple, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
92 public:
93 typedef ::std::tr1::tuple<> type;
zhanyong.wan32de5f52009-12-23 00:13:23 +000094 static type GetSelectedFields(const Tuple& /* t */) {
zhanyong.wan2661c682009-06-09 05:42:12 +000095 using ::std::tr1::get;
96 return type();
97 }
98};
99
100template <class Tuple, int k0>
101class TupleFields<Tuple, k0, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
102 public:
103 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0)> type;
104 static type GetSelectedFields(const Tuple& t) {
105 using ::std::tr1::get;
106 return type(get<k0>(t));
107 }
108};
109
110template <class Tuple, int k0, int k1>
111class TupleFields<Tuple, k0, k1, -1, -1, -1, -1, -1, -1, -1, -1> {
112 public:
113 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
114 GMOCK_FIELD_TYPE_(Tuple, k1)> type;
115 static type GetSelectedFields(const Tuple& t) {
116 using ::std::tr1::get;
117 return type(get<k0>(t), get<k1>(t));
118 }
119};
120
121template <class Tuple, int k0, int k1, int k2>
122class TupleFields<Tuple, k0, k1, k2, -1, -1, -1, -1, -1, -1, -1> {
123 public:
124 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
125 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2)> type;
126 static type GetSelectedFields(const Tuple& t) {
127 using ::std::tr1::get;
128 return type(get<k0>(t), get<k1>(t), get<k2>(t));
129 }
130};
131
132template <class Tuple, int k0, int k1, int k2, int k3>
133class TupleFields<Tuple, k0, k1, k2, k3, -1, -1, -1, -1, -1, -1> {
134 public:
135 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
136 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
137 GMOCK_FIELD_TYPE_(Tuple, k3)> type;
138 static type GetSelectedFields(const Tuple& t) {
139 using ::std::tr1::get;
140 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t));
141 }
142};
143
144template <class Tuple, int k0, int k1, int k2, int k3, int k4>
145class TupleFields<Tuple, k0, k1, k2, k3, k4, -1, -1, -1, -1, -1> {
146 public:
147 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
148 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
149 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4)> type;
150 static type GetSelectedFields(const Tuple& t) {
151 using ::std::tr1::get;
152 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t));
153 }
154};
155
156template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5>
157class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, -1, -1, -1, -1> {
158 public:
159 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
160 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
161 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
162 GMOCK_FIELD_TYPE_(Tuple, k5)> type;
163 static type GetSelectedFields(const Tuple& t) {
164 using ::std::tr1::get;
165 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
166 get<k5>(t));
167 }
168};
169
170template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6>
171class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, -1, -1, -1> {
172 public:
173 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
174 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
175 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
176 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6)> type;
177 static type GetSelectedFields(const Tuple& t) {
178 using ::std::tr1::get;
179 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
180 get<k5>(t), get<k6>(t));
181 }
182};
183
184template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
185 int k7>
186class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, -1, -1> {
187 public:
188 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
189 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
190 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
191 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
192 GMOCK_FIELD_TYPE_(Tuple, k7)> type;
193 static type GetSelectedFields(const Tuple& t) {
194 using ::std::tr1::get;
195 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
196 get<k5>(t), get<k6>(t), get<k7>(t));
197 }
198};
199
200template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
201 int k7, int k8>
202class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, k8, -1> {
203 public:
204 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
205 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
206 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
207 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
208 GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8)> type;
209 static type GetSelectedFields(const Tuple& t) {
210 using ::std::tr1::get;
211 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
212 get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t));
213 }
214};
215
216#undef GMOCK_FIELD_TYPE_
217
218// Implements the Args() matcher.
219template <class ArgsTuple, int k0 = -1, int k1 = -1, int k2 = -1, int k3 = -1,
220 int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
221 int k9 = -1>
222class ArgsMatcherImpl : public MatcherInterface<ArgsTuple> {
223 public:
224 // ArgsTuple may have top-level const or reference modifiers.
zhanyong.wanab5b77c2010-05-17 19:32:48 +0000225 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(ArgsTuple) RawArgsTuple;
zhanyong.wan2661c682009-06-09 05:42:12 +0000226 typedef typename internal::TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5,
227 k6, k7, k8, k9>::type SelectedArgs;
228 typedef Matcher<const SelectedArgs&> MonomorphicInnerMatcher;
229
230 template <typename InnerMatcher>
231 explicit ArgsMatcherImpl(const InnerMatcher& inner_matcher)
232 : inner_matcher_(SafeMatcherCast<const SelectedArgs&>(inner_matcher)) {}
233
zhanyong.wan82113312010-01-08 21:55:40 +0000234 virtual bool MatchAndExplain(ArgsTuple args,
235 MatchResultListener* listener) const {
zhanyong.wanb1c7f932010-03-24 17:35:11 +0000236 const SelectedArgs& selected_args = GetSelectedArgs(args);
237 if (!listener->IsInterested())
238 return inner_matcher_.Matches(selected_args);
239
240 PrintIndices(listener->stream());
241 *listener << "are " << PrintToString(selected_args);
242
243 StringMatchResultListener inner_listener;
244 const bool match = inner_matcher_.MatchAndExplain(selected_args,
245 &inner_listener);
246 PrintIfNotEmpty(inner_listener.str(), listener->stream());
247 return match;
zhanyong.wan2661c682009-06-09 05:42:12 +0000248 }
249
250 virtual void DescribeTo(::std::ostream* os) const {
zhanyong.wanb1c7f932010-03-24 17:35:11 +0000251 *os << "are a tuple ";
zhanyong.wan2661c682009-06-09 05:42:12 +0000252 PrintIndices(os);
253 inner_matcher_.DescribeTo(os);
254 }
255
256 virtual void DescribeNegationTo(::std::ostream* os) const {
zhanyong.wanb1c7f932010-03-24 17:35:11 +0000257 *os << "are a tuple ";
zhanyong.wan2661c682009-06-09 05:42:12 +0000258 PrintIndices(os);
259 inner_matcher_.DescribeNegationTo(os);
260 }
261
zhanyong.wan2661c682009-06-09 05:42:12 +0000262 private:
263 static SelectedArgs GetSelectedArgs(ArgsTuple args) {
264 return TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5, k6, k7, k8,
265 k9>::GetSelectedFields(args);
266 }
267
268 // Prints the indices of the selected fields.
269 static void PrintIndices(::std::ostream* os) {
zhanyong.wanb1c7f932010-03-24 17:35:11 +0000270 *os << "whose fields (";
zhanyong.wan2661c682009-06-09 05:42:12 +0000271 const int indices[10] = { k0, k1, k2, k3, k4, k5, k6, k7, k8, k9 };
272 for (int i = 0; i < 10; i++) {
273 if (indices[i] < 0)
274 break;
275
276 if (i >= 1)
277 *os << ", ";
278
279 *os << "#" << indices[i];
280 }
281 *os << ") ";
282 }
283
284 const MonomorphicInnerMatcher inner_matcher_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000285
286 GTEST_DISALLOW_ASSIGN_(ArgsMatcherImpl);
zhanyong.wan2661c682009-06-09 05:42:12 +0000287};
288
289template <class InnerMatcher, int k0 = -1, int k1 = -1, int k2 = -1,
290 int k3 = -1, int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1,
291 int k8 = -1, int k9 = -1>
292class ArgsMatcher {
293 public:
294 explicit ArgsMatcher(const InnerMatcher& inner_matcher)
295 : inner_matcher_(inner_matcher) {}
296
297 template <typename ArgsTuple>
298 operator Matcher<ArgsTuple>() const {
299 return MakeMatcher(new ArgsMatcherImpl<ArgsTuple, k0, k1, k2, k3, k4, k5,
300 k6, k7, k8, k9>(inner_matcher_));
301 }
302
zhanyong.wan32de5f52009-12-23 00:13:23 +0000303 private:
zhanyong.wan2661c682009-06-09 05:42:12 +0000304 const InnerMatcher inner_matcher_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000305
306 GTEST_DISALLOW_ASSIGN_(ArgsMatcher);
zhanyong.wan2661c682009-06-09 05:42:12 +0000307};
308
jgm38513a82012-11-15 15:50:36 +0000309// Implements ElementsAre() of 1-10 arguments. The use of DecayArray in
310// the implementation allows ElementsAre() to accept string literals, whose
311// inferred type is const char[N] while we want to treat them as const char*.
shiqiane35fdd92008-12-10 05:08:54 +0000312
313template <typename T1>
314class ElementsAreMatcher1 {
315 public:
316 explicit ElementsAreMatcher1(const T1& e1) : e1_(e1) {}
317
318 template <typename Container>
319 operator Matcher<Container>() const {
zhanyong.wanab5b77c2010-05-17 19:32:48 +0000320 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000321 typedef typename internal::StlContainerView<RawContainer>::type::value_type
322 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000323
zhanyong.wan95b12332009-09-25 18:55:50 +0000324 // Nokia's Symbian Compiler has a nasty bug where the object put
325 // in a one-element local array is not destructed when the array
326 // goes out of scope. This leads to obvious badness as we've
327 // added the linked_ptr in it to our other linked_ptrs list.
328 // Hence we implement ElementsAreMatcher1 specially to avoid using
329 // a local array.
330 const Matcher<const Element&> matcher =
331 MatcherCast<const Element&>(e1_);
jgm38513a82012-11-15 15:50:36 +0000332 return MakeMatcher(new ElementsAreMatcherImpl<Container>(&matcher,
333 &matcher + 1));
shiqiane35fdd92008-12-10 05:08:54 +0000334 }
335
336 private:
jgm38513a82012-11-15 15:50:36 +0000337 const typename DecayArray<T1>::type e1_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000338
339 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher1);
shiqiane35fdd92008-12-10 05:08:54 +0000340};
341
342template <typename T1, typename T2>
343class ElementsAreMatcher2 {
344 public:
345 ElementsAreMatcher2(const T1& e1, const T2& e2) : e1_(e1), e2_(e2) {}
346
347 template <typename Container>
348 operator Matcher<Container>() const {
zhanyong.wanab5b77c2010-05-17 19:32:48 +0000349 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000350 typedef typename internal::StlContainerView<RawContainer>::type::value_type
351 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000352
353 const Matcher<const Element&> matchers[] = {
354 MatcherCast<const Element&>(e1_),
355 MatcherCast<const Element&>(e2_),
356 };
357
jgm38513a82012-11-15 15:50:36 +0000358 return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers,
359 matchers + 2));
shiqiane35fdd92008-12-10 05:08:54 +0000360 }
361
362 private:
jgm38513a82012-11-15 15:50:36 +0000363 const typename DecayArray<T1>::type e1_;
364 const typename DecayArray<T2>::type e2_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000365
366 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher2);
shiqiane35fdd92008-12-10 05:08:54 +0000367};
368
369template <typename T1, typename T2, typename T3>
370class ElementsAreMatcher3 {
371 public:
372 ElementsAreMatcher3(const T1& e1, const T2& e2, const T3& e3) : e1_(e1),
373 e2_(e2), e3_(e3) {}
374
375 template <typename Container>
376 operator Matcher<Container>() const {
zhanyong.wanab5b77c2010-05-17 19:32:48 +0000377 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000378 typedef typename internal::StlContainerView<RawContainer>::type::value_type
379 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000380
381 const Matcher<const Element&> matchers[] = {
382 MatcherCast<const Element&>(e1_),
383 MatcherCast<const Element&>(e2_),
384 MatcherCast<const Element&>(e3_),
385 };
386
jgm38513a82012-11-15 15:50:36 +0000387 return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers,
388 matchers + 3));
shiqiane35fdd92008-12-10 05:08:54 +0000389 }
390
391 private:
jgm38513a82012-11-15 15:50:36 +0000392 const typename DecayArray<T1>::type e1_;
393 const typename DecayArray<T2>::type e2_;
394 const typename DecayArray<T3>::type e3_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000395
396 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher3);
shiqiane35fdd92008-12-10 05:08:54 +0000397};
398
399template <typename T1, typename T2, typename T3, typename T4>
400class ElementsAreMatcher4 {
401 public:
402 ElementsAreMatcher4(const T1& e1, const T2& e2, const T3& e3,
403 const T4& e4) : e1_(e1), e2_(e2), e3_(e3), e4_(e4) {}
404
405 template <typename Container>
406 operator Matcher<Container>() const {
zhanyong.wanab5b77c2010-05-17 19:32:48 +0000407 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000408 typedef typename internal::StlContainerView<RawContainer>::type::value_type
409 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000410
411 const Matcher<const Element&> matchers[] = {
412 MatcherCast<const Element&>(e1_),
413 MatcherCast<const Element&>(e2_),
414 MatcherCast<const Element&>(e3_),
415 MatcherCast<const Element&>(e4_),
416 };
417
jgm38513a82012-11-15 15:50:36 +0000418 return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers,
419 matchers + 4));
shiqiane35fdd92008-12-10 05:08:54 +0000420 }
421
422 private:
jgm38513a82012-11-15 15:50:36 +0000423 const typename DecayArray<T1>::type e1_;
424 const typename DecayArray<T2>::type e2_;
425 const typename DecayArray<T3>::type e3_;
426 const typename DecayArray<T4>::type e4_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000427
428 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher4);
shiqiane35fdd92008-12-10 05:08:54 +0000429};
430
431template <typename T1, typename T2, typename T3, typename T4, typename T5>
432class ElementsAreMatcher5 {
433 public:
434 ElementsAreMatcher5(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
435 const T5& e5) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5) {}
436
437 template <typename Container>
438 operator Matcher<Container>() const {
zhanyong.wanab5b77c2010-05-17 19:32:48 +0000439 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000440 typedef typename internal::StlContainerView<RawContainer>::type::value_type
441 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000442
443 const Matcher<const Element&> matchers[] = {
444 MatcherCast<const Element&>(e1_),
445 MatcherCast<const Element&>(e2_),
446 MatcherCast<const Element&>(e3_),
447 MatcherCast<const Element&>(e4_),
448 MatcherCast<const Element&>(e5_),
449 };
450
jgm38513a82012-11-15 15:50:36 +0000451 return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers,
452 matchers + 5));
shiqiane35fdd92008-12-10 05:08:54 +0000453 }
454
455 private:
jgm38513a82012-11-15 15:50:36 +0000456 const typename DecayArray<T1>::type e1_;
457 const typename DecayArray<T2>::type e2_;
458 const typename DecayArray<T3>::type e3_;
459 const typename DecayArray<T4>::type e4_;
460 const typename DecayArray<T5>::type e5_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000461
462 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher5);
shiqiane35fdd92008-12-10 05:08:54 +0000463};
464
465template <typename T1, typename T2, typename T3, typename T4, typename T5,
466 typename T6>
467class ElementsAreMatcher6 {
468 public:
469 ElementsAreMatcher6(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
470 const T5& e5, const T6& e6) : e1_(e1), e2_(e2), e3_(e3), e4_(e4),
471 e5_(e5), e6_(e6) {}
472
473 template <typename Container>
474 operator Matcher<Container>() const {
zhanyong.wanab5b77c2010-05-17 19:32:48 +0000475 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000476 typedef typename internal::StlContainerView<RawContainer>::type::value_type
477 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000478
479 const Matcher<const Element&> matchers[] = {
480 MatcherCast<const Element&>(e1_),
481 MatcherCast<const Element&>(e2_),
482 MatcherCast<const Element&>(e3_),
483 MatcherCast<const Element&>(e4_),
484 MatcherCast<const Element&>(e5_),
485 MatcherCast<const Element&>(e6_),
486 };
487
jgm38513a82012-11-15 15:50:36 +0000488 return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers,
489 matchers + 6));
shiqiane35fdd92008-12-10 05:08:54 +0000490 }
491
492 private:
jgm38513a82012-11-15 15:50:36 +0000493 const typename DecayArray<T1>::type e1_;
494 const typename DecayArray<T2>::type e2_;
495 const typename DecayArray<T3>::type e3_;
496 const typename DecayArray<T4>::type e4_;
497 const typename DecayArray<T5>::type e5_;
498 const typename DecayArray<T6>::type e6_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000499
500 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher6);
shiqiane35fdd92008-12-10 05:08:54 +0000501};
502
503template <typename T1, typename T2, typename T3, typename T4, typename T5,
504 typename T6, typename T7>
505class ElementsAreMatcher7 {
506 public:
507 ElementsAreMatcher7(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
508 const T5& e5, const T6& e6, const T7& e7) : e1_(e1), e2_(e2), e3_(e3),
509 e4_(e4), e5_(e5), e6_(e6), e7_(e7) {}
510
511 template <typename Container>
512 operator Matcher<Container>() const {
zhanyong.wanab5b77c2010-05-17 19:32:48 +0000513 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000514 typedef typename internal::StlContainerView<RawContainer>::type::value_type
515 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000516
517 const Matcher<const Element&> matchers[] = {
518 MatcherCast<const Element&>(e1_),
519 MatcherCast<const Element&>(e2_),
520 MatcherCast<const Element&>(e3_),
521 MatcherCast<const Element&>(e4_),
522 MatcherCast<const Element&>(e5_),
523 MatcherCast<const Element&>(e6_),
524 MatcherCast<const Element&>(e7_),
525 };
526
jgm38513a82012-11-15 15:50:36 +0000527 return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers,
528 matchers + 7));
shiqiane35fdd92008-12-10 05:08:54 +0000529 }
530
531 private:
jgm38513a82012-11-15 15:50:36 +0000532 const typename DecayArray<T1>::type e1_;
533 const typename DecayArray<T2>::type e2_;
534 const typename DecayArray<T3>::type e3_;
535 const typename DecayArray<T4>::type e4_;
536 const typename DecayArray<T5>::type e5_;
537 const typename DecayArray<T6>::type e6_;
538 const typename DecayArray<T7>::type e7_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000539
540 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher7);
shiqiane35fdd92008-12-10 05:08:54 +0000541};
542
543template <typename T1, typename T2, typename T3, typename T4, typename T5,
544 typename T6, typename T7, typename T8>
545class ElementsAreMatcher8 {
546 public:
547 ElementsAreMatcher8(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
548 const T5& e5, const T6& e6, const T7& e7, const T8& e8) : e1_(e1),
549 e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6), e7_(e7), e8_(e8) {}
550
551 template <typename Container>
552 operator Matcher<Container>() const {
zhanyong.wanab5b77c2010-05-17 19:32:48 +0000553 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000554 typedef typename internal::StlContainerView<RawContainer>::type::value_type
555 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000556
557 const Matcher<const Element&> matchers[] = {
558 MatcherCast<const Element&>(e1_),
559 MatcherCast<const Element&>(e2_),
560 MatcherCast<const Element&>(e3_),
561 MatcherCast<const Element&>(e4_),
562 MatcherCast<const Element&>(e5_),
563 MatcherCast<const Element&>(e6_),
564 MatcherCast<const Element&>(e7_),
565 MatcherCast<const Element&>(e8_),
566 };
567
jgm38513a82012-11-15 15:50:36 +0000568 return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers,
569 matchers + 8));
shiqiane35fdd92008-12-10 05:08:54 +0000570 }
571
572 private:
jgm38513a82012-11-15 15:50:36 +0000573 const typename DecayArray<T1>::type e1_;
574 const typename DecayArray<T2>::type e2_;
575 const typename DecayArray<T3>::type e3_;
576 const typename DecayArray<T4>::type e4_;
577 const typename DecayArray<T5>::type e5_;
578 const typename DecayArray<T6>::type e6_;
579 const typename DecayArray<T7>::type e7_;
580 const typename DecayArray<T8>::type e8_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000581
582 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher8);
shiqiane35fdd92008-12-10 05:08:54 +0000583};
584
585template <typename T1, typename T2, typename T3, typename T4, typename T5,
586 typename T6, typename T7, typename T8, typename T9>
587class ElementsAreMatcher9 {
588 public:
589 ElementsAreMatcher9(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
590 const T5& e5, const T6& e6, const T7& e7, const T8& e8,
591 const T9& e9) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6),
592 e7_(e7), e8_(e8), e9_(e9) {}
593
594 template <typename Container>
595 operator Matcher<Container>() const {
zhanyong.wanab5b77c2010-05-17 19:32:48 +0000596 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000597 typedef typename internal::StlContainerView<RawContainer>::type::value_type
598 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000599
600 const Matcher<const Element&> matchers[] = {
601 MatcherCast<const Element&>(e1_),
602 MatcherCast<const Element&>(e2_),
603 MatcherCast<const Element&>(e3_),
604 MatcherCast<const Element&>(e4_),
605 MatcherCast<const Element&>(e5_),
606 MatcherCast<const Element&>(e6_),
607 MatcherCast<const Element&>(e7_),
608 MatcherCast<const Element&>(e8_),
609 MatcherCast<const Element&>(e9_),
610 };
611
jgm38513a82012-11-15 15:50:36 +0000612 return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers,
613 matchers + 9));
shiqiane35fdd92008-12-10 05:08:54 +0000614 }
615
616 private:
jgm38513a82012-11-15 15:50:36 +0000617 const typename DecayArray<T1>::type e1_;
618 const typename DecayArray<T2>::type e2_;
619 const typename DecayArray<T3>::type e3_;
620 const typename DecayArray<T4>::type e4_;
621 const typename DecayArray<T5>::type e5_;
622 const typename DecayArray<T6>::type e6_;
623 const typename DecayArray<T7>::type e7_;
624 const typename DecayArray<T8>::type e8_;
625 const typename DecayArray<T9>::type e9_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000626
627 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher9);
shiqiane35fdd92008-12-10 05:08:54 +0000628};
629
630template <typename T1, typename T2, typename T3, typename T4, typename T5,
631 typename T6, typename T7, typename T8, typename T9, typename T10>
632class ElementsAreMatcher10 {
633 public:
634 ElementsAreMatcher10(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
635 const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,
636 const T10& e10) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6),
637 e7_(e7), e8_(e8), e9_(e9), e10_(e10) {}
638
639 template <typename Container>
640 operator Matcher<Container>() const {
zhanyong.wanab5b77c2010-05-17 19:32:48 +0000641 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
zhanyong.wanb8243162009-06-04 05:48:20 +0000642 typedef typename internal::StlContainerView<RawContainer>::type::value_type
643 Element;
shiqiane35fdd92008-12-10 05:08:54 +0000644
645 const Matcher<const Element&> matchers[] = {
646 MatcherCast<const Element&>(e1_),
647 MatcherCast<const Element&>(e2_),
648 MatcherCast<const Element&>(e3_),
649 MatcherCast<const Element&>(e4_),
650 MatcherCast<const Element&>(e5_),
651 MatcherCast<const Element&>(e6_),
652 MatcherCast<const Element&>(e7_),
653 MatcherCast<const Element&>(e8_),
654 MatcherCast<const Element&>(e9_),
655 MatcherCast<const Element&>(e10_),
656 };
657
jgm38513a82012-11-15 15:50:36 +0000658 return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers,
659 matchers + 10));
shiqiane35fdd92008-12-10 05:08:54 +0000660 }
661
662 private:
jgm38513a82012-11-15 15:50:36 +0000663 const typename DecayArray<T1>::type e1_;
664 const typename DecayArray<T2>::type e2_;
665 const typename DecayArray<T3>::type e3_;
666 const typename DecayArray<T4>::type e4_;
667 const typename DecayArray<T5>::type e5_;
668 const typename DecayArray<T6>::type e6_;
669 const typename DecayArray<T7>::type e7_;
670 const typename DecayArray<T8>::type e8_;
671 const typename DecayArray<T9>::type e9_;
672 const typename DecayArray<T10>::type e10_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000673
674 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher10);
shiqiane35fdd92008-12-10 05:08:54 +0000675};
676
jgm79a367e2012-04-10 16:02:11 +0000677// A set of metafunctions for computing the result type of AllOf.
678// AllOf(m1, ..., mN) returns
679// AllOfResultN<decltype(m1), ..., decltype(mN)>::type.
680
681// Although AllOf isn't defined for one argument, AllOfResult1 is defined
682// to simplify the implementation.
683template <typename M1>
684struct AllOfResult1 {
685 typedef M1 type;
686};
687
688template <typename M1, typename M2>
689struct AllOfResult2 {
690 typedef BothOfMatcher<
691 typename AllOfResult1<M1>::type,
692 typename AllOfResult1<M2>::type
693 > type;
694};
695
696template <typename M1, typename M2, typename M3>
697struct AllOfResult3 {
698 typedef BothOfMatcher<
699 typename AllOfResult1<M1>::type,
700 typename AllOfResult2<M2, M3>::type
701 > type;
702};
703
704template <typename M1, typename M2, typename M3, typename M4>
705struct AllOfResult4 {
706 typedef BothOfMatcher<
707 typename AllOfResult2<M1, M2>::type,
708 typename AllOfResult2<M3, M4>::type
709 > type;
710};
711
712template <typename M1, typename M2, typename M3, typename M4, typename M5>
713struct AllOfResult5 {
714 typedef BothOfMatcher<
715 typename AllOfResult2<M1, M2>::type,
716 typename AllOfResult3<M3, M4, M5>::type
717 > type;
718};
719
720template <typename M1, typename M2, typename M3, typename M4, typename M5,
721 typename M6>
722struct AllOfResult6 {
723 typedef BothOfMatcher<
724 typename AllOfResult3<M1, M2, M3>::type,
725 typename AllOfResult3<M4, M5, M6>::type
726 > type;
727};
728
729template <typename M1, typename M2, typename M3, typename M4, typename M5,
730 typename M6, typename M7>
731struct AllOfResult7 {
732 typedef BothOfMatcher<
733 typename AllOfResult3<M1, M2, M3>::type,
734 typename AllOfResult4<M4, M5, M6, M7>::type
735 > type;
736};
737
738template <typename M1, typename M2, typename M3, typename M4, typename M5,
739 typename M6, typename M7, typename M8>
740struct AllOfResult8 {
741 typedef BothOfMatcher<
742 typename AllOfResult4<M1, M2, M3, M4>::type,
743 typename AllOfResult4<M5, M6, M7, M8>::type
744 > type;
745};
746
747template <typename M1, typename M2, typename M3, typename M4, typename M5,
748 typename M6, typename M7, typename M8, typename M9>
749struct AllOfResult9 {
750 typedef BothOfMatcher<
751 typename AllOfResult4<M1, M2, M3, M4>::type,
752 typename AllOfResult5<M5, M6, M7, M8, M9>::type
753 > type;
754};
755
756template <typename M1, typename M2, typename M3, typename M4, typename M5,
757 typename M6, typename M7, typename M8, typename M9, typename M10>
758struct AllOfResult10 {
759 typedef BothOfMatcher<
760 typename AllOfResult5<M1, M2, M3, M4, M5>::type,
761 typename AllOfResult5<M6, M7, M8, M9, M10>::type
762 > type;
763};
764
765// A set of metafunctions for computing the result type of AnyOf.
766// AnyOf(m1, ..., mN) returns
767// AnyOfResultN<decltype(m1), ..., decltype(mN)>::type.
768
769// Although AnyOf isn't defined for one argument, AnyOfResult1 is defined
770// to simplify the implementation.
771template <typename M1>
772struct AnyOfResult1 {
773 typedef M1 type;
774};
775
776template <typename M1, typename M2>
777struct AnyOfResult2 {
778 typedef EitherOfMatcher<
779 typename AnyOfResult1<M1>::type,
780 typename AnyOfResult1<M2>::type
781 > type;
782};
783
784template <typename M1, typename M2, typename M3>
785struct AnyOfResult3 {
786 typedef EitherOfMatcher<
787 typename AnyOfResult1<M1>::type,
788 typename AnyOfResult2<M2, M3>::type
789 > type;
790};
791
792template <typename M1, typename M2, typename M3, typename M4>
793struct AnyOfResult4 {
794 typedef EitherOfMatcher<
795 typename AnyOfResult2<M1, M2>::type,
796 typename AnyOfResult2<M3, M4>::type
797 > type;
798};
799
800template <typename M1, typename M2, typename M3, typename M4, typename M5>
801struct AnyOfResult5 {
802 typedef EitherOfMatcher<
803 typename AnyOfResult2<M1, M2>::type,
804 typename AnyOfResult3<M3, M4, M5>::type
805 > type;
806};
807
808template <typename M1, typename M2, typename M3, typename M4, typename M5,
809 typename M6>
810struct AnyOfResult6 {
811 typedef EitherOfMatcher<
812 typename AnyOfResult3<M1, M2, M3>::type,
813 typename AnyOfResult3<M4, M5, M6>::type
814 > type;
815};
816
817template <typename M1, typename M2, typename M3, typename M4, typename M5,
818 typename M6, typename M7>
819struct AnyOfResult7 {
820 typedef EitherOfMatcher<
821 typename AnyOfResult3<M1, M2, M3>::type,
822 typename AnyOfResult4<M4, M5, M6, M7>::type
823 > type;
824};
825
826template <typename M1, typename M2, typename M3, typename M4, typename M5,
827 typename M6, typename M7, typename M8>
828struct AnyOfResult8 {
829 typedef EitherOfMatcher<
830 typename AnyOfResult4<M1, M2, M3, M4>::type,
831 typename AnyOfResult4<M5, M6, M7, M8>::type
832 > type;
833};
834
835template <typename M1, typename M2, typename M3, typename M4, typename M5,
836 typename M6, typename M7, typename M8, typename M9>
837struct AnyOfResult9 {
838 typedef EitherOfMatcher<
839 typename AnyOfResult4<M1, M2, M3, M4>::type,
840 typename AnyOfResult5<M5, M6, M7, M8, M9>::type
841 > type;
842};
843
844template <typename M1, typename M2, typename M3, typename M4, typename M5,
845 typename M6, typename M7, typename M8, typename M9, typename M10>
846struct AnyOfResult10 {
847 typedef EitherOfMatcher<
848 typename AnyOfResult5<M1, M2, M3, M4, M5>::type,
849 typename AnyOfResult5<M6, M7, M8, M9, M10>::type
850 > type;
851};
852
shiqiane35fdd92008-12-10 05:08:54 +0000853} // namespace internal
854
zhanyong.wan2661c682009-06-09 05:42:12 +0000855// Args<N1, N2, ..., Nk>(a_matcher) matches a tuple if the selected
856// fields of it matches a_matcher. C++ doesn't support default
857// arguments for function templates, so we have to overload it.
858template <typename InnerMatcher>
859inline internal::ArgsMatcher<InnerMatcher>
860Args(const InnerMatcher& matcher) {
861 return internal::ArgsMatcher<InnerMatcher>(matcher);
862}
863
864template <int k1, typename InnerMatcher>
865inline internal::ArgsMatcher<InnerMatcher, k1>
866Args(const InnerMatcher& matcher) {
867 return internal::ArgsMatcher<InnerMatcher, k1>(matcher);
868}
869
870template <int k1, int k2, typename InnerMatcher>
871inline internal::ArgsMatcher<InnerMatcher, k1, k2>
872Args(const InnerMatcher& matcher) {
873 return internal::ArgsMatcher<InnerMatcher, k1, k2>(matcher);
874}
875
876template <int k1, int k2, int k3, typename InnerMatcher>
877inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3>
878Args(const InnerMatcher& matcher) {
879 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3>(matcher);
880}
881
882template <int k1, int k2, int k3, int k4, typename InnerMatcher>
883inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>
884Args(const InnerMatcher& matcher) {
885 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>(matcher);
886}
887
888template <int k1, int k2, int k3, int k4, int k5, typename InnerMatcher>
889inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>
890Args(const InnerMatcher& matcher) {
891 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>(matcher);
892}
893
894template <int k1, int k2, int k3, int k4, int k5, int k6, typename InnerMatcher>
895inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>
896Args(const InnerMatcher& matcher) {
897 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>(matcher);
898}
899
900template <int k1, int k2, int k3, int k4, int k5, int k6, int k7,
901 typename InnerMatcher>
902inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7>
903Args(const InnerMatcher& matcher) {
904 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6,
905 k7>(matcher);
906}
907
908template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
909 typename InnerMatcher>
910inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8>
911Args(const InnerMatcher& matcher) {
912 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7,
913 k8>(matcher);
914}
915
916template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
917 int k9, typename InnerMatcher>
918inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9>
919Args(const InnerMatcher& matcher) {
920 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
921 k9>(matcher);
922}
923
924template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
925 int k9, int k10, typename InnerMatcher>
926inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9,
927 k10>
928Args(const InnerMatcher& matcher) {
929 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
930 k9, k10>(matcher);
931}
932
shiqiane35fdd92008-12-10 05:08:54 +0000933// ElementsAre(e0, e1, ..., e_n) matches an STL-style container with
934// (n + 1) elements, where the i-th element in the container must
935// match the i-th argument in the list. Each argument of
936// ElementsAre() can be either a value or a matcher. We support up to
937// 10 arguments.
938//
939// NOTE: Since ElementsAre() cares about the order of the elements, it
940// must not be used with containers whose elements's order is
941// undefined (e.g. hash_map).
942
943inline internal::ElementsAreMatcher0 ElementsAre() {
944 return internal::ElementsAreMatcher0();
945}
946
947template <typename T1>
948inline internal::ElementsAreMatcher1<T1> ElementsAre(const T1& e1) {
949 return internal::ElementsAreMatcher1<T1>(e1);
950}
951
952template <typename T1, typename T2>
953inline internal::ElementsAreMatcher2<T1, T2> ElementsAre(const T1& e1,
954 const T2& e2) {
955 return internal::ElementsAreMatcher2<T1, T2>(e1, e2);
956}
957
958template <typename T1, typename T2, typename T3>
959inline internal::ElementsAreMatcher3<T1, T2, T3> ElementsAre(const T1& e1,
960 const T2& e2, const T3& e3) {
961 return internal::ElementsAreMatcher3<T1, T2, T3>(e1, e2, e3);
962}
963
964template <typename T1, typename T2, typename T3, typename T4>
965inline internal::ElementsAreMatcher4<T1, T2, T3, T4> ElementsAre(const T1& e1,
966 const T2& e2, const T3& e3, const T4& e4) {
967 return internal::ElementsAreMatcher4<T1, T2, T3, T4>(e1, e2, e3, e4);
968}
969
970template <typename T1, typename T2, typename T3, typename T4, typename T5>
971inline internal::ElementsAreMatcher5<T1, T2, T3, T4,
972 T5> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
973 const T5& e5) {
974 return internal::ElementsAreMatcher5<T1, T2, T3, T4, T5>(e1, e2, e3, e4, e5);
975}
976
977template <typename T1, typename T2, typename T3, typename T4, typename T5,
978 typename T6>
979inline internal::ElementsAreMatcher6<T1, T2, T3, T4, T5,
980 T6> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
981 const T5& e5, const T6& e6) {
982 return internal::ElementsAreMatcher6<T1, T2, T3, T4, T5, T6>(e1, e2, e3, e4,
983 e5, e6);
984}
985
986template <typename T1, typename T2, typename T3, typename T4, typename T5,
987 typename T6, typename T7>
988inline internal::ElementsAreMatcher7<T1, T2, T3, T4, T5, T6,
989 T7> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
990 const T5& e5, const T6& e6, const T7& e7) {
991 return internal::ElementsAreMatcher7<T1, T2, T3, T4, T5, T6, T7>(e1, e2, e3,
992 e4, e5, e6, e7);
993}
994
995template <typename T1, typename T2, typename T3, typename T4, typename T5,
996 typename T6, typename T7, typename T8>
997inline internal::ElementsAreMatcher8<T1, T2, T3, T4, T5, T6, T7,
998 T8> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
999 const T5& e5, const T6& e6, const T7& e7, const T8& e8) {
1000 return internal::ElementsAreMatcher8<T1, T2, T3, T4, T5, T6, T7, T8>(e1, e2,
1001 e3, e4, e5, e6, e7, e8);
1002}
1003
1004template <typename T1, typename T2, typename T3, typename T4, typename T5,
1005 typename T6, typename T7, typename T8, typename T9>
1006inline internal::ElementsAreMatcher9<T1, T2, T3, T4, T5, T6, T7, T8,
1007 T9> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
1008 const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9) {
1009 return internal::ElementsAreMatcher9<T1, T2, T3, T4, T5, T6, T7, T8, T9>(e1,
1010 e2, e3, e4, e5, e6, e7, e8, e9);
1011}
1012
1013template <typename T1, typename T2, typename T3, typename T4, typename T5,
1014 typename T6, typename T7, typename T8, typename T9, typename T10>
1015inline internal::ElementsAreMatcher10<T1, T2, T3, T4, T5, T6, T7, T8, T9,
1016 T10> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
1017 const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,
1018 const T10& e10) {
1019 return internal::ElementsAreMatcher10<T1, T2, T3, T4, T5, T6, T7, T8, T9,
1020 T10>(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10);
1021}
1022
jgm38513a82012-11-15 15:50:36 +00001023// ElementsAreArray(array)
1024// ElementsAreArray(pointer, count)
1025// ElementsAreArray(vector)
1026// ElementsAreArray(first, last)
1027//
1028// The ElementsAreArray() functions are like ElementsAre(...), except that
1029// they are given a sequence of matchers or values rather than taking each
1030// element as a function argument. The sequence can be specified as a
1031// C-style array, a pointer and count, a vector, or an STL iterator range.
1032//
1033// * The array form infers the size of 'array', which must be of a
1034// statically-sized C-style array type.
1035//
1036// * The (pointer, count) form can take either a statically-sized C-style
1037// array or a pointer to a dynamically created array. It does not take
1038// ownership of the pointer.
1039//
1040// * The vector form can take a std::vector either of values or of matchers.
1041//
1042// * The (first, last) form can take any STL iterator range.
1043//
1044// All forms of ElementsAreArray() make a copy of the input sequence.
shiqiane35fdd92008-12-10 05:08:54 +00001045template <typename T>
1046inline internal::ElementsAreArrayMatcher<T> ElementsAreArray(
1047 const T* first, size_t count) {
jgm38513a82012-11-15 15:50:36 +00001048 return internal::ElementsAreArrayMatcher<T>(first, first + count);
shiqiane35fdd92008-12-10 05:08:54 +00001049}
1050
1051template <typename T, size_t N>
jgm38513a82012-11-15 15:50:36 +00001052inline internal::ElementsAreArrayMatcher<T> ElementsAreArray(
1053 const T (&array)[N]) {
1054 return internal::ElementsAreArrayMatcher<T>(array, array + N);
shiqiane35fdd92008-12-10 05:08:54 +00001055}
1056
jgm38513a82012-11-15 15:50:36 +00001057template <typename T, typename A>
1058inline internal::ElementsAreArrayMatcher<T> ElementsAreArray(
1059 const std::vector<T, A>& vec) {
1060 return internal::ElementsAreArrayMatcher<T>(vec.begin(), vec.end());
1061}
1062
1063template <typename Iter>
1064inline internal::ElementsAreArrayMatcher<
1065 typename std::iterator_traits<Iter>::value_type>
1066ElementsAreArray(Iter first, Iter last) {
1067 typedef typename std::iterator_traits<Iter>::value_type T;
1068 return internal::ElementsAreArrayMatcher<T>(first, last);
1069}
1070
1071
zhanyong.wan02c15052010-06-09 19:21:30 +00001072// AllOf(m1, m2, ..., mk) matches any value that matches all of the given
zhanyong.wan86d2eeb2011-03-16 17:10:39 +00001073// sub-matchers. AllOf is called fully qualified to prevent ADL from firing.
zhanyong.wan02c15052010-06-09 19:21:30 +00001074
jgm79a367e2012-04-10 16:02:11 +00001075template <typename M1, typename M2>
1076inline typename internal::AllOfResult2<M1, M2>::type
1077AllOf(M1 m1, M2 m2) {
1078 return typename internal::AllOfResult2<M1, M2>::type(
1079 m1,
1080 m2);
zhanyong.wan02c15052010-06-09 19:21:30 +00001081}
1082
jgm79a367e2012-04-10 16:02:11 +00001083template <typename M1, typename M2, typename M3>
1084inline typename internal::AllOfResult3<M1, M2, M3>::type
1085AllOf(M1 m1, M2 m2, M3 m3) {
1086 return typename internal::AllOfResult3<M1, M2, M3>::type(
1087 m1,
1088 ::testing::AllOf(m2, m3));
zhanyong.wan02c15052010-06-09 19:21:30 +00001089}
1090
jgm79a367e2012-04-10 16:02:11 +00001091template <typename M1, typename M2, typename M3, typename M4>
1092inline typename internal::AllOfResult4<M1, M2, M3, M4>::type
1093AllOf(M1 m1, M2 m2, M3 m3, M4 m4) {
1094 return typename internal::AllOfResult4<M1, M2, M3, M4>::type(
1095 ::testing::AllOf(m1, m2),
1096 ::testing::AllOf(m3, m4));
zhanyong.wan02c15052010-06-09 19:21:30 +00001097}
1098
jgm79a367e2012-04-10 16:02:11 +00001099template <typename M1, typename M2, typename M3, typename M4, typename M5>
1100inline typename internal::AllOfResult5<M1, M2, M3, M4, M5>::type
1101AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5) {
1102 return typename internal::AllOfResult5<M1, M2, M3, M4, M5>::type(
1103 ::testing::AllOf(m1, m2),
1104 ::testing::AllOf(m3, m4, m5));
zhanyong.wan02c15052010-06-09 19:21:30 +00001105}
1106
jgm79a367e2012-04-10 16:02:11 +00001107template <typename M1, typename M2, typename M3, typename M4, typename M5,
1108 typename M6>
1109inline typename internal::AllOfResult6<M1, M2, M3, M4, M5, M6>::type
1110AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6) {
1111 return typename internal::AllOfResult6<M1, M2, M3, M4, M5, M6>::type(
1112 ::testing::AllOf(m1, m2, m3),
1113 ::testing::AllOf(m4, m5, m6));
zhanyong.wan02c15052010-06-09 19:21:30 +00001114}
1115
jgm79a367e2012-04-10 16:02:11 +00001116template <typename M1, typename M2, typename M3, typename M4, typename M5,
1117 typename M6, typename M7>
1118inline typename internal::AllOfResult7<M1, M2, M3, M4, M5, M6, M7>::type
1119AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7) {
1120 return typename internal::AllOfResult7<M1, M2, M3, M4, M5, M6, M7>::type(
1121 ::testing::AllOf(m1, m2, m3),
1122 ::testing::AllOf(m4, m5, m6, m7));
zhanyong.wan02c15052010-06-09 19:21:30 +00001123}
1124
jgm79a367e2012-04-10 16:02:11 +00001125template <typename M1, typename M2, typename M3, typename M4, typename M5,
1126 typename M6, typename M7, typename M8>
1127inline typename internal::AllOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type
1128AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8) {
1129 return typename internal::AllOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type(
1130 ::testing::AllOf(m1, m2, m3, m4),
1131 ::testing::AllOf(m5, m6, m7, m8));
zhanyong.wan02c15052010-06-09 19:21:30 +00001132}
1133
jgm79a367e2012-04-10 16:02:11 +00001134template <typename M1, typename M2, typename M3, typename M4, typename M5,
1135 typename M6, typename M7, typename M8, typename M9>
1136inline typename internal::AllOfResult9<M1, M2, M3, M4, M5, M6, M7, M8, M9>::type
1137AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9) {
1138 return typename internal::AllOfResult9<M1, M2, M3, M4, M5, M6, M7, M8,
1139 M9>::type(
1140 ::testing::AllOf(m1, m2, m3, m4),
1141 ::testing::AllOf(m5, m6, m7, m8, m9));
zhanyong.wan02c15052010-06-09 19:21:30 +00001142}
1143
jgm79a367e2012-04-10 16:02:11 +00001144template <typename M1, typename M2, typename M3, typename M4, typename M5,
1145 typename M6, typename M7, typename M8, typename M9, typename M10>
1146inline typename internal::AllOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
1147 M10>::type
1148AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
1149 return typename internal::AllOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
1150 M10>::type(
1151 ::testing::AllOf(m1, m2, m3, m4, m5),
1152 ::testing::AllOf(m6, m7, m8, m9, m10));
zhanyong.wan02c15052010-06-09 19:21:30 +00001153}
1154
1155// AnyOf(m1, m2, ..., mk) matches any value that matches any of the given
zhanyong.wan86d2eeb2011-03-16 17:10:39 +00001156// sub-matchers. AnyOf is called fully qualified to prevent ADL from firing.
zhanyong.wan02c15052010-06-09 19:21:30 +00001157
jgm79a367e2012-04-10 16:02:11 +00001158template <typename M1, typename M2>
1159inline typename internal::AnyOfResult2<M1, M2>::type
1160AnyOf(M1 m1, M2 m2) {
1161 return typename internal::AnyOfResult2<M1, M2>::type(
1162 m1,
1163 m2);
zhanyong.wan02c15052010-06-09 19:21:30 +00001164}
1165
jgm79a367e2012-04-10 16:02:11 +00001166template <typename M1, typename M2, typename M3>
1167inline typename internal::AnyOfResult3<M1, M2, M3>::type
1168AnyOf(M1 m1, M2 m2, M3 m3) {
1169 return typename internal::AnyOfResult3<M1, M2, M3>::type(
1170 m1,
1171 ::testing::AnyOf(m2, m3));
zhanyong.wan02c15052010-06-09 19:21:30 +00001172}
1173
jgm79a367e2012-04-10 16:02:11 +00001174template <typename M1, typename M2, typename M3, typename M4>
1175inline typename internal::AnyOfResult4<M1, M2, M3, M4>::type
1176AnyOf(M1 m1, M2 m2, M3 m3, M4 m4) {
1177 return typename internal::AnyOfResult4<M1, M2, M3, M4>::type(
1178 ::testing::AnyOf(m1, m2),
1179 ::testing::AnyOf(m3, m4));
zhanyong.wan02c15052010-06-09 19:21:30 +00001180}
1181
jgm79a367e2012-04-10 16:02:11 +00001182template <typename M1, typename M2, typename M3, typename M4, typename M5>
1183inline typename internal::AnyOfResult5<M1, M2, M3, M4, M5>::type
1184AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5) {
1185 return typename internal::AnyOfResult5<M1, M2, M3, M4, M5>::type(
1186 ::testing::AnyOf(m1, m2),
1187 ::testing::AnyOf(m3, m4, m5));
zhanyong.wan02c15052010-06-09 19:21:30 +00001188}
1189
jgm79a367e2012-04-10 16:02:11 +00001190template <typename M1, typename M2, typename M3, typename M4, typename M5,
1191 typename M6>
1192inline typename internal::AnyOfResult6<M1, M2, M3, M4, M5, M6>::type
1193AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6) {
1194 return typename internal::AnyOfResult6<M1, M2, M3, M4, M5, M6>::type(
1195 ::testing::AnyOf(m1, m2, m3),
1196 ::testing::AnyOf(m4, m5, m6));
zhanyong.wan02c15052010-06-09 19:21:30 +00001197}
1198
jgm79a367e2012-04-10 16:02:11 +00001199template <typename M1, typename M2, typename M3, typename M4, typename M5,
1200 typename M6, typename M7>
1201inline typename internal::AnyOfResult7<M1, M2, M3, M4, M5, M6, M7>::type
1202AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7) {
1203 return typename internal::AnyOfResult7<M1, M2, M3, M4, M5, M6, M7>::type(
1204 ::testing::AnyOf(m1, m2, m3),
1205 ::testing::AnyOf(m4, m5, m6, m7));
zhanyong.wan02c15052010-06-09 19:21:30 +00001206}
1207
jgm79a367e2012-04-10 16:02:11 +00001208template <typename M1, typename M2, typename M3, typename M4, typename M5,
1209 typename M6, typename M7, typename M8>
1210inline typename internal::AnyOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type
1211AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8) {
1212 return typename internal::AnyOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type(
1213 ::testing::AnyOf(m1, m2, m3, m4),
1214 ::testing::AnyOf(m5, m6, m7, m8));
zhanyong.wan02c15052010-06-09 19:21:30 +00001215}
1216
jgm79a367e2012-04-10 16:02:11 +00001217template <typename M1, typename M2, typename M3, typename M4, typename M5,
1218 typename M6, typename M7, typename M8, typename M9>
1219inline typename internal::AnyOfResult9<M1, M2, M3, M4, M5, M6, M7, M8, M9>::type
1220AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9) {
1221 return typename internal::AnyOfResult9<M1, M2, M3, M4, M5, M6, M7, M8,
1222 M9>::type(
1223 ::testing::AnyOf(m1, m2, m3, m4),
1224 ::testing::AnyOf(m5, m6, m7, m8, m9));
zhanyong.wan02c15052010-06-09 19:21:30 +00001225}
1226
jgm79a367e2012-04-10 16:02:11 +00001227template <typename M1, typename M2, typename M3, typename M4, typename M5,
1228 typename M6, typename M7, typename M8, typename M9, typename M10>
1229inline typename internal::AnyOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
1230 M10>::type
1231AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
1232 return typename internal::AnyOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
1233 M10>::type(
1234 ::testing::AnyOf(m1, m2, m3, m4, m5),
1235 ::testing::AnyOf(m6, m7, m8, m9, m10));
zhanyong.wan02c15052010-06-09 19:21:30 +00001236}
1237
shiqiane35fdd92008-12-10 05:08:54 +00001238} // namespace testing
1239
zhanyong.wan86d2eeb2011-03-16 17:10:39 +00001240
zhanyong.wance198ff2009-02-12 01:34:27 +00001241// The MATCHER* family of macros can be used in a namespace scope to
zhanyong.wan82113312010-01-08 21:55:40 +00001242// define custom matchers easily.
1243//
1244// Basic Usage
1245// ===========
1246//
1247// The syntax
zhanyong.wance198ff2009-02-12 01:34:27 +00001248//
1249// MATCHER(name, description_string) { statements; }
1250//
zhanyong.wan82113312010-01-08 21:55:40 +00001251// defines a matcher with the given name that executes the statements,
1252// which must return a bool to indicate if the match succeeds. Inside
1253// the statements, you can refer to the value being matched by 'arg',
1254// and refer to its type by 'arg_type'.
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001255//
1256// The description string documents what the matcher does, and is used
1257// to generate the failure message when the match fails. Since a
1258// MATCHER() is usually defined in a header file shared by multiple
1259// C++ source files, we require the description to be a C-string
1260// literal to avoid possible side effects. It can be empty, in which
1261// case we'll use the sequence of words in the matcher name as the
1262// description.
1263//
1264// For example:
zhanyong.wance198ff2009-02-12 01:34:27 +00001265//
1266// MATCHER(IsEven, "") { return (arg % 2) == 0; }
1267//
1268// allows you to write
1269//
1270// // Expects mock_foo.Bar(n) to be called where n is even.
1271// EXPECT_CALL(mock_foo, Bar(IsEven()));
1272//
1273// or,
1274//
1275// // Verifies that the value of some_expression is even.
1276// EXPECT_THAT(some_expression, IsEven());
1277//
1278// If the above assertion fails, it will print something like:
1279//
1280// Value of: some_expression
1281// Expected: is even
1282// Actual: 7
1283//
1284// where the description "is even" is automatically calculated from the
1285// matcher name IsEven.
1286//
zhanyong.wan82113312010-01-08 21:55:40 +00001287// Argument Type
1288// =============
1289//
zhanyong.wance198ff2009-02-12 01:34:27 +00001290// Note that the type of the value being matched (arg_type) is
1291// determined by the context in which you use the matcher and is
1292// supplied to you by the compiler, so you don't need to worry about
1293// declaring it (nor can you). This allows the matcher to be
1294// polymorphic. For example, IsEven() can be used to match any type
1295// where the value of "(arg % 2) == 0" can be implicitly converted to
1296// a bool. In the "Bar(IsEven())" example above, if method Bar()
1297// takes an int, 'arg_type' will be int; if it takes an unsigned long,
1298// 'arg_type' will be unsigned long; and so on.
1299//
zhanyong.wan82113312010-01-08 21:55:40 +00001300// Parameterizing Matchers
1301// =======================
1302//
zhanyong.wance198ff2009-02-12 01:34:27 +00001303// Sometimes you'll want to parameterize the matcher. For that you
1304// can use another macro:
1305//
1306// MATCHER_P(name, param_name, description_string) { statements; }
1307//
1308// For example:
1309//
1310// MATCHER_P(HasAbsoluteValue, value, "") { return abs(arg) == value; }
1311//
1312// will allow you to write:
1313//
1314// EXPECT_THAT(Blah("a"), HasAbsoluteValue(n));
1315//
1316// which may lead to this message (assuming n is 10):
1317//
1318// Value of: Blah("a")
1319// Expected: has absolute value 10
1320// Actual: -9
1321//
1322// Note that both the matcher description and its parameter are
1323// printed, making the message human-friendly.
1324//
1325// In the matcher definition body, you can write 'foo_type' to
1326// reference the type of a parameter named 'foo'. For example, in the
1327// body of MATCHER_P(HasAbsoluteValue, value) above, you can write
1328// 'value_type' to refer to the type of 'value'.
1329//
1330// We also provide MATCHER_P2, MATCHER_P3, ..., up to MATCHER_P10 to
1331// support multi-parameter matchers.
1332//
zhanyong.wan82113312010-01-08 21:55:40 +00001333// Describing Parameterized Matchers
1334// =================================
1335//
zhanyong.wanb4140802010-06-08 22:53:57 +00001336// The last argument to MATCHER*() is a string-typed expression. The
1337// expression can reference all of the matcher's parameters and a
1338// special bool-typed variable named 'negation'. When 'negation' is
1339// false, the expression should evaluate to the matcher's description;
1340// otherwise it should evaluate to the description of the negation of
1341// the matcher. For example,
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001342//
zhanyong.wanb4140802010-06-08 22:53:57 +00001343// using testing::PrintToString;
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001344//
zhanyong.wanb4140802010-06-08 22:53:57 +00001345// MATCHER_P2(InClosedRange, low, hi,
1346// string(negation ? "is not" : "is") + " in range [" +
1347// PrintToString(low) + ", " + PrintToString(hi) + "]") {
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001348// return low <= arg && arg <= hi;
1349// }
1350// ...
1351// EXPECT_THAT(3, InClosedRange(4, 6));
zhanyong.wanb4140802010-06-08 22:53:57 +00001352// EXPECT_THAT(3, Not(InClosedRange(2, 4)));
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001353//
zhanyong.wanb4140802010-06-08 22:53:57 +00001354// would generate two failures that contain the text:
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001355//
1356// Expected: is in range [4, 6]
zhanyong.wanb4140802010-06-08 22:53:57 +00001357// ...
1358// Expected: is not in range [2, 4]
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001359//
1360// If you specify "" as the description, the failure message will
1361// contain the sequence of words in the matcher name followed by the
1362// parameter values printed as a tuple. For example,
1363//
1364// MATCHER_P2(InClosedRange, low, hi, "") { ... }
1365// ...
1366// EXPECT_THAT(3, InClosedRange(4, 6));
zhanyong.wanb4140802010-06-08 22:53:57 +00001367// EXPECT_THAT(3, Not(InClosedRange(2, 4)));
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001368//
zhanyong.wanb4140802010-06-08 22:53:57 +00001369// would generate two failures that contain the text:
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001370//
1371// Expected: in closed range (4, 6)
zhanyong.wanb4140802010-06-08 22:53:57 +00001372// ...
1373// Expected: not (in closed range (2, 4))
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001374//
zhanyong.wan82113312010-01-08 21:55:40 +00001375// Types of Matcher Parameters
1376// ===========================
1377//
zhanyong.wance198ff2009-02-12 01:34:27 +00001378// For the purpose of typing, you can view
1379//
1380// MATCHER_Pk(Foo, p1, ..., pk, description_string) { ... }
1381//
1382// as shorthand for
1383//
1384// template <typename p1_type, ..., typename pk_type>
1385// FooMatcherPk<p1_type, ..., pk_type>
1386// Foo(p1_type p1, ..., pk_type pk) { ... }
1387//
1388// When you write Foo(v1, ..., vk), the compiler infers the types of
1389// the parameters v1, ..., and vk for you. If you are not happy with
1390// the result of the type inference, you can specify the types by
1391// explicitly instantiating the template, as in Foo<long, bool>(5,
1392// false). As said earlier, you don't get to (or need to) specify
1393// 'arg_type' as that's determined by the context in which the matcher
1394// is used. You can assign the result of expression Foo(p1, ..., pk)
1395// to a variable of type FooMatcherPk<p1_type, ..., pk_type>. This
1396// can be useful when composing matchers.
1397//
1398// While you can instantiate a matcher template with reference types,
1399// passing the parameters by pointer usually makes your code more
1400// readable. If, however, you still want to pass a parameter by
1401// reference, be aware that in the failure message generated by the
1402// matcher you will see the value of the referenced object but not its
1403// address.
1404//
zhanyong.wan82113312010-01-08 21:55:40 +00001405// Explaining Match Results
1406// ========================
1407//
1408// Sometimes the matcher description alone isn't enough to explain why
1409// the match has failed or succeeded. For example, when expecting a
1410// long string, it can be very helpful to also print the diff between
1411// the expected string and the actual one. To achieve that, you can
1412// optionally stream additional information to a special variable
1413// named result_listener, whose type is a pointer to class
1414// MatchResultListener:
1415//
1416// MATCHER_P(EqualsLongString, str, "") {
1417// if (arg == str) return true;
1418//
1419// *result_listener << "the difference: "
1420/// << DiffStrings(str, arg);
1421// return false;
1422// }
1423//
1424// Overloading Matchers
1425// ====================
1426//
zhanyong.wance198ff2009-02-12 01:34:27 +00001427// You can overload matchers with different numbers of parameters:
1428//
1429// MATCHER_P(Blah, a, description_string1) { ... }
1430// MATCHER_P2(Blah, a, b, description_string2) { ... }
1431//
zhanyong.wan82113312010-01-08 21:55:40 +00001432// Caveats
1433// =======
zhanyong.wance198ff2009-02-12 01:34:27 +00001434//
zhanyong.wan82113312010-01-08 21:55:40 +00001435// When defining a new matcher, you should also consider implementing
1436// MatcherInterface or using MakePolymorphicMatcher(). These
1437// approaches require more work than the MATCHER* macros, but also
1438// give you more control on the types of the value being matched and
1439// the matcher parameters, which may leads to better compiler error
1440// messages when the matcher is used wrong. They also allow
1441// overloading matchers based on parameter types (as opposed to just
1442// based on the number of parameters).
zhanyong.wance198ff2009-02-12 01:34:27 +00001443//
1444// MATCHER*() can only be used in a namespace scope. The reason is
1445// that C++ doesn't yet allow function-local types to be used to
1446// instantiate templates. The up-coming C++0x standard will fix this.
1447// Once that's done, we'll consider supporting using MATCHER*() inside
1448// a function.
1449//
zhanyong.wan82113312010-01-08 21:55:40 +00001450// More Information
1451// ================
zhanyong.wance198ff2009-02-12 01:34:27 +00001452//
1453// To learn more about using these macros, please search for 'MATCHER'
1454// on http://code.google.com/p/googlemock/wiki/CookBook.
1455
1456#define MATCHER(name, description)\
1457 class name##Matcher {\
1458 public:\
1459 template <typename arg_type>\
1460 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1461 public:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001462 gmock_Impl()\
1463 {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001464 virtual bool MatchAndExplain(\
1465 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001466 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001467 *gmock_os << FormatDescription(false);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001468 }\
zhanyong.wanb4140802010-06-08 22:53:57 +00001469 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1470 *gmock_os << FormatDescription(true);\
1471 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001472 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001473 ::testing::internal::string FormatDescription(bool negation) const {\
1474 const ::testing::internal::string gmock_description = (description);\
1475 if (!gmock_description.empty())\
1476 return gmock_description;\
1477 return ::testing::internal::FormatMatcherDescription(\
jgm79a367e2012-04-10 16:02:11 +00001478 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001479 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1480 ::std::tr1::tuple<>()));\
1481 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001482 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001483 };\
1484 template <typename arg_type>\
1485 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001486 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001487 new gmock_Impl<arg_type>());\
zhanyong.wance198ff2009-02-12 01:34:27 +00001488 }\
1489 name##Matcher() {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001490 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001491 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001492 GTEST_DISALLOW_ASSIGN_(name##Matcher);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001493 };\
1494 inline name##Matcher name() {\
1495 return name##Matcher();\
1496 }\
1497 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001498 bool name##Matcher::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00001499 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00001500 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1501 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001502
1503#define MATCHER_P(name, p0, description)\
1504 template <typename p0##_type>\
1505 class name##MatcherP {\
1506 public:\
1507 template <typename arg_type>\
1508 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1509 public:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001510 explicit gmock_Impl(p0##_type gmock_p0)\
1511 : p0(gmock_p0) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001512 virtual bool MatchAndExplain(\
1513 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001514 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001515 *gmock_os << FormatDescription(false);\
1516 }\
1517 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1518 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001519 }\
1520 p0##_type p0;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001521 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001522 ::testing::internal::string FormatDescription(bool negation) const {\
1523 const ::testing::internal::string gmock_description = (description);\
1524 if (!gmock_description.empty())\
1525 return gmock_description;\
1526 return ::testing::internal::FormatMatcherDescription(\
jgm79a367e2012-04-10 16:02:11 +00001527 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001528 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1529 ::std::tr1::tuple<p0##_type>(p0)));\
1530 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001531 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001532 };\
1533 template <typename arg_type>\
1534 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001535 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001536 new gmock_Impl<arg_type>(p0));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001537 }\
1538 name##MatcherP(p0##_type gmock_p0) : p0(gmock_p0) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001539 }\
1540 p0##_type p0;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001541 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001542 GTEST_DISALLOW_ASSIGN_(name##MatcherP);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001543 };\
1544 template <typename p0##_type>\
1545 inline name##MatcherP<p0##_type> name(p0##_type p0) {\
1546 return name##MatcherP<p0##_type>(p0);\
1547 }\
1548 template <typename p0##_type>\
1549 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001550 bool name##MatcherP<p0##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00001551 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00001552 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1553 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001554
1555#define MATCHER_P2(name, p0, p1, description)\
1556 template <typename p0##_type, typename p1##_type>\
1557 class name##MatcherP2 {\
1558 public:\
1559 template <typename arg_type>\
1560 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1561 public:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001562 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1)\
1563 : p0(gmock_p0), p1(gmock_p1) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001564 virtual bool MatchAndExplain(\
1565 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001566 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001567 *gmock_os << FormatDescription(false);\
1568 }\
1569 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1570 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001571 }\
1572 p0##_type p0;\
1573 p1##_type p1;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001574 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001575 ::testing::internal::string FormatDescription(bool negation) const {\
1576 const ::testing::internal::string gmock_description = (description);\
1577 if (!gmock_description.empty())\
1578 return gmock_description;\
1579 return ::testing::internal::FormatMatcherDescription(\
jgm79a367e2012-04-10 16:02:11 +00001580 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001581 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1582 ::std::tr1::tuple<p0##_type, p1##_type>(p0, p1)));\
1583 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001584 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001585 };\
1586 template <typename arg_type>\
1587 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001588 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001589 new gmock_Impl<arg_type>(p0, p1));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001590 }\
1591 name##MatcherP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
1592 p1(gmock_p1) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001593 }\
1594 p0##_type p0;\
1595 p1##_type p1;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001596 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001597 GTEST_DISALLOW_ASSIGN_(name##MatcherP2);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001598 };\
1599 template <typename p0##_type, typename p1##_type>\
1600 inline name##MatcherP2<p0##_type, p1##_type> name(p0##_type p0, \
1601 p1##_type p1) {\
1602 return name##MatcherP2<p0##_type, p1##_type>(p0, p1);\
1603 }\
1604 template <typename p0##_type, typename p1##_type>\
1605 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001606 bool name##MatcherP2<p0##_type, \
1607 p1##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00001608 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00001609 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1610 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001611
1612#define MATCHER_P3(name, p0, p1, p2, description)\
1613 template <typename p0##_type, typename p1##_type, typename p2##_type>\
1614 class name##MatcherP3 {\
1615 public:\
1616 template <typename arg_type>\
1617 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1618 public:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001619 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2)\
1620 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001621 virtual bool MatchAndExplain(\
1622 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001623 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001624 *gmock_os << FormatDescription(false);\
1625 }\
1626 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1627 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001628 }\
1629 p0##_type p0;\
1630 p1##_type p1;\
1631 p2##_type p2;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001632 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001633 ::testing::internal::string FormatDescription(bool negation) const {\
1634 const ::testing::internal::string gmock_description = (description);\
1635 if (!gmock_description.empty())\
1636 return gmock_description;\
1637 return ::testing::internal::FormatMatcherDescription(\
jgm79a367e2012-04-10 16:02:11 +00001638 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001639 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1640 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type>(p0, p1, \
1641 p2)));\
1642 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001643 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001644 };\
1645 template <typename arg_type>\
1646 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001647 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001648 new gmock_Impl<arg_type>(p0, p1, p2));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001649 }\
1650 name##MatcherP3(p0##_type gmock_p0, p1##_type gmock_p1, \
1651 p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001652 }\
1653 p0##_type p0;\
1654 p1##_type p1;\
1655 p2##_type p2;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001656 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001657 GTEST_DISALLOW_ASSIGN_(name##MatcherP3);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001658 };\
1659 template <typename p0##_type, typename p1##_type, typename p2##_type>\
1660 inline name##MatcherP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0, \
1661 p1##_type p1, p2##_type p2) {\
1662 return name##MatcherP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\
1663 }\
1664 template <typename p0##_type, typename p1##_type, typename p2##_type>\
1665 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001666 bool name##MatcherP3<p0##_type, p1##_type, \
1667 p2##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00001668 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00001669 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1670 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001671
1672#define MATCHER_P4(name, p0, p1, p2, p3, description)\
1673 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1674 typename p3##_type>\
1675 class name##MatcherP4 {\
1676 public:\
1677 template <typename arg_type>\
1678 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1679 public:\
1680 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001681 p3##_type gmock_p3)\
1682 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001683 virtual bool MatchAndExplain(\
1684 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001685 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001686 *gmock_os << FormatDescription(false);\
1687 }\
1688 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1689 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001690 }\
1691 p0##_type p0;\
1692 p1##_type p1;\
1693 p2##_type p2;\
1694 p3##_type p3;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001695 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001696 ::testing::internal::string FormatDescription(bool negation) const {\
1697 const ::testing::internal::string gmock_description = (description);\
1698 if (!gmock_description.empty())\
1699 return gmock_description;\
1700 return ::testing::internal::FormatMatcherDescription(\
jgm79a367e2012-04-10 16:02:11 +00001701 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001702 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1703 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, \
1704 p3##_type>(p0, p1, p2, p3)));\
1705 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001706 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001707 };\
1708 template <typename arg_type>\
1709 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001710 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001711 new gmock_Impl<arg_type>(p0, p1, p2, p3));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001712 }\
1713 name##MatcherP4(p0##_type gmock_p0, p1##_type gmock_p1, \
1714 p2##_type gmock_p2, p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), \
1715 p2(gmock_p2), p3(gmock_p3) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001716 }\
1717 p0##_type p0;\
1718 p1##_type p1;\
1719 p2##_type p2;\
1720 p3##_type p3;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001721 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001722 GTEST_DISALLOW_ASSIGN_(name##MatcherP4);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001723 };\
1724 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1725 typename p3##_type>\
1726 inline name##MatcherP4<p0##_type, p1##_type, p2##_type, \
1727 p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
1728 p3##_type p3) {\
1729 return name##MatcherP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, \
1730 p1, p2, p3);\
1731 }\
1732 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1733 typename p3##_type>\
1734 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001735 bool name##MatcherP4<p0##_type, p1##_type, p2##_type, \
1736 p3##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00001737 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00001738 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1739 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001740
1741#define MATCHER_P5(name, p0, p1, p2, p3, p4, description)\
1742 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1743 typename p3##_type, typename p4##_type>\
1744 class name##MatcherP5 {\
1745 public:\
1746 template <typename arg_type>\
1747 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1748 public:\
1749 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001750 p3##_type gmock_p3, p4##_type gmock_p4)\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001751 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
zhanyong.wanb4140802010-06-08 22:53:57 +00001752 p4(gmock_p4) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001753 virtual bool MatchAndExplain(\
1754 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001755 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001756 *gmock_os << FormatDescription(false);\
1757 }\
1758 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1759 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001760 }\
1761 p0##_type p0;\
1762 p1##_type p1;\
1763 p2##_type p2;\
1764 p3##_type p3;\
1765 p4##_type p4;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001766 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001767 ::testing::internal::string FormatDescription(bool negation) const {\
1768 const ::testing::internal::string gmock_description = (description);\
1769 if (!gmock_description.empty())\
1770 return gmock_description;\
1771 return ::testing::internal::FormatMatcherDescription(\
jgm79a367e2012-04-10 16:02:11 +00001772 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001773 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1774 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1775 p4##_type>(p0, p1, p2, p3, p4)));\
1776 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001777 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001778 };\
1779 template <typename arg_type>\
1780 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001781 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001782 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001783 }\
1784 name##MatcherP5(p0##_type gmock_p0, p1##_type gmock_p1, \
1785 p2##_type gmock_p2, p3##_type gmock_p3, \
1786 p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1787 p3(gmock_p3), p4(gmock_p4) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001788 }\
1789 p0##_type p0;\
1790 p1##_type p1;\
1791 p2##_type p2;\
1792 p3##_type p3;\
1793 p4##_type p4;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001794 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001795 GTEST_DISALLOW_ASSIGN_(name##MatcherP5);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001796 };\
1797 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1798 typename p3##_type, typename p4##_type>\
1799 inline name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1800 p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
1801 p4##_type p4) {\
1802 return name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1803 p4##_type>(p0, p1, p2, p3, p4);\
1804 }\
1805 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1806 typename p3##_type, typename p4##_type>\
1807 template <typename arg_type>\
zhanyong.wan82113312010-01-08 21:55:40 +00001808 bool name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1809 p4##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00001810 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00001811 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1812 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001813
1814#define MATCHER_P6(name, p0, p1, p2, p3, p4, p5, description)\
1815 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1816 typename p3##_type, typename p4##_type, typename p5##_type>\
1817 class name##MatcherP6 {\
1818 public:\
1819 template <typename arg_type>\
1820 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1821 public:\
1822 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001823 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5)\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001824 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
zhanyong.wanb4140802010-06-08 22:53:57 +00001825 p4(gmock_p4), p5(gmock_p5) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001826 virtual bool MatchAndExplain(\
1827 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001828 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001829 *gmock_os << FormatDescription(false);\
1830 }\
1831 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1832 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001833 }\
1834 p0##_type p0;\
1835 p1##_type p1;\
1836 p2##_type p2;\
1837 p3##_type p3;\
1838 p4##_type p4;\
1839 p5##_type p5;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001840 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001841 ::testing::internal::string FormatDescription(bool negation) const {\
1842 const ::testing::internal::string gmock_description = (description);\
1843 if (!gmock_description.empty())\
1844 return gmock_description;\
1845 return ::testing::internal::FormatMatcherDescription(\
jgm79a367e2012-04-10 16:02:11 +00001846 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001847 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1848 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1849 p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5)));\
1850 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001851 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001852 };\
1853 template <typename arg_type>\
1854 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001855 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001856 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001857 }\
1858 name##MatcherP6(p0##_type gmock_p0, p1##_type gmock_p1, \
1859 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1860 p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1861 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001862 }\
1863 p0##_type p0;\
1864 p1##_type p1;\
1865 p2##_type p2;\
1866 p3##_type p3;\
1867 p4##_type p4;\
1868 p5##_type p5;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001869 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001870 GTEST_DISALLOW_ASSIGN_(name##MatcherP6);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001871 };\
1872 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1873 typename p3##_type, typename p4##_type, typename p5##_type>\
1874 inline name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
1875 p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
1876 p3##_type p3, p4##_type p4, p5##_type p5) {\
1877 return name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
1878 p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\
1879 }\
1880 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1881 typename p3##_type, typename p4##_type, typename p5##_type>\
1882 template <typename arg_type>\
1883 bool name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00001884 p5##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00001885 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00001886 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1887 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001888
1889#define MATCHER_P7(name, p0, p1, p2, p3, p4, p5, p6, description)\
1890 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1891 typename p3##_type, typename p4##_type, typename p5##_type, \
1892 typename p6##_type>\
1893 class name##MatcherP7 {\
1894 public:\
1895 template <typename arg_type>\
1896 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1897 public:\
1898 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1899 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001900 p6##_type gmock_p6)\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001901 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
zhanyong.wanb4140802010-06-08 22:53:57 +00001902 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001903 virtual bool MatchAndExplain(\
1904 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001905 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001906 *gmock_os << FormatDescription(false);\
1907 }\
1908 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1909 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001910 }\
1911 p0##_type p0;\
1912 p1##_type p1;\
1913 p2##_type p2;\
1914 p3##_type p3;\
1915 p4##_type p4;\
1916 p5##_type p5;\
1917 p6##_type p6;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001918 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00001919 ::testing::internal::string FormatDescription(bool negation) const {\
1920 const ::testing::internal::string gmock_description = (description);\
1921 if (!gmock_description.empty())\
1922 return gmock_description;\
1923 return ::testing::internal::FormatMatcherDescription(\
jgm79a367e2012-04-10 16:02:11 +00001924 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001925 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1926 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1927 p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, \
1928 p6)));\
1929 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001930 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001931 };\
1932 template <typename arg_type>\
1933 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001934 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00001935 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6));\
zhanyong.wance198ff2009-02-12 01:34:27 +00001936 }\
1937 name##MatcherP7(p0##_type gmock_p0, p1##_type gmock_p1, \
1938 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1939 p5##_type gmock_p5, p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), \
1940 p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), \
1941 p6(gmock_p6) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00001942 }\
1943 p0##_type p0;\
1944 p1##_type p1;\
1945 p2##_type p2;\
1946 p3##_type p3;\
1947 p4##_type p4;\
1948 p5##_type p5;\
1949 p6##_type p6;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001950 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001951 GTEST_DISALLOW_ASSIGN_(name##MatcherP7);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001952 };\
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>\
1956 inline name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
1957 p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \
1958 p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
1959 p6##_type p6) {\
1960 return name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
1961 p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\
1962 }\
1963 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1964 typename p3##_type, typename p4##_type, typename p5##_type, \
1965 typename p6##_type>\
1966 template <typename arg_type>\
1967 bool name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00001968 p5##_type, p6##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00001969 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00001970 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1971 const
zhanyong.wance198ff2009-02-12 01:34:27 +00001972
1973#define MATCHER_P8(name, p0, p1, p2, p3, p4, p5, p6, p7, description)\
1974 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1975 typename p3##_type, typename p4##_type, typename p5##_type, \
1976 typename p6##_type, typename p7##_type>\
1977 class name##MatcherP8 {\
1978 public:\
1979 template <typename arg_type>\
1980 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1981 public:\
1982 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1983 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
zhanyong.wanb4140802010-06-08 22:53:57 +00001984 p6##_type gmock_p6, p7##_type gmock_p7)\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001985 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
zhanyong.wanb4140802010-06-08 22:53:57 +00001986 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00001987 virtual bool MatchAndExplain(\
1988 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00001989 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00001990 *gmock_os << FormatDescription(false);\
1991 }\
1992 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1993 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00001994 }\
1995 p0##_type p0;\
1996 p1##_type p1;\
1997 p2##_type p2;\
1998 p3##_type p3;\
1999 p4##_type p4;\
2000 p5##_type p5;\
2001 p6##_type p6;\
2002 p7##_type p7;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002003 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00002004 ::testing::internal::string FormatDescription(bool negation) const {\
2005 const ::testing::internal::string gmock_description = (description);\
2006 if (!gmock_description.empty())\
2007 return gmock_description;\
2008 return ::testing::internal::FormatMatcherDescription(\
jgm79a367e2012-04-10 16:02:11 +00002009 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00002010 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
2011 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
2012 p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, \
2013 p3, p4, p5, p6, p7)));\
2014 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002015 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00002016 };\
2017 template <typename arg_type>\
2018 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00002019 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00002020 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7));\
zhanyong.wance198ff2009-02-12 01:34:27 +00002021 }\
2022 name##MatcherP8(p0##_type gmock_p0, p1##_type gmock_p1, \
2023 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
2024 p5##_type gmock_p5, p6##_type gmock_p6, \
2025 p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
2026 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
2027 p7(gmock_p7) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00002028 }\
2029 p0##_type p0;\
2030 p1##_type p1;\
2031 p2##_type p2;\
2032 p3##_type p3;\
2033 p4##_type p4;\
2034 p5##_type p5;\
2035 p6##_type p6;\
2036 p7##_type p7;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002037 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002038 GTEST_DISALLOW_ASSIGN_(name##MatcherP8);\
zhanyong.wance198ff2009-02-12 01:34:27 +00002039 };\
2040 template <typename p0##_type, typename p1##_type, typename p2##_type, \
2041 typename p3##_type, typename p4##_type, typename p5##_type, \
2042 typename p6##_type, typename p7##_type>\
2043 inline name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
2044 p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \
2045 p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
2046 p6##_type p6, p7##_type p7) {\
2047 return name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
2048 p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5, \
2049 p6, p7);\
2050 }\
2051 template <typename p0##_type, typename p1##_type, typename p2##_type, \
2052 typename p3##_type, typename p4##_type, typename p5##_type, \
2053 typename p6##_type, typename p7##_type>\
2054 template <typename arg_type>\
2055 bool name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00002056 p5##_type, p6##_type, \
2057 p7##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00002058 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00002059 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
2060 const
zhanyong.wance198ff2009-02-12 01:34:27 +00002061
2062#define MATCHER_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, description)\
2063 template <typename p0##_type, typename p1##_type, typename p2##_type, \
2064 typename p3##_type, typename p4##_type, typename p5##_type, \
2065 typename p6##_type, typename p7##_type, typename p8##_type>\
2066 class name##MatcherP9 {\
2067 public:\
2068 template <typename arg_type>\
2069 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
2070 public:\
2071 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
2072 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
zhanyong.wanb4140802010-06-08 22:53:57 +00002073 p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8)\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00002074 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
2075 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
zhanyong.wanb4140802010-06-08 22:53:57 +00002076 p8(gmock_p8) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00002077 virtual bool MatchAndExplain(\
2078 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00002079 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00002080 *gmock_os << FormatDescription(false);\
2081 }\
2082 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
2083 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00002084 }\
2085 p0##_type p0;\
2086 p1##_type p1;\
2087 p2##_type p2;\
2088 p3##_type p3;\
2089 p4##_type p4;\
2090 p5##_type p5;\
2091 p6##_type p6;\
2092 p7##_type p7;\
2093 p8##_type p8;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002094 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00002095 ::testing::internal::string FormatDescription(bool negation) const {\
2096 const ::testing::internal::string gmock_description = (description);\
2097 if (!gmock_description.empty())\
2098 return gmock_description;\
2099 return ::testing::internal::FormatMatcherDescription(\
jgm79a367e2012-04-10 16:02:11 +00002100 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00002101 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
2102 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
2103 p4##_type, p5##_type, p6##_type, p7##_type, \
2104 p8##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8)));\
2105 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002106 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00002107 };\
2108 template <typename arg_type>\
2109 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00002110 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00002111 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8));\
zhanyong.wance198ff2009-02-12 01:34:27 +00002112 }\
2113 name##MatcherP9(p0##_type gmock_p0, p1##_type gmock_p1, \
2114 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
2115 p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
2116 p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
2117 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
2118 p8(gmock_p8) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00002119 }\
2120 p0##_type p0;\
2121 p1##_type p1;\
2122 p2##_type p2;\
2123 p3##_type p3;\
2124 p4##_type p4;\
2125 p5##_type p5;\
2126 p6##_type p6;\
2127 p7##_type p7;\
2128 p8##_type p8;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002129 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002130 GTEST_DISALLOW_ASSIGN_(name##MatcherP9);\
zhanyong.wance198ff2009-02-12 01:34:27 +00002131 };\
2132 template <typename p0##_type, typename p1##_type, typename p2##_type, \
2133 typename p3##_type, typename p4##_type, typename p5##_type, \
2134 typename p6##_type, typename p7##_type, typename p8##_type>\
2135 inline name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \
2136 p4##_type, p5##_type, p6##_type, p7##_type, \
2137 p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
2138 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \
2139 p8##_type p8) {\
2140 return name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \
2141 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type>(p0, p1, p2, \
2142 p3, p4, p5, p6, p7, p8);\
2143 }\
2144 template <typename p0##_type, typename p1##_type, typename p2##_type, \
2145 typename p3##_type, typename p4##_type, typename p5##_type, \
2146 typename p6##_type, typename p7##_type, typename p8##_type>\
2147 template <typename arg_type>\
2148 bool name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00002149 p5##_type, p6##_type, p7##_type, \
2150 p8##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00002151 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00002152 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
2153 const
zhanyong.wance198ff2009-02-12 01:34:27 +00002154
2155#define MATCHER_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, description)\
2156 template <typename p0##_type, typename p1##_type, typename p2##_type, \
2157 typename p3##_type, typename p4##_type, typename p5##_type, \
2158 typename p6##_type, typename p7##_type, typename p8##_type, \
2159 typename p9##_type>\
2160 class name##MatcherP10 {\
2161 public:\
2162 template <typename arg_type>\
2163 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
2164 public:\
2165 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
2166 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
2167 p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
zhanyong.wanb4140802010-06-08 22:53:57 +00002168 p9##_type gmock_p9)\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00002169 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
2170 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
zhanyong.wanb4140802010-06-08 22:53:57 +00002171 p8(gmock_p8), p9(gmock_p9) {}\
zhanyong.wan82113312010-01-08 21:55:40 +00002172 virtual bool MatchAndExplain(\
2173 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00002174 virtual void DescribeTo(::std::ostream* gmock_os) const {\
zhanyong.wanb4140802010-06-08 22:53:57 +00002175 *gmock_os << FormatDescription(false);\
2176 }\
2177 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
2178 *gmock_os << FormatDescription(true);\
zhanyong.wance198ff2009-02-12 01:34:27 +00002179 }\
2180 p0##_type p0;\
2181 p1##_type p1;\
2182 p2##_type p2;\
2183 p3##_type p3;\
2184 p4##_type p4;\
2185 p5##_type p5;\
2186 p6##_type p6;\
2187 p7##_type p7;\
2188 p8##_type p8;\
2189 p9##_type p9;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002190 private:\
zhanyong.wanb4140802010-06-08 22:53:57 +00002191 ::testing::internal::string FormatDescription(bool negation) const {\
2192 const ::testing::internal::string gmock_description = (description);\
2193 if (!gmock_description.empty())\
2194 return gmock_description;\
2195 return ::testing::internal::FormatMatcherDescription(\
jgm79a367e2012-04-10 16:02:11 +00002196 negation, #name, \
zhanyong.wanb4140802010-06-08 22:53:57 +00002197 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
2198 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
2199 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
2200 p9##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)));\
2201 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002202 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wance198ff2009-02-12 01:34:27 +00002203 };\
2204 template <typename arg_type>\
2205 operator ::testing::Matcher<arg_type>() const {\
zhanyong.wan4a5330d2009-02-19 00:36:44 +00002206 return ::testing::Matcher<arg_type>(\
zhanyong.wanb4140802010-06-08 22:53:57 +00002207 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9));\
zhanyong.wance198ff2009-02-12 01:34:27 +00002208 }\
2209 name##MatcherP10(p0##_type gmock_p0, p1##_type gmock_p1, \
2210 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
2211 p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
2212 p8##_type gmock_p8, p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), \
2213 p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
2214 p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {\
zhanyong.wance198ff2009-02-12 01:34:27 +00002215 }\
2216 p0##_type p0;\
2217 p1##_type p1;\
2218 p2##_type p2;\
2219 p3##_type p3;\
2220 p4##_type p4;\
2221 p5##_type p5;\
2222 p6##_type p6;\
2223 p7##_type p7;\
2224 p8##_type p8;\
2225 p9##_type p9;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002226 private:\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002227 GTEST_DISALLOW_ASSIGN_(name##MatcherP10);\
zhanyong.wance198ff2009-02-12 01:34:27 +00002228 };\
2229 template <typename p0##_type, typename p1##_type, typename p2##_type, \
2230 typename p3##_type, typename p4##_type, typename p5##_type, \
2231 typename p6##_type, typename p7##_type, typename p8##_type, \
2232 typename p9##_type>\
2233 inline name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
2234 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
2235 p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
2236 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
2237 p9##_type p9) {\
2238 return name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
2239 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>(p0, \
2240 p1, p2, p3, p4, p5, p6, p7, p8, p9);\
2241 }\
2242 template <typename p0##_type, typename p1##_type, typename p2##_type, \
2243 typename p3##_type, typename p4##_type, typename p5##_type, \
2244 typename p6##_type, typename p7##_type, typename p8##_type, \
2245 typename p9##_type>\
2246 template <typename arg_type>\
2247 bool name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
zhanyong.wan82113312010-01-08 21:55:40 +00002248 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
2249 p9##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
jgm79a367e2012-04-10 16:02:11 +00002250 arg_type arg, \
zhanyong.wan82113312010-01-08 21:55:40 +00002251 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
2252 const
zhanyong.wance198ff2009-02-12 01:34:27 +00002253
shiqiane35fdd92008-12-10 05:08:54 +00002254#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_