1
// This file was GENERATED by command:
2
// pump.py gmock-generated-matchers.h.pump
3
// DO NOT EDIT BY HAND!!!
5
// Copyright 2008, Google Inc.
6
// All rights reserved.
8
// Redistribution and use in source and binary forms, with or without
9
// modification, are permitted provided that the following conditions are
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
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.
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.
34
// Google Mock - a framework for writing C++ mock classes.
36
// This file implements some commonly used variadic matchers.
38
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
39
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
45
#include "gmock/gmock-matchers.h"
50
// 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
54
// TupleFields<Tuple, k0, ..., kn> is for selecting fields from a
55
// tuple of type Tuple. It has two members:
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.
60
// For example, in class TupleFields<tuple<bool, char, int>, 2, 0>, we have:
62
// type is tuple<int, bool>, and
63
// GetSelectedFields(make_tuple(true, 'a', 42)) is (42, true).
65
template <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,
70
// This generic version is used when there are 10 selectors.
71
template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
72
int k7, int k8, int k9>
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));
88
// The following specialization is used for 0 ~ 9 selectors.
90
template <class Tuple>
91
class TupleFields<Tuple, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
93
typedef ::std::tr1::tuple<> type;
94
static type GetSelectedFields(const Tuple& /* t */) {
95
using ::std::tr1::get;
100
template <class Tuple, int k0>
101
class TupleFields<Tuple, k0, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
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));
110
template <class Tuple, int k0, int k1>
111
class TupleFields<Tuple, k0, k1, -1, -1, -1, -1, -1, -1, -1, -1> {
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));
121
template <class Tuple, int k0, int k1, int k2>
122
class TupleFields<Tuple, k0, k1, k2, -1, -1, -1, -1, -1, -1, -1> {
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));
132
template <class Tuple, int k0, int k1, int k2, int k3>
133
class TupleFields<Tuple, k0, k1, k2, k3, -1, -1, -1, -1, -1, -1> {
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));
144
template <class Tuple, int k0, int k1, int k2, int k3, int k4>
145
class TupleFields<Tuple, k0, k1, k2, k3, k4, -1, -1, -1, -1, -1> {
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));
156
template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5>
157
class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, -1, -1, -1, -1> {
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),
170
template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6>
171
class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, -1, -1, -1> {
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));
184
template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
186
class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, -1, -1> {
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));
200
template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
202
class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, k8, -1> {
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));
216
#undef GMOCK_FIELD_TYPE_
218
// Implements the Args() matcher.
219
template <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,
222
class ArgsMatcherImpl : public MatcherInterface<ArgsTuple> {
224
// ArgsTuple may have top-level const or reference modifiers.
225
typedef GTEST_REMOVE_REFERENCE_AND_CONST_(ArgsTuple) RawArgsTuple;
226
typedef typename internal::TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5,
227
k6, k7, k8, k9>::type SelectedArgs;
228
typedef Matcher<const SelectedArgs&> MonomorphicInnerMatcher;
230
template <typename InnerMatcher>
231
explicit ArgsMatcherImpl(const InnerMatcher& inner_matcher)
232
: inner_matcher_(SafeMatcherCast<const SelectedArgs&>(inner_matcher)) {}
234
virtual bool MatchAndExplain(ArgsTuple args,
235
MatchResultListener* listener) const {
236
const SelectedArgs& selected_args = GetSelectedArgs(args);
237
if (!listener->IsInterested())
238
return inner_matcher_.Matches(selected_args);
240
PrintIndices(listener->stream());
241
*listener << "are " << PrintToString(selected_args);
243
StringMatchResultListener inner_listener;
244
const bool match = inner_matcher_.MatchAndExplain(selected_args,
246
PrintIfNotEmpty(inner_listener.str(), listener->stream());
250
virtual void DescribeTo(::std::ostream* os) const {
251
*os << "are a tuple ";
253
inner_matcher_.DescribeTo(os);
256
virtual void DescribeNegationTo(::std::ostream* os) const {
257
*os << "are a tuple ";
259
inner_matcher_.DescribeNegationTo(os);
263
static SelectedArgs GetSelectedArgs(ArgsTuple args) {
264
return TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5, k6, k7, k8,
265
k9>::GetSelectedFields(args);
268
// Prints the indices of the selected fields.
269
static void PrintIndices(::std::ostream* os) {
270
*os << "whose fields (";
271
const int indices[10] = { k0, k1, k2, k3, k4, k5, k6, k7, k8, k9 };
272
for (int i = 0; i < 10; i++) {
279
*os << "#" << indices[i];
284
const MonomorphicInnerMatcher inner_matcher_;
286
GTEST_DISALLOW_ASSIGN_(ArgsMatcherImpl);
289
template <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>
294
explicit ArgsMatcher(const InnerMatcher& inner_matcher)
295
: inner_matcher_(inner_matcher) {}
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_));
304
const InnerMatcher inner_matcher_;
306
GTEST_DISALLOW_ASSIGN_(ArgsMatcher);
309
// A set of metafunctions for computing the result type of AllOf.
310
// AllOf(m1, ..., mN) returns
311
// AllOfResultN<decltype(m1), ..., decltype(mN)>::type.
313
// Although AllOf isn't defined for one argument, AllOfResult1 is defined
314
// to simplify the implementation.
315
template <typename M1>
316
struct AllOfResult1 {
320
template <typename M1, typename M2>
321
struct AllOfResult2 {
322
typedef BothOfMatcher<
323
typename AllOfResult1<M1>::type,
324
typename AllOfResult1<M2>::type
328
template <typename M1, typename M2, typename M3>
329
struct AllOfResult3 {
330
typedef BothOfMatcher<
331
typename AllOfResult1<M1>::type,
332
typename AllOfResult2<M2, M3>::type
336
template <typename M1, typename M2, typename M3, typename M4>
337
struct AllOfResult4 {
338
typedef BothOfMatcher<
339
typename AllOfResult2<M1, M2>::type,
340
typename AllOfResult2<M3, M4>::type
344
template <typename M1, typename M2, typename M3, typename M4, typename M5>
345
struct AllOfResult5 {
346
typedef BothOfMatcher<
347
typename AllOfResult2<M1, M2>::type,
348
typename AllOfResult3<M3, M4, M5>::type
352
template <typename M1, typename M2, typename M3, typename M4, typename M5,
354
struct AllOfResult6 {
355
typedef BothOfMatcher<
356
typename AllOfResult3<M1, M2, M3>::type,
357
typename AllOfResult3<M4, M5, M6>::type
361
template <typename M1, typename M2, typename M3, typename M4, typename M5,
362
typename M6, typename M7>
363
struct AllOfResult7 {
364
typedef BothOfMatcher<
365
typename AllOfResult3<M1, M2, M3>::type,
366
typename AllOfResult4<M4, M5, M6, M7>::type
370
template <typename M1, typename M2, typename M3, typename M4, typename M5,
371
typename M6, typename M7, typename M8>
372
struct AllOfResult8 {
373
typedef BothOfMatcher<
374
typename AllOfResult4<M1, M2, M3, M4>::type,
375
typename AllOfResult4<M5, M6, M7, M8>::type
379
template <typename M1, typename M2, typename M3, typename M4, typename M5,
380
typename M6, typename M7, typename M8, typename M9>
381
struct AllOfResult9 {
382
typedef BothOfMatcher<
383
typename AllOfResult4<M1, M2, M3, M4>::type,
384
typename AllOfResult5<M5, M6, M7, M8, M9>::type
388
template <typename M1, typename M2, typename M3, typename M4, typename M5,
389
typename M6, typename M7, typename M8, typename M9, typename M10>
390
struct AllOfResult10 {
391
typedef BothOfMatcher<
392
typename AllOfResult5<M1, M2, M3, M4, M5>::type,
393
typename AllOfResult5<M6, M7, M8, M9, M10>::type
397
// A set of metafunctions for computing the result type of AnyOf.
398
// AnyOf(m1, ..., mN) returns
399
// AnyOfResultN<decltype(m1), ..., decltype(mN)>::type.
401
// Although AnyOf isn't defined for one argument, AnyOfResult1 is defined
402
// to simplify the implementation.
403
template <typename M1>
404
struct AnyOfResult1 {
408
template <typename M1, typename M2>
409
struct AnyOfResult2 {
410
typedef EitherOfMatcher<
411
typename AnyOfResult1<M1>::type,
412
typename AnyOfResult1<M2>::type
416
template <typename M1, typename M2, typename M3>
417
struct AnyOfResult3 {
418
typedef EitherOfMatcher<
419
typename AnyOfResult1<M1>::type,
420
typename AnyOfResult2<M2, M3>::type
424
template <typename M1, typename M2, typename M3, typename M4>
425
struct AnyOfResult4 {
426
typedef EitherOfMatcher<
427
typename AnyOfResult2<M1, M2>::type,
428
typename AnyOfResult2<M3, M4>::type
432
template <typename M1, typename M2, typename M3, typename M4, typename M5>
433
struct AnyOfResult5 {
434
typedef EitherOfMatcher<
435
typename AnyOfResult2<M1, M2>::type,
436
typename AnyOfResult3<M3, M4, M5>::type
440
template <typename M1, typename M2, typename M3, typename M4, typename M5,
442
struct AnyOfResult6 {
443
typedef EitherOfMatcher<
444
typename AnyOfResult3<M1, M2, M3>::type,
445
typename AnyOfResult3<M4, M5, M6>::type
449
template <typename M1, typename M2, typename M3, typename M4, typename M5,
450
typename M6, typename M7>
451
struct AnyOfResult7 {
452
typedef EitherOfMatcher<
453
typename AnyOfResult3<M1, M2, M3>::type,
454
typename AnyOfResult4<M4, M5, M6, M7>::type
458
template <typename M1, typename M2, typename M3, typename M4, typename M5,
459
typename M6, typename M7, typename M8>
460
struct AnyOfResult8 {
461
typedef EitherOfMatcher<
462
typename AnyOfResult4<M1, M2, M3, M4>::type,
463
typename AnyOfResult4<M5, M6, M7, M8>::type
467
template <typename M1, typename M2, typename M3, typename M4, typename M5,
468
typename M6, typename M7, typename M8, typename M9>
469
struct AnyOfResult9 {
470
typedef EitherOfMatcher<
471
typename AnyOfResult4<M1, M2, M3, M4>::type,
472
typename AnyOfResult5<M5, M6, M7, M8, M9>::type
476
template <typename M1, typename M2, typename M3, typename M4, typename M5,
477
typename M6, typename M7, typename M8, typename M9, typename M10>
478
struct AnyOfResult10 {
479
typedef EitherOfMatcher<
480
typename AnyOfResult5<M1, M2, M3, M4, M5>::type,
481
typename AnyOfResult5<M6, M7, M8, M9, M10>::type
485
} // namespace internal
487
// Args<N1, N2, ..., Nk>(a_matcher) matches a tuple if the selected
488
// fields of it matches a_matcher. C++ doesn't support default
489
// arguments for function templates, so we have to overload it.
490
template <typename InnerMatcher>
491
inline internal::ArgsMatcher<InnerMatcher>
492
Args(const InnerMatcher& matcher) {
493
return internal::ArgsMatcher<InnerMatcher>(matcher);
496
template <int k1, typename InnerMatcher>
497
inline internal::ArgsMatcher<InnerMatcher, k1>
498
Args(const InnerMatcher& matcher) {
499
return internal::ArgsMatcher<InnerMatcher, k1>(matcher);
502
template <int k1, int k2, typename InnerMatcher>
503
inline internal::ArgsMatcher<InnerMatcher, k1, k2>
504
Args(const InnerMatcher& matcher) {
505
return internal::ArgsMatcher<InnerMatcher, k1, k2>(matcher);
508
template <int k1, int k2, int k3, typename InnerMatcher>
509
inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3>
510
Args(const InnerMatcher& matcher) {
511
return internal::ArgsMatcher<InnerMatcher, k1, k2, k3>(matcher);
514
template <int k1, int k2, int k3, int k4, typename InnerMatcher>
515
inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>
516
Args(const InnerMatcher& matcher) {
517
return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>(matcher);
520
template <int k1, int k2, int k3, int k4, int k5, typename InnerMatcher>
521
inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>
522
Args(const InnerMatcher& matcher) {
523
return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>(matcher);
526
template <int k1, int k2, int k3, int k4, int k5, int k6, typename InnerMatcher>
527
inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>
528
Args(const InnerMatcher& matcher) {
529
return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>(matcher);
532
template <int k1, int k2, int k3, int k4, int k5, int k6, int k7,
533
typename InnerMatcher>
534
inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7>
535
Args(const InnerMatcher& matcher) {
536
return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6,
540
template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
541
typename InnerMatcher>
542
inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8>
543
Args(const InnerMatcher& matcher) {
544
return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7,
548
template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
549
int k9, typename InnerMatcher>
550
inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9>
551
Args(const InnerMatcher& matcher) {
552
return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
556
template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
557
int k9, int k10, typename InnerMatcher>
558
inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9,
560
Args(const InnerMatcher& matcher) {
561
return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
565
// ElementsAre(e_1, e_2, ... e_n) matches an STL-style container with
566
// n elements, where the i-th element in the container must
567
// match the i-th argument in the list. Each argument of
568
// ElementsAre() can be either a value or a matcher. We support up to
571
// The use of DecayArray in the implementation allows ElementsAre()
572
// to accept string literals, whose type is const char[N], but we
573
// want to treat them as const char*.
575
// NOTE: Since ElementsAre() cares about the order of the elements, it
576
// must not be used with containers whose elements's order is
577
// undefined (e.g. hash_map).
579
inline internal::ElementsAreMatcher<
582
typedef std::tr1::tuple<> Args;
583
return internal::ElementsAreMatcher<Args>(Args());
586
template <typename T1>
587
inline internal::ElementsAreMatcher<
589
typename internal::DecayArray<T1>::type> >
590
ElementsAre(const T1& e1) {
591
typedef std::tr1::tuple<
592
typename internal::DecayArray<T1>::type> Args;
593
return internal::ElementsAreMatcher<Args>(Args(e1));
596
template <typename T1, typename T2>
597
inline internal::ElementsAreMatcher<
599
typename internal::DecayArray<T1>::type,
600
typename internal::DecayArray<T2>::type> >
601
ElementsAre(const T1& e1, const T2& e2) {
602
typedef std::tr1::tuple<
603
typename internal::DecayArray<T1>::type,
604
typename internal::DecayArray<T2>::type> Args;
605
return internal::ElementsAreMatcher<Args>(Args(e1, e2));
608
template <typename T1, typename T2, typename T3>
609
inline internal::ElementsAreMatcher<
611
typename internal::DecayArray<T1>::type,
612
typename internal::DecayArray<T2>::type,
613
typename internal::DecayArray<T3>::type> >
614
ElementsAre(const T1& e1, const T2& e2, const T3& e3) {
615
typedef std::tr1::tuple<
616
typename internal::DecayArray<T1>::type,
617
typename internal::DecayArray<T2>::type,
618
typename internal::DecayArray<T3>::type> Args;
619
return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3));
622
template <typename T1, typename T2, typename T3, typename T4>
623
inline internal::ElementsAreMatcher<
625
typename internal::DecayArray<T1>::type,
626
typename internal::DecayArray<T2>::type,
627
typename internal::DecayArray<T3>::type,
628
typename internal::DecayArray<T4>::type> >
629
ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4) {
630
typedef std::tr1::tuple<
631
typename internal::DecayArray<T1>::type,
632
typename internal::DecayArray<T2>::type,
633
typename internal::DecayArray<T3>::type,
634
typename internal::DecayArray<T4>::type> Args;
635
return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4));
638
template <typename T1, typename T2, typename T3, typename T4, typename T5>
639
inline internal::ElementsAreMatcher<
641
typename internal::DecayArray<T1>::type,
642
typename internal::DecayArray<T2>::type,
643
typename internal::DecayArray<T3>::type,
644
typename internal::DecayArray<T4>::type,
645
typename internal::DecayArray<T5>::type> >
646
ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
648
typedef std::tr1::tuple<
649
typename internal::DecayArray<T1>::type,
650
typename internal::DecayArray<T2>::type,
651
typename internal::DecayArray<T3>::type,
652
typename internal::DecayArray<T4>::type,
653
typename internal::DecayArray<T5>::type> Args;
654
return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5));
657
template <typename T1, typename T2, typename T3, typename T4, typename T5,
659
inline internal::ElementsAreMatcher<
661
typename internal::DecayArray<T1>::type,
662
typename internal::DecayArray<T2>::type,
663
typename internal::DecayArray<T3>::type,
664
typename internal::DecayArray<T4>::type,
665
typename internal::DecayArray<T5>::type,
666
typename internal::DecayArray<T6>::type> >
667
ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
668
const T5& e5, const T6& e6) {
669
typedef std::tr1::tuple<
670
typename internal::DecayArray<T1>::type,
671
typename internal::DecayArray<T2>::type,
672
typename internal::DecayArray<T3>::type,
673
typename internal::DecayArray<T4>::type,
674
typename internal::DecayArray<T5>::type,
675
typename internal::DecayArray<T6>::type> Args;
676
return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6));
679
template <typename T1, typename T2, typename T3, typename T4, typename T5,
680
typename T6, typename T7>
681
inline internal::ElementsAreMatcher<
683
typename internal::DecayArray<T1>::type,
684
typename internal::DecayArray<T2>::type,
685
typename internal::DecayArray<T3>::type,
686
typename internal::DecayArray<T4>::type,
687
typename internal::DecayArray<T5>::type,
688
typename internal::DecayArray<T6>::type,
689
typename internal::DecayArray<T7>::type> >
690
ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
691
const T5& e5, const T6& e6, const T7& e7) {
692
typedef std::tr1::tuple<
693
typename internal::DecayArray<T1>::type,
694
typename internal::DecayArray<T2>::type,
695
typename internal::DecayArray<T3>::type,
696
typename internal::DecayArray<T4>::type,
697
typename internal::DecayArray<T5>::type,
698
typename internal::DecayArray<T6>::type,
699
typename internal::DecayArray<T7>::type> Args;
700
return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7));
703
template <typename T1, typename T2, typename T3, typename T4, typename T5,
704
typename T6, typename T7, typename T8>
705
inline internal::ElementsAreMatcher<
707
typename internal::DecayArray<T1>::type,
708
typename internal::DecayArray<T2>::type,
709
typename internal::DecayArray<T3>::type,
710
typename internal::DecayArray<T4>::type,
711
typename internal::DecayArray<T5>::type,
712
typename internal::DecayArray<T6>::type,
713
typename internal::DecayArray<T7>::type,
714
typename internal::DecayArray<T8>::type> >
715
ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
716
const T5& e5, const T6& e6, const T7& e7, const T8& e8) {
717
typedef std::tr1::tuple<
718
typename internal::DecayArray<T1>::type,
719
typename internal::DecayArray<T2>::type,
720
typename internal::DecayArray<T3>::type,
721
typename internal::DecayArray<T4>::type,
722
typename internal::DecayArray<T5>::type,
723
typename internal::DecayArray<T6>::type,
724
typename internal::DecayArray<T7>::type,
725
typename internal::DecayArray<T8>::type> Args;
726
return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7,
730
template <typename T1, typename T2, typename T3, typename T4, typename T5,
731
typename T6, typename T7, typename T8, typename T9>
732
inline internal::ElementsAreMatcher<
734
typename internal::DecayArray<T1>::type,
735
typename internal::DecayArray<T2>::type,
736
typename internal::DecayArray<T3>::type,
737
typename internal::DecayArray<T4>::type,
738
typename internal::DecayArray<T5>::type,
739
typename internal::DecayArray<T6>::type,
740
typename internal::DecayArray<T7>::type,
741
typename internal::DecayArray<T8>::type,
742
typename internal::DecayArray<T9>::type> >
743
ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
744
const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9) {
745
typedef std::tr1::tuple<
746
typename internal::DecayArray<T1>::type,
747
typename internal::DecayArray<T2>::type,
748
typename internal::DecayArray<T3>::type,
749
typename internal::DecayArray<T4>::type,
750
typename internal::DecayArray<T5>::type,
751
typename internal::DecayArray<T6>::type,
752
typename internal::DecayArray<T7>::type,
753
typename internal::DecayArray<T8>::type,
754
typename internal::DecayArray<T9>::type> Args;
755
return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7,
759
template <typename T1, typename T2, typename T3, typename T4, typename T5,
760
typename T6, typename T7, typename T8, typename T9, typename T10>
761
inline internal::ElementsAreMatcher<
763
typename internal::DecayArray<T1>::type,
764
typename internal::DecayArray<T2>::type,
765
typename internal::DecayArray<T3>::type,
766
typename internal::DecayArray<T4>::type,
767
typename internal::DecayArray<T5>::type,
768
typename internal::DecayArray<T6>::type,
769
typename internal::DecayArray<T7>::type,
770
typename internal::DecayArray<T8>::type,
771
typename internal::DecayArray<T9>::type,
772
typename internal::DecayArray<T10>::type> >
773
ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
774
const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,
776
typedef std::tr1::tuple<
777
typename internal::DecayArray<T1>::type,
778
typename internal::DecayArray<T2>::type,
779
typename internal::DecayArray<T3>::type,
780
typename internal::DecayArray<T4>::type,
781
typename internal::DecayArray<T5>::type,
782
typename internal::DecayArray<T6>::type,
783
typename internal::DecayArray<T7>::type,
784
typename internal::DecayArray<T8>::type,
785
typename internal::DecayArray<T9>::type,
786
typename internal::DecayArray<T10>::type> Args;
787
return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7,
791
// UnorderedElementsAre(e_1, e_2, ..., e_n) is an ElementsAre extension
792
// that matches n elements in any order. We support up to n=10 arguments.
794
inline internal::UnorderedElementsAreMatcher<
796
UnorderedElementsAre() {
797
typedef std::tr1::tuple<> Args;
798
return internal::UnorderedElementsAreMatcher<Args>(Args());
801
template <typename T1>
802
inline internal::UnorderedElementsAreMatcher<
804
typename internal::DecayArray<T1>::type> >
805
UnorderedElementsAre(const T1& e1) {
806
typedef std::tr1::tuple<
807
typename internal::DecayArray<T1>::type> Args;
808
return internal::UnorderedElementsAreMatcher<Args>(Args(e1));
811
template <typename T1, typename T2>
812
inline internal::UnorderedElementsAreMatcher<
814
typename internal::DecayArray<T1>::type,
815
typename internal::DecayArray<T2>::type> >
816
UnorderedElementsAre(const T1& e1, const T2& e2) {
817
typedef std::tr1::tuple<
818
typename internal::DecayArray<T1>::type,
819
typename internal::DecayArray<T2>::type> Args;
820
return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2));
823
template <typename T1, typename T2, typename T3>
824
inline internal::UnorderedElementsAreMatcher<
826
typename internal::DecayArray<T1>::type,
827
typename internal::DecayArray<T2>::type,
828
typename internal::DecayArray<T3>::type> >
829
UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3) {
830
typedef std::tr1::tuple<
831
typename internal::DecayArray<T1>::type,
832
typename internal::DecayArray<T2>::type,
833
typename internal::DecayArray<T3>::type> Args;
834
return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3));
837
template <typename T1, typename T2, typename T3, typename T4>
838
inline internal::UnorderedElementsAreMatcher<
840
typename internal::DecayArray<T1>::type,
841
typename internal::DecayArray<T2>::type,
842
typename internal::DecayArray<T3>::type,
843
typename internal::DecayArray<T4>::type> >
844
UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4) {
845
typedef std::tr1::tuple<
846
typename internal::DecayArray<T1>::type,
847
typename internal::DecayArray<T2>::type,
848
typename internal::DecayArray<T3>::type,
849
typename internal::DecayArray<T4>::type> Args;
850
return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4));
853
template <typename T1, typename T2, typename T3, typename T4, typename T5>
854
inline internal::UnorderedElementsAreMatcher<
856
typename internal::DecayArray<T1>::type,
857
typename internal::DecayArray<T2>::type,
858
typename internal::DecayArray<T3>::type,
859
typename internal::DecayArray<T4>::type,
860
typename internal::DecayArray<T5>::type> >
861
UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
863
typedef std::tr1::tuple<
864
typename internal::DecayArray<T1>::type,
865
typename internal::DecayArray<T2>::type,
866
typename internal::DecayArray<T3>::type,
867
typename internal::DecayArray<T4>::type,
868
typename internal::DecayArray<T5>::type> Args;
869
return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5));
872
template <typename T1, typename T2, typename T3, typename T4, typename T5,
874
inline internal::UnorderedElementsAreMatcher<
876
typename internal::DecayArray<T1>::type,
877
typename internal::DecayArray<T2>::type,
878
typename internal::DecayArray<T3>::type,
879
typename internal::DecayArray<T4>::type,
880
typename internal::DecayArray<T5>::type,
881
typename internal::DecayArray<T6>::type> >
882
UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
883
const T5& e5, const T6& e6) {
884
typedef std::tr1::tuple<
885
typename internal::DecayArray<T1>::type,
886
typename internal::DecayArray<T2>::type,
887
typename internal::DecayArray<T3>::type,
888
typename internal::DecayArray<T4>::type,
889
typename internal::DecayArray<T5>::type,
890
typename internal::DecayArray<T6>::type> Args;
891
return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
895
template <typename T1, typename T2, typename T3, typename T4, typename T5,
896
typename T6, typename T7>
897
inline internal::UnorderedElementsAreMatcher<
899
typename internal::DecayArray<T1>::type,
900
typename internal::DecayArray<T2>::type,
901
typename internal::DecayArray<T3>::type,
902
typename internal::DecayArray<T4>::type,
903
typename internal::DecayArray<T5>::type,
904
typename internal::DecayArray<T6>::type,
905
typename internal::DecayArray<T7>::type> >
906
UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
907
const T5& e5, const T6& e6, const T7& e7) {
908
typedef std::tr1::tuple<
909
typename internal::DecayArray<T1>::type,
910
typename internal::DecayArray<T2>::type,
911
typename internal::DecayArray<T3>::type,
912
typename internal::DecayArray<T4>::type,
913
typename internal::DecayArray<T5>::type,
914
typename internal::DecayArray<T6>::type,
915
typename internal::DecayArray<T7>::type> Args;
916
return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
920
template <typename T1, typename T2, typename T3, typename T4, typename T5,
921
typename T6, typename T7, typename T8>
922
inline internal::UnorderedElementsAreMatcher<
924
typename internal::DecayArray<T1>::type,
925
typename internal::DecayArray<T2>::type,
926
typename internal::DecayArray<T3>::type,
927
typename internal::DecayArray<T4>::type,
928
typename internal::DecayArray<T5>::type,
929
typename internal::DecayArray<T6>::type,
930
typename internal::DecayArray<T7>::type,
931
typename internal::DecayArray<T8>::type> >
932
UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
933
const T5& e5, const T6& e6, const T7& e7, const T8& e8) {
934
typedef std::tr1::tuple<
935
typename internal::DecayArray<T1>::type,
936
typename internal::DecayArray<T2>::type,
937
typename internal::DecayArray<T3>::type,
938
typename internal::DecayArray<T4>::type,
939
typename internal::DecayArray<T5>::type,
940
typename internal::DecayArray<T6>::type,
941
typename internal::DecayArray<T7>::type,
942
typename internal::DecayArray<T8>::type> Args;
943
return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
947
template <typename T1, typename T2, typename T3, typename T4, typename T5,
948
typename T6, typename T7, typename T8, typename T9>
949
inline internal::UnorderedElementsAreMatcher<
951
typename internal::DecayArray<T1>::type,
952
typename internal::DecayArray<T2>::type,
953
typename internal::DecayArray<T3>::type,
954
typename internal::DecayArray<T4>::type,
955
typename internal::DecayArray<T5>::type,
956
typename internal::DecayArray<T6>::type,
957
typename internal::DecayArray<T7>::type,
958
typename internal::DecayArray<T8>::type,
959
typename internal::DecayArray<T9>::type> >
960
UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
961
const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9) {
962
typedef std::tr1::tuple<
963
typename internal::DecayArray<T1>::type,
964
typename internal::DecayArray<T2>::type,
965
typename internal::DecayArray<T3>::type,
966
typename internal::DecayArray<T4>::type,
967
typename internal::DecayArray<T5>::type,
968
typename internal::DecayArray<T6>::type,
969
typename internal::DecayArray<T7>::type,
970
typename internal::DecayArray<T8>::type,
971
typename internal::DecayArray<T9>::type> Args;
972
return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
976
template <typename T1, typename T2, typename T3, typename T4, typename T5,
977
typename T6, typename T7, typename T8, typename T9, typename T10>
978
inline internal::UnorderedElementsAreMatcher<
980
typename internal::DecayArray<T1>::type,
981
typename internal::DecayArray<T2>::type,
982
typename internal::DecayArray<T3>::type,
983
typename internal::DecayArray<T4>::type,
984
typename internal::DecayArray<T5>::type,
985
typename internal::DecayArray<T6>::type,
986
typename internal::DecayArray<T7>::type,
987
typename internal::DecayArray<T8>::type,
988
typename internal::DecayArray<T9>::type,
989
typename internal::DecayArray<T10>::type> >
990
UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
991
const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,
993
typedef std::tr1::tuple<
994
typename internal::DecayArray<T1>::type,
995
typename internal::DecayArray<T2>::type,
996
typename internal::DecayArray<T3>::type,
997
typename internal::DecayArray<T4>::type,
998
typename internal::DecayArray<T5>::type,
999
typename internal::DecayArray<T6>::type,
1000
typename internal::DecayArray<T7>::type,
1001
typename internal::DecayArray<T8>::type,
1002
typename internal::DecayArray<T9>::type,
1003
typename internal::DecayArray<T10>::type> Args;
1004
return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
1005
e6, e7, e8, e9, e10));
1008
// AllOf(m1, m2, ..., mk) matches any value that matches all of the given
1009
// sub-matchers. AllOf is called fully qualified to prevent ADL from firing.
1011
template <typename M1, typename M2>
1012
inline typename internal::AllOfResult2<M1, M2>::type
1013
AllOf(M1 m1, M2 m2) {
1014
return typename internal::AllOfResult2<M1, M2>::type(
1019
template <typename M1, typename M2, typename M3>
1020
inline typename internal::AllOfResult3<M1, M2, M3>::type
1021
AllOf(M1 m1, M2 m2, M3 m3) {
1022
return typename internal::AllOfResult3<M1, M2, M3>::type(
1024
::testing::AllOf(m2, m3));
1027
template <typename M1, typename M2, typename M3, typename M4>
1028
inline typename internal::AllOfResult4<M1, M2, M3, M4>::type
1029
AllOf(M1 m1, M2 m2, M3 m3, M4 m4) {
1030
return typename internal::AllOfResult4<M1, M2, M3, M4>::type(
1031
::testing::AllOf(m1, m2),
1032
::testing::AllOf(m3, m4));
1035
template <typename M1, typename M2, typename M3, typename M4, typename M5>
1036
inline typename internal::AllOfResult5<M1, M2, M3, M4, M5>::type
1037
AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5) {
1038
return typename internal::AllOfResult5<M1, M2, M3, M4, M5>::type(
1039
::testing::AllOf(m1, m2),
1040
::testing::AllOf(m3, m4, m5));
1043
template <typename M1, typename M2, typename M3, typename M4, typename M5,
1045
inline typename internal::AllOfResult6<M1, M2, M3, M4, M5, M6>::type
1046
AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6) {
1047
return typename internal::AllOfResult6<M1, M2, M3, M4, M5, M6>::type(
1048
::testing::AllOf(m1, m2, m3),
1049
::testing::AllOf(m4, m5, m6));
1052
template <typename M1, typename M2, typename M3, typename M4, typename M5,
1053
typename M6, typename M7>
1054
inline typename internal::AllOfResult7<M1, M2, M3, M4, M5, M6, M7>::type
1055
AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7) {
1056
return typename internal::AllOfResult7<M1, M2, M3, M4, M5, M6, M7>::type(
1057
::testing::AllOf(m1, m2, m3),
1058
::testing::AllOf(m4, m5, m6, m7));
1061
template <typename M1, typename M2, typename M3, typename M4, typename M5,
1062
typename M6, typename M7, typename M8>
1063
inline typename internal::AllOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type
1064
AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8) {
1065
return typename internal::AllOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type(
1066
::testing::AllOf(m1, m2, m3, m4),
1067
::testing::AllOf(m5, m6, m7, m8));
1070
template <typename M1, typename M2, typename M3, typename M4, typename M5,
1071
typename M6, typename M7, typename M8, typename M9>
1072
inline typename internal::AllOfResult9<M1, M2, M3, M4, M5, M6, M7, M8, M9>::type
1073
AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9) {
1074
return typename internal::AllOfResult9<M1, M2, M3, M4, M5, M6, M7, M8,
1076
::testing::AllOf(m1, m2, m3, m4),
1077
::testing::AllOf(m5, m6, m7, m8, m9));
1080
template <typename M1, typename M2, typename M3, typename M4, typename M5,
1081
typename M6, typename M7, typename M8, typename M9, typename M10>
1082
inline typename internal::AllOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
1084
AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
1085
return typename internal::AllOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
1087
::testing::AllOf(m1, m2, m3, m4, m5),
1088
::testing::AllOf(m6, m7, m8, m9, m10));
1091
// AnyOf(m1, m2, ..., mk) matches any value that matches any of the given
1092
// sub-matchers. AnyOf is called fully qualified to prevent ADL from firing.
1094
template <typename M1, typename M2>
1095
inline typename internal::AnyOfResult2<M1, M2>::type
1096
AnyOf(M1 m1, M2 m2) {
1097
return typename internal::AnyOfResult2<M1, M2>::type(
1102
template <typename M1, typename M2, typename M3>
1103
inline typename internal::AnyOfResult3<M1, M2, M3>::type
1104
AnyOf(M1 m1, M2 m2, M3 m3) {
1105
return typename internal::AnyOfResult3<M1, M2, M3>::type(
1107
::testing::AnyOf(m2, m3));
1110
template <typename M1, typename M2, typename M3, typename M4>
1111
inline typename internal::AnyOfResult4<M1, M2, M3, M4>::type
1112
AnyOf(M1 m1, M2 m2, M3 m3, M4 m4) {
1113
return typename internal::AnyOfResult4<M1, M2, M3, M4>::type(
1114
::testing::AnyOf(m1, m2),
1115
::testing::AnyOf(m3, m4));
1118
template <typename M1, typename M2, typename M3, typename M4, typename M5>
1119
inline typename internal::AnyOfResult5<M1, M2, M3, M4, M5>::type
1120
AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5) {
1121
return typename internal::AnyOfResult5<M1, M2, M3, M4, M5>::type(
1122
::testing::AnyOf(m1, m2),
1123
::testing::AnyOf(m3, m4, m5));
1126
template <typename M1, typename M2, typename M3, typename M4, typename M5,
1128
inline typename internal::AnyOfResult6<M1, M2, M3, M4, M5, M6>::type
1129
AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6) {
1130
return typename internal::AnyOfResult6<M1, M2, M3, M4, M5, M6>::type(
1131
::testing::AnyOf(m1, m2, m3),
1132
::testing::AnyOf(m4, m5, m6));
1135
template <typename M1, typename M2, typename M3, typename M4, typename M5,
1136
typename M6, typename M7>
1137
inline typename internal::AnyOfResult7<M1, M2, M3, M4, M5, M6, M7>::type
1138
AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7) {
1139
return typename internal::AnyOfResult7<M1, M2, M3, M4, M5, M6, M7>::type(
1140
::testing::AnyOf(m1, m2, m3),
1141
::testing::AnyOf(m4, m5, m6, m7));
1144
template <typename M1, typename M2, typename M3, typename M4, typename M5,
1145
typename M6, typename M7, typename M8>
1146
inline typename internal::AnyOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type
1147
AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8) {
1148
return typename internal::AnyOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type(
1149
::testing::AnyOf(m1, m2, m3, m4),
1150
::testing::AnyOf(m5, m6, m7, m8));
1153
template <typename M1, typename M2, typename M3, typename M4, typename M5,
1154
typename M6, typename M7, typename M8, typename M9>
1155
inline typename internal::AnyOfResult9<M1, M2, M3, M4, M5, M6, M7, M8, M9>::type
1156
AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9) {
1157
return typename internal::AnyOfResult9<M1, M2, M3, M4, M5, M6, M7, M8,
1159
::testing::AnyOf(m1, m2, m3, m4),
1160
::testing::AnyOf(m5, m6, m7, m8, m9));
1163
template <typename M1, typename M2, typename M3, typename M4, typename M5,
1164
typename M6, typename M7, typename M8, typename M9, typename M10>
1165
inline typename internal::AnyOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
1167
AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
1168
return typename internal::AnyOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
1170
::testing::AnyOf(m1, m2, m3, m4, m5),
1171
::testing::AnyOf(m6, m7, m8, m9, m10));
1174
} // namespace testing
1177
// The MATCHER* family of macros can be used in a namespace scope to
1178
// define custom matchers easily.
1185
// MATCHER(name, description_string) { statements; }
1187
// defines a matcher with the given name that executes the statements,
1188
// which must return a bool to indicate if the match succeeds. Inside
1189
// the statements, you can refer to the value being matched by 'arg',
1190
// and refer to its type by 'arg_type'.
1192
// The description string documents what the matcher does, and is used
1193
// to generate the failure message when the match fails. Since a
1194
// MATCHER() is usually defined in a header file shared by multiple
1195
// C++ source files, we require the description to be a C-string
1196
// literal to avoid possible side effects. It can be empty, in which
1197
// case we'll use the sequence of words in the matcher name as the
1202
// MATCHER(IsEven, "") { return (arg % 2) == 0; }
1204
// allows you to write
1206
// // Expects mock_foo.Bar(n) to be called where n is even.
1207
// EXPECT_CALL(mock_foo, Bar(IsEven()));
1211
// // Verifies that the value of some_expression is even.
1212
// EXPECT_THAT(some_expression, IsEven());
1214
// If the above assertion fails, it will print something like:
1216
// Value of: some_expression
1217
// Expected: is even
1220
// where the description "is even" is automatically calculated from the
1221
// matcher name IsEven.
1226
// Note that the type of the value being matched (arg_type) is
1227
// determined by the context in which you use the matcher and is
1228
// supplied to you by the compiler, so you don't need to worry about
1229
// declaring it (nor can you). This allows the matcher to be
1230
// polymorphic. For example, IsEven() can be used to match any type
1231
// where the value of "(arg % 2) == 0" can be implicitly converted to
1232
// a bool. In the "Bar(IsEven())" example above, if method Bar()
1233
// takes an int, 'arg_type' will be int; if it takes an unsigned long,
1234
// 'arg_type' will be unsigned long; and so on.
1236
// Parameterizing Matchers
1237
// =======================
1239
// Sometimes you'll want to parameterize the matcher. For that you
1240
// can use another macro:
1242
// MATCHER_P(name, param_name, description_string) { statements; }
1246
// MATCHER_P(HasAbsoluteValue, value, "") { return abs(arg) == value; }
1248
// will allow you to write:
1250
// EXPECT_THAT(Blah("a"), HasAbsoluteValue(n));
1252
// which may lead to this message (assuming n is 10):
1254
// Value of: Blah("a")
1255
// Expected: has absolute value 10
1258
// Note that both the matcher description and its parameter are
1259
// printed, making the message human-friendly.
1261
// In the matcher definition body, you can write 'foo_type' to
1262
// reference the type of a parameter named 'foo'. For example, in the
1263
// body of MATCHER_P(HasAbsoluteValue, value) above, you can write
1264
// 'value_type' to refer to the type of 'value'.
1266
// We also provide MATCHER_P2, MATCHER_P3, ..., up to MATCHER_P10 to
1267
// support multi-parameter matchers.
1269
// Describing Parameterized Matchers
1270
// =================================
1272
// The last argument to MATCHER*() is a string-typed expression. The
1273
// expression can reference all of the matcher's parameters and a
1274
// special bool-typed variable named 'negation'. When 'negation' is
1275
// false, the expression should evaluate to the matcher's description;
1276
// otherwise it should evaluate to the description of the negation of
1277
// the matcher. For example,
1279
// using testing::PrintToString;
1281
// MATCHER_P2(InClosedRange, low, hi,
1282
// string(negation ? "is not" : "is") + " in range [" +
1283
// PrintToString(low) + ", " + PrintToString(hi) + "]") {
1284
// return low <= arg && arg <= hi;
1287
// EXPECT_THAT(3, InClosedRange(4, 6));
1288
// EXPECT_THAT(3, Not(InClosedRange(2, 4)));
1290
// would generate two failures that contain the text:
1292
// Expected: is in range [4, 6]
1294
// Expected: is not in range [2, 4]
1296
// If you specify "" as the description, the failure message will
1297
// contain the sequence of words in the matcher name followed by the
1298
// parameter values printed as a tuple. For example,
1300
// MATCHER_P2(InClosedRange, low, hi, "") { ... }
1302
// EXPECT_THAT(3, InClosedRange(4, 6));
1303
// EXPECT_THAT(3, Not(InClosedRange(2, 4)));
1305
// would generate two failures that contain the text:
1307
// Expected: in closed range (4, 6)
1309
// Expected: not (in closed range (2, 4))
1311
// Types of Matcher Parameters
1312
// ===========================
1314
// For the purpose of typing, you can view
1316
// MATCHER_Pk(Foo, p1, ..., pk, description_string) { ... }
1320
// template <typename p1_type, ..., typename pk_type>
1321
// FooMatcherPk<p1_type, ..., pk_type>
1322
// Foo(p1_type p1, ..., pk_type pk) { ... }
1324
// When you write Foo(v1, ..., vk), the compiler infers the types of
1325
// the parameters v1, ..., and vk for you. If you are not happy with
1326
// the result of the type inference, you can specify the types by
1327
// explicitly instantiating the template, as in Foo<long, bool>(5,
1328
// false). As said earlier, you don't get to (or need to) specify
1329
// 'arg_type' as that's determined by the context in which the matcher
1330
// is used. You can assign the result of expression Foo(p1, ..., pk)
1331
// to a variable of type FooMatcherPk<p1_type, ..., pk_type>. This
1332
// can be useful when composing matchers.
1334
// While you can instantiate a matcher template with reference types,
1335
// passing the parameters by pointer usually makes your code more
1336
// readable. If, however, you still want to pass a parameter by
1337
// reference, be aware that in the failure message generated by the
1338
// matcher you will see the value of the referenced object but not its
1341
// Explaining Match Results
1342
// ========================
1344
// Sometimes the matcher description alone isn't enough to explain why
1345
// the match has failed or succeeded. For example, when expecting a
1346
// long string, it can be very helpful to also print the diff between
1347
// the expected string and the actual one. To achieve that, you can
1348
// optionally stream additional information to a special variable
1349
// named result_listener, whose type is a pointer to class
1350
// MatchResultListener:
1352
// MATCHER_P(EqualsLongString, str, "") {
1353
// if (arg == str) return true;
1355
// *result_listener << "the difference: "
1356
/// << DiffStrings(str, arg);
1360
// Overloading Matchers
1361
// ====================
1363
// You can overload matchers with different numbers of parameters:
1365
// MATCHER_P(Blah, a, description_string1) { ... }
1366
// MATCHER_P2(Blah, a, b, description_string2) { ... }
1371
// When defining a new matcher, you should also consider implementing
1372
// MatcherInterface or using MakePolymorphicMatcher(). These
1373
// approaches require more work than the MATCHER* macros, but also
1374
// give you more control on the types of the value being matched and
1375
// the matcher parameters, which may leads to better compiler error
1376
// messages when the matcher is used wrong. They also allow
1377
// overloading matchers based on parameter types (as opposed to just
1378
// based on the number of parameters).
1380
// MATCHER*() can only be used in a namespace scope. The reason is
1381
// that C++ doesn't yet allow function-local types to be used to
1382
// instantiate templates. The up-coming C++0x standard will fix this.
1383
// Once that's done, we'll consider supporting using MATCHER*() inside
1389
// To learn more about using these macros, please search for 'MATCHER'
1390
// on http://code.google.com/p/googlemock/wiki/CookBook.
1392
#define MATCHER(name, description)\
1393
class name##Matcher {\
1395
template <typename arg_type>\
1396
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1400
virtual bool MatchAndExplain(\
1401
arg_type arg, ::testing::MatchResultListener* result_listener) const;\
1402
virtual void DescribeTo(::std::ostream* gmock_os) const {\
1403
*gmock_os << FormatDescription(false);\
1405
virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1406
*gmock_os << FormatDescription(true);\
1409
::testing::internal::string FormatDescription(bool negation) const {\
1410
const ::testing::internal::string gmock_description = (description);\
1411
if (!gmock_description.empty())\
1412
return gmock_description;\
1413
return ::testing::internal::FormatMatcherDescription(\
1415
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1416
::std::tr1::tuple<>()));\
1418
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1420
template <typename arg_type>\
1421
operator ::testing::Matcher<arg_type>() const {\
1422
return ::testing::Matcher<arg_type>(\
1423
new gmock_Impl<arg_type>());\
1428
GTEST_DISALLOW_ASSIGN_(name##Matcher);\
1430
inline name##Matcher name() {\
1431
return name##Matcher();\
1433
template <typename arg_type>\
1434
bool name##Matcher::gmock_Impl<arg_type>::MatchAndExplain(\
1436
::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1439
#define MATCHER_P(name, p0, description)\
1440
template <typename p0##_type>\
1441
class name##MatcherP {\
1443
template <typename arg_type>\
1444
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1446
explicit gmock_Impl(p0##_type gmock_p0)\
1448
virtual bool MatchAndExplain(\
1449
arg_type arg, ::testing::MatchResultListener* result_listener) const;\
1450
virtual void DescribeTo(::std::ostream* gmock_os) const {\
1451
*gmock_os << FormatDescription(false);\
1453
virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1454
*gmock_os << FormatDescription(true);\
1458
::testing::internal::string FormatDescription(bool negation) const {\
1459
const ::testing::internal::string gmock_description = (description);\
1460
if (!gmock_description.empty())\
1461
return gmock_description;\
1462
return ::testing::internal::FormatMatcherDescription(\
1464
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1465
::std::tr1::tuple<p0##_type>(p0)));\
1467
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1469
template <typename arg_type>\
1470
operator ::testing::Matcher<arg_type>() const {\
1471
return ::testing::Matcher<arg_type>(\
1472
new gmock_Impl<arg_type>(p0));\
1474
name##MatcherP(p0##_type gmock_p0) : p0(gmock_p0) {\
1478
GTEST_DISALLOW_ASSIGN_(name##MatcherP);\
1480
template <typename p0##_type>\
1481
inline name##MatcherP<p0##_type> name(p0##_type p0) {\
1482
return name##MatcherP<p0##_type>(p0);\
1484
template <typename p0##_type>\
1485
template <typename arg_type>\
1486
bool name##MatcherP<p0##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1488
::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1491
#define MATCHER_P2(name, p0, p1, description)\
1492
template <typename p0##_type, typename p1##_type>\
1493
class name##MatcherP2 {\
1495
template <typename arg_type>\
1496
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1498
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1)\
1499
: p0(gmock_p0), p1(gmock_p1) {}\
1500
virtual bool MatchAndExplain(\
1501
arg_type arg, ::testing::MatchResultListener* result_listener) const;\
1502
virtual void DescribeTo(::std::ostream* gmock_os) const {\
1503
*gmock_os << FormatDescription(false);\
1505
virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1506
*gmock_os << FormatDescription(true);\
1511
::testing::internal::string FormatDescription(bool negation) const {\
1512
const ::testing::internal::string gmock_description = (description);\
1513
if (!gmock_description.empty())\
1514
return gmock_description;\
1515
return ::testing::internal::FormatMatcherDescription(\
1517
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1518
::std::tr1::tuple<p0##_type, p1##_type>(p0, p1)));\
1520
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1522
template <typename arg_type>\
1523
operator ::testing::Matcher<arg_type>() const {\
1524
return ::testing::Matcher<arg_type>(\
1525
new gmock_Impl<arg_type>(p0, p1));\
1527
name##MatcherP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
1533
GTEST_DISALLOW_ASSIGN_(name##MatcherP2);\
1535
template <typename p0##_type, typename p1##_type>\
1536
inline name##MatcherP2<p0##_type, p1##_type> name(p0##_type p0, \
1538
return name##MatcherP2<p0##_type, p1##_type>(p0, p1);\
1540
template <typename p0##_type, typename p1##_type>\
1541
template <typename arg_type>\
1542
bool name##MatcherP2<p0##_type, \
1543
p1##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1545
::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1548
#define MATCHER_P3(name, p0, p1, p2, description)\
1549
template <typename p0##_type, typename p1##_type, typename p2##_type>\
1550
class name##MatcherP3 {\
1552
template <typename arg_type>\
1553
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1555
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2)\
1556
: p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\
1557
virtual bool MatchAndExplain(\
1558
arg_type arg, ::testing::MatchResultListener* result_listener) const;\
1559
virtual void DescribeTo(::std::ostream* gmock_os) const {\
1560
*gmock_os << FormatDescription(false);\
1562
virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1563
*gmock_os << FormatDescription(true);\
1569
::testing::internal::string FormatDescription(bool negation) const {\
1570
const ::testing::internal::string gmock_description = (description);\
1571
if (!gmock_description.empty())\
1572
return gmock_description;\
1573
return ::testing::internal::FormatMatcherDescription(\
1575
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1576
::std::tr1::tuple<p0##_type, p1##_type, p2##_type>(p0, p1, \
1579
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1581
template <typename arg_type>\
1582
operator ::testing::Matcher<arg_type>() const {\
1583
return ::testing::Matcher<arg_type>(\
1584
new gmock_Impl<arg_type>(p0, p1, p2));\
1586
name##MatcherP3(p0##_type gmock_p0, p1##_type gmock_p1, \
1587
p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {\
1593
GTEST_DISALLOW_ASSIGN_(name##MatcherP3);\
1595
template <typename p0##_type, typename p1##_type, typename p2##_type>\
1596
inline name##MatcherP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0, \
1597
p1##_type p1, p2##_type p2) {\
1598
return name##MatcherP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\
1600
template <typename p0##_type, typename p1##_type, typename p2##_type>\
1601
template <typename arg_type>\
1602
bool name##MatcherP3<p0##_type, p1##_type, \
1603
p2##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1605
::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1608
#define MATCHER_P4(name, p0, p1, p2, p3, description)\
1609
template <typename p0##_type, typename p1##_type, typename p2##_type, \
1610
typename p3##_type>\
1611
class name##MatcherP4 {\
1613
template <typename arg_type>\
1614
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1616
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1617
p3##_type gmock_p3)\
1618
: p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3) {}\
1619
virtual bool MatchAndExplain(\
1620
arg_type arg, ::testing::MatchResultListener* result_listener) const;\
1621
virtual void DescribeTo(::std::ostream* gmock_os) const {\
1622
*gmock_os << FormatDescription(false);\
1624
virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1625
*gmock_os << FormatDescription(true);\
1632
::testing::internal::string FormatDescription(bool negation) const {\
1633
const ::testing::internal::string gmock_description = (description);\
1634
if (!gmock_description.empty())\
1635
return gmock_description;\
1636
return ::testing::internal::FormatMatcherDescription(\
1638
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1639
::std::tr1::tuple<p0##_type, p1##_type, p2##_type, \
1640
p3##_type>(p0, p1, p2, p3)));\
1642
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1644
template <typename arg_type>\
1645
operator ::testing::Matcher<arg_type>() const {\
1646
return ::testing::Matcher<arg_type>(\
1647
new gmock_Impl<arg_type>(p0, p1, p2, p3));\
1649
name##MatcherP4(p0##_type gmock_p0, p1##_type gmock_p1, \
1650
p2##_type gmock_p2, p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), \
1651
p2(gmock_p2), p3(gmock_p3) {\
1658
GTEST_DISALLOW_ASSIGN_(name##MatcherP4);\
1660
template <typename p0##_type, typename p1##_type, typename p2##_type, \
1661
typename p3##_type>\
1662
inline name##MatcherP4<p0##_type, p1##_type, p2##_type, \
1663
p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
1665
return name##MatcherP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, \
1668
template <typename p0##_type, typename p1##_type, typename p2##_type, \
1669
typename p3##_type>\
1670
template <typename arg_type>\
1671
bool name##MatcherP4<p0##_type, p1##_type, p2##_type, \
1672
p3##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1674
::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1677
#define MATCHER_P5(name, p0, p1, p2, p3, p4, description)\
1678
template <typename p0##_type, typename p1##_type, typename p2##_type, \
1679
typename p3##_type, typename p4##_type>\
1680
class name##MatcherP5 {\
1682
template <typename arg_type>\
1683
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1685
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1686
p3##_type gmock_p3, p4##_type gmock_p4)\
1687
: p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1689
virtual bool MatchAndExplain(\
1690
arg_type arg, ::testing::MatchResultListener* result_listener) const;\
1691
virtual void DescribeTo(::std::ostream* gmock_os) const {\
1692
*gmock_os << FormatDescription(false);\
1694
virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1695
*gmock_os << FormatDescription(true);\
1703
::testing::internal::string FormatDescription(bool negation) const {\
1704
const ::testing::internal::string gmock_description = (description);\
1705
if (!gmock_description.empty())\
1706
return gmock_description;\
1707
return ::testing::internal::FormatMatcherDescription(\
1709
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1710
::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1711
p4##_type>(p0, p1, p2, p3, p4)));\
1713
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1715
template <typename arg_type>\
1716
operator ::testing::Matcher<arg_type>() const {\
1717
return ::testing::Matcher<arg_type>(\
1718
new gmock_Impl<arg_type>(p0, p1, p2, p3, p4));\
1720
name##MatcherP5(p0##_type gmock_p0, p1##_type gmock_p1, \
1721
p2##_type gmock_p2, p3##_type gmock_p3, \
1722
p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1723
p3(gmock_p3), p4(gmock_p4) {\
1731
GTEST_DISALLOW_ASSIGN_(name##MatcherP5);\
1733
template <typename p0##_type, typename p1##_type, typename p2##_type, \
1734
typename p3##_type, typename p4##_type>\
1735
inline name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1736
p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
1738
return name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1739
p4##_type>(p0, p1, p2, p3, p4);\
1741
template <typename p0##_type, typename p1##_type, typename p2##_type, \
1742
typename p3##_type, typename p4##_type>\
1743
template <typename arg_type>\
1744
bool name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1745
p4##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1747
::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1750
#define MATCHER_P6(name, p0, p1, p2, p3, p4, p5, description)\
1751
template <typename p0##_type, typename p1##_type, typename p2##_type, \
1752
typename p3##_type, typename p4##_type, typename p5##_type>\
1753
class name##MatcherP6 {\
1755
template <typename arg_type>\
1756
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1758
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1759
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5)\
1760
: p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1761
p4(gmock_p4), p5(gmock_p5) {}\
1762
virtual bool MatchAndExplain(\
1763
arg_type arg, ::testing::MatchResultListener* result_listener) const;\
1764
virtual void DescribeTo(::std::ostream* gmock_os) const {\
1765
*gmock_os << FormatDescription(false);\
1767
virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1768
*gmock_os << FormatDescription(true);\
1777
::testing::internal::string FormatDescription(bool negation) const {\
1778
const ::testing::internal::string gmock_description = (description);\
1779
if (!gmock_description.empty())\
1780
return gmock_description;\
1781
return ::testing::internal::FormatMatcherDescription(\
1783
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1784
::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1785
p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5)));\
1787
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1789
template <typename arg_type>\
1790
operator ::testing::Matcher<arg_type>() const {\
1791
return ::testing::Matcher<arg_type>(\
1792
new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5));\
1794
name##MatcherP6(p0##_type gmock_p0, p1##_type gmock_p1, \
1795
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1796
p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1797
p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {\
1806
GTEST_DISALLOW_ASSIGN_(name##MatcherP6);\
1808
template <typename p0##_type, typename p1##_type, typename p2##_type, \
1809
typename p3##_type, typename p4##_type, typename p5##_type>\
1810
inline name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
1811
p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
1812
p3##_type p3, p4##_type p4, p5##_type p5) {\
1813
return name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
1814
p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\
1816
template <typename p0##_type, typename p1##_type, typename p2##_type, \
1817
typename p3##_type, typename p4##_type, typename p5##_type>\
1818
template <typename arg_type>\
1819
bool name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
1820
p5##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1822
::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1825
#define MATCHER_P7(name, p0, p1, p2, p3, p4, p5, p6, description)\
1826
template <typename p0##_type, typename p1##_type, typename p2##_type, \
1827
typename p3##_type, typename p4##_type, typename p5##_type, \
1828
typename p6##_type>\
1829
class name##MatcherP7 {\
1831
template <typename arg_type>\
1832
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1834
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1835
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
1836
p6##_type gmock_p6)\
1837
: p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1838
p4(gmock_p4), p5(gmock_p5), p6(gmock_p6) {}\
1839
virtual bool MatchAndExplain(\
1840
arg_type arg, ::testing::MatchResultListener* result_listener) const;\
1841
virtual void DescribeTo(::std::ostream* gmock_os) const {\
1842
*gmock_os << FormatDescription(false);\
1844
virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1845
*gmock_os << FormatDescription(true);\
1855
::testing::internal::string FormatDescription(bool negation) const {\
1856
const ::testing::internal::string gmock_description = (description);\
1857
if (!gmock_description.empty())\
1858
return gmock_description;\
1859
return ::testing::internal::FormatMatcherDescription(\
1861
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1862
::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1863
p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, \
1866
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1868
template <typename arg_type>\
1869
operator ::testing::Matcher<arg_type>() const {\
1870
return ::testing::Matcher<arg_type>(\
1871
new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6));\
1873
name##MatcherP7(p0##_type gmock_p0, p1##_type gmock_p1, \
1874
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1875
p5##_type gmock_p5, p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), \
1876
p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), \
1887
GTEST_DISALLOW_ASSIGN_(name##MatcherP7);\
1889
template <typename p0##_type, typename p1##_type, typename p2##_type, \
1890
typename p3##_type, typename p4##_type, typename p5##_type, \
1891
typename p6##_type>\
1892
inline name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
1893
p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \
1894
p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
1896
return name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
1897
p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\
1899
template <typename p0##_type, typename p1##_type, typename p2##_type, \
1900
typename p3##_type, typename p4##_type, typename p5##_type, \
1901
typename p6##_type>\
1902
template <typename arg_type>\
1903
bool name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
1904
p5##_type, p6##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1906
::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1909
#define MATCHER_P8(name, p0, p1, p2, p3, p4, p5, p6, p7, description)\
1910
template <typename p0##_type, typename p1##_type, typename p2##_type, \
1911
typename p3##_type, typename p4##_type, typename p5##_type, \
1912
typename p6##_type, typename p7##_type>\
1913
class name##MatcherP8 {\
1915
template <typename arg_type>\
1916
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1918
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1919
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
1920
p6##_type gmock_p6, p7##_type gmock_p7)\
1921
: p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1922
p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7) {}\
1923
virtual bool MatchAndExplain(\
1924
arg_type arg, ::testing::MatchResultListener* result_listener) const;\
1925
virtual void DescribeTo(::std::ostream* gmock_os) const {\
1926
*gmock_os << FormatDescription(false);\
1928
virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1929
*gmock_os << FormatDescription(true);\
1940
::testing::internal::string FormatDescription(bool negation) const {\
1941
const ::testing::internal::string gmock_description = (description);\
1942
if (!gmock_description.empty())\
1943
return gmock_description;\
1944
return ::testing::internal::FormatMatcherDescription(\
1946
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1947
::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1948
p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, \
1949
p3, p4, p5, p6, p7)));\
1951
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1953
template <typename arg_type>\
1954
operator ::testing::Matcher<arg_type>() const {\
1955
return ::testing::Matcher<arg_type>(\
1956
new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7));\
1958
name##MatcherP8(p0##_type gmock_p0, p1##_type gmock_p1, \
1959
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1960
p5##_type gmock_p5, p6##_type gmock_p6, \
1961
p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1962
p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
1974
GTEST_DISALLOW_ASSIGN_(name##MatcherP8);\
1976
template <typename p0##_type, typename p1##_type, typename p2##_type, \
1977
typename p3##_type, typename p4##_type, typename p5##_type, \
1978
typename p6##_type, typename p7##_type>\
1979
inline name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
1980
p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \
1981
p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
1982
p6##_type p6, p7##_type p7) {\
1983
return name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
1984
p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5, \
1987
template <typename p0##_type, typename p1##_type, typename p2##_type, \
1988
typename p3##_type, typename p4##_type, typename p5##_type, \
1989
typename p6##_type, typename p7##_type>\
1990
template <typename arg_type>\
1991
bool name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
1992
p5##_type, p6##_type, \
1993
p7##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1995
::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1998
#define MATCHER_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, description)\
1999
template <typename p0##_type, typename p1##_type, typename p2##_type, \
2000
typename p3##_type, typename p4##_type, typename p5##_type, \
2001
typename p6##_type, typename p7##_type, typename p8##_type>\
2002
class name##MatcherP9 {\
2004
template <typename arg_type>\
2005
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
2007
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
2008
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
2009
p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8)\
2010
: p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
2011
p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
2013
virtual bool MatchAndExplain(\
2014
arg_type arg, ::testing::MatchResultListener* result_listener) const;\
2015
virtual void DescribeTo(::std::ostream* gmock_os) const {\
2016
*gmock_os << FormatDescription(false);\
2018
virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
2019
*gmock_os << FormatDescription(true);\
2031
::testing::internal::string FormatDescription(bool negation) const {\
2032
const ::testing::internal::string gmock_description = (description);\
2033
if (!gmock_description.empty())\
2034
return gmock_description;\
2035
return ::testing::internal::FormatMatcherDescription(\
2037
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
2038
::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
2039
p4##_type, p5##_type, p6##_type, p7##_type, \
2040
p8##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8)));\
2042
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
2044
template <typename arg_type>\
2045
operator ::testing::Matcher<arg_type>() const {\
2046
return ::testing::Matcher<arg_type>(\
2047
new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8));\
2049
name##MatcherP9(p0##_type gmock_p0, p1##_type gmock_p1, \
2050
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
2051
p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
2052
p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
2053
p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
2066
GTEST_DISALLOW_ASSIGN_(name##MatcherP9);\
2068
template <typename p0##_type, typename p1##_type, typename p2##_type, \
2069
typename p3##_type, typename p4##_type, typename p5##_type, \
2070
typename p6##_type, typename p7##_type, typename p8##_type>\
2071
inline name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \
2072
p4##_type, p5##_type, p6##_type, p7##_type, \
2073
p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
2074
p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \
2076
return name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \
2077
p4##_type, p5##_type, p6##_type, p7##_type, p8##_type>(p0, p1, p2, \
2078
p3, p4, p5, p6, p7, p8);\
2080
template <typename p0##_type, typename p1##_type, typename p2##_type, \
2081
typename p3##_type, typename p4##_type, typename p5##_type, \
2082
typename p6##_type, typename p7##_type, typename p8##_type>\
2083
template <typename arg_type>\
2084
bool name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
2085
p5##_type, p6##_type, p7##_type, \
2086
p8##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
2088
::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
2091
#define MATCHER_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, description)\
2092
template <typename p0##_type, typename p1##_type, typename p2##_type, \
2093
typename p3##_type, typename p4##_type, typename p5##_type, \
2094
typename p6##_type, typename p7##_type, typename p8##_type, \
2095
typename p9##_type>\
2096
class name##MatcherP10 {\
2098
template <typename arg_type>\
2099
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
2101
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
2102
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
2103
p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
2104
p9##_type gmock_p9)\
2105
: p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
2106
p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
2107
p8(gmock_p8), p9(gmock_p9) {}\
2108
virtual bool MatchAndExplain(\
2109
arg_type arg, ::testing::MatchResultListener* result_listener) const;\
2110
virtual void DescribeTo(::std::ostream* gmock_os) const {\
2111
*gmock_os << FormatDescription(false);\
2113
virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
2114
*gmock_os << FormatDescription(true);\
2127
::testing::internal::string FormatDescription(bool negation) const {\
2128
const ::testing::internal::string gmock_description = (description);\
2129
if (!gmock_description.empty())\
2130
return gmock_description;\
2131
return ::testing::internal::FormatMatcherDescription(\
2133
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
2134
::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
2135
p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
2136
p9##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)));\
2138
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
2140
template <typename arg_type>\
2141
operator ::testing::Matcher<arg_type>() const {\
2142
return ::testing::Matcher<arg_type>(\
2143
new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9));\
2145
name##MatcherP10(p0##_type gmock_p0, p1##_type gmock_p1, \
2146
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
2147
p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
2148
p8##_type gmock_p8, p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), \
2149
p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
2150
p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {\
2163
GTEST_DISALLOW_ASSIGN_(name##MatcherP10);\
2165
template <typename p0##_type, typename p1##_type, typename p2##_type, \
2166
typename p3##_type, typename p4##_type, typename p5##_type, \
2167
typename p6##_type, typename p7##_type, typename p8##_type, \
2168
typename p9##_type>\
2169
inline name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
2170
p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
2171
p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
2172
p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
2174
return name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
2175
p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>(p0, \
2176
p1, p2, p3, p4, p5, p6, p7, p8, p9);\
2178
template <typename p0##_type, typename p1##_type, typename p2##_type, \
2179
typename p3##_type, typename p4##_type, typename p5##_type, \
2180
typename p6##_type, typename p7##_type, typename p8##_type, \
2181
typename p9##_type>\
2182
template <typename arg_type>\
2183
bool name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
2184
p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
2185
p9##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
2187
::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
2190
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_