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
// 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*.
313
template <typename T1>
314
class ElementsAreMatcher1 {
316
explicit ElementsAreMatcher1(const T1& e1) : e1_(e1) {}
318
template <typename Container>
319
operator Matcher<Container>() const {
320
typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
321
typedef typename internal::StlContainerView<RawContainer>::type::value_type
324
// 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
330
const Matcher<const Element&> matcher =
331
MatcherCast<const Element&>(e1_);
332
return MakeMatcher(new ElementsAreMatcherImpl<Container>(&matcher,
337
const typename DecayArray<T1>::type e1_;
339
GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher1);
342
template <typename T1, typename T2>
343
class ElementsAreMatcher2 {
345
ElementsAreMatcher2(const T1& e1, const T2& e2) : e1_(e1), e2_(e2) {}
347
template <typename Container>
348
operator Matcher<Container>() const {
349
typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
350
typedef typename internal::StlContainerView<RawContainer>::type::value_type
353
const Matcher<const Element&> matchers[] = {
354
MatcherCast<const Element&>(e1_),
355
MatcherCast<const Element&>(e2_),
358
return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers,
363
const typename DecayArray<T1>::type e1_;
364
const typename DecayArray<T2>::type e2_;
366
GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher2);
369
template <typename T1, typename T2, typename T3>
370
class ElementsAreMatcher3 {
372
ElementsAreMatcher3(const T1& e1, const T2& e2, const T3& e3) : e1_(e1),
375
template <typename Container>
376
operator Matcher<Container>() const {
377
typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
378
typedef typename internal::StlContainerView<RawContainer>::type::value_type
381
const Matcher<const Element&> matchers[] = {
382
MatcherCast<const Element&>(e1_),
383
MatcherCast<const Element&>(e2_),
384
MatcherCast<const Element&>(e3_),
387
return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers,
392
const typename DecayArray<T1>::type e1_;
393
const typename DecayArray<T2>::type e2_;
394
const typename DecayArray<T3>::type e3_;
396
GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher3);
399
template <typename T1, typename T2, typename T3, typename T4>
400
class ElementsAreMatcher4 {
402
ElementsAreMatcher4(const T1& e1, const T2& e2, const T3& e3,
403
const T4& e4) : e1_(e1), e2_(e2), e3_(e3), e4_(e4) {}
405
template <typename Container>
406
operator Matcher<Container>() const {
407
typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
408
typedef typename internal::StlContainerView<RawContainer>::type::value_type
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_),
418
return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers,
423
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_;
428
GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher4);
431
template <typename T1, typename T2, typename T3, typename T4, typename T5>
432
class ElementsAreMatcher5 {
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) {}
437
template <typename Container>
438
operator Matcher<Container>() const {
439
typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
440
typedef typename internal::StlContainerView<RawContainer>::type::value_type
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_),
451
return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers,
456
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_;
462
GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher5);
465
template <typename T1, typename T2, typename T3, typename T4, typename T5,
467
class ElementsAreMatcher6 {
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),
473
template <typename Container>
474
operator Matcher<Container>() const {
475
typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
476
typedef typename internal::StlContainerView<RawContainer>::type::value_type
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_),
488
return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers,
493
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_;
500
GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher6);
503
template <typename T1, typename T2, typename T3, typename T4, typename T5,
504
typename T6, typename T7>
505
class ElementsAreMatcher7 {
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) {}
511
template <typename Container>
512
operator Matcher<Container>() const {
513
typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
514
typedef typename internal::StlContainerView<RawContainer>::type::value_type
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_),
527
return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers,
532
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_;
540
GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher7);
543
template <typename T1, typename T2, typename T3, typename T4, typename T5,
544
typename T6, typename T7, typename T8>
545
class ElementsAreMatcher8 {
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) {}
551
template <typename Container>
552
operator Matcher<Container>() const {
553
typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
554
typedef typename internal::StlContainerView<RawContainer>::type::value_type
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_),
568
return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers,
573
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_;
582
GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher8);
585
template <typename T1, typename T2, typename T3, typename T4, typename T5,
586
typename T6, typename T7, typename T8, typename T9>
587
class ElementsAreMatcher9 {
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) {}
594
template <typename Container>
595
operator Matcher<Container>() const {
596
typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
597
typedef typename internal::StlContainerView<RawContainer>::type::value_type
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_),
612
return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers,
617
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_;
627
GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher9);
630
template <typename T1, typename T2, typename T3, typename T4, typename T5,
631
typename T6, typename T7, typename T8, typename T9, typename T10>
632
class ElementsAreMatcher10 {
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) {}
639
template <typename Container>
640
operator Matcher<Container>() const {
641
typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
642
typedef typename internal::StlContainerView<RawContainer>::type::value_type
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_),
658
return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers,
663
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_;
674
GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher10);
677
// A set of metafunctions for computing the result type of AllOf.
678
// AllOf(m1, ..., mN) returns
679
// AllOfResultN<decltype(m1), ..., decltype(mN)>::type.
681
// Although AllOf isn't defined for one argument, AllOfResult1 is defined
682
// to simplify the implementation.
683
template <typename M1>
684
struct AllOfResult1 {
688
template <typename M1, typename M2>
689
struct AllOfResult2 {
690
typedef BothOfMatcher<
691
typename AllOfResult1<M1>::type,
692
typename AllOfResult1<M2>::type
696
template <typename M1, typename M2, typename M3>
697
struct AllOfResult3 {
698
typedef BothOfMatcher<
699
typename AllOfResult1<M1>::type,
700
typename AllOfResult2<M2, M3>::type
704
template <typename M1, typename M2, typename M3, typename M4>
705
struct AllOfResult4 {
706
typedef BothOfMatcher<
707
typename AllOfResult2<M1, M2>::type,
708
typename AllOfResult2<M3, M4>::type
712
template <typename M1, typename M2, typename M3, typename M4, typename M5>
713
struct AllOfResult5 {
714
typedef BothOfMatcher<
715
typename AllOfResult2<M1, M2>::type,
716
typename AllOfResult3<M3, M4, M5>::type
720
template <typename M1, typename M2, typename M3, typename M4, typename M5,
722
struct AllOfResult6 {
723
typedef BothOfMatcher<
724
typename AllOfResult3<M1, M2, M3>::type,
725
typename AllOfResult3<M4, M5, M6>::type
729
template <typename M1, typename M2, typename M3, typename M4, typename M5,
730
typename M6, typename M7>
731
struct AllOfResult7 {
732
typedef BothOfMatcher<
733
typename AllOfResult3<M1, M2, M3>::type,
734
typename AllOfResult4<M4, M5, M6, M7>::type
738
template <typename M1, typename M2, typename M3, typename M4, typename M5,
739
typename M6, typename M7, typename M8>
740
struct AllOfResult8 {
741
typedef BothOfMatcher<
742
typename AllOfResult4<M1, M2, M3, M4>::type,
743
typename AllOfResult4<M5, M6, M7, M8>::type
747
template <typename M1, typename M2, typename M3, typename M4, typename M5,
748
typename M6, typename M7, typename M8, typename M9>
749
struct AllOfResult9 {
750
typedef BothOfMatcher<
751
typename AllOfResult4<M1, M2, M3, M4>::type,
752
typename AllOfResult5<M5, M6, M7, M8, M9>::type
756
template <typename M1, typename M2, typename M3, typename M4, typename M5,
757
typename M6, typename M7, typename M8, typename M9, typename M10>
758
struct AllOfResult10 {
759
typedef BothOfMatcher<
760
typename AllOfResult5<M1, M2, M3, M4, M5>::type,
761
typename AllOfResult5<M6, M7, M8, M9, M10>::type
765
// A set of metafunctions for computing the result type of AnyOf.
766
// AnyOf(m1, ..., mN) returns
767
// AnyOfResultN<decltype(m1), ..., decltype(mN)>::type.
769
// Although AnyOf isn't defined for one argument, AnyOfResult1 is defined
770
// to simplify the implementation.
771
template <typename M1>
772
struct AnyOfResult1 {
776
template <typename M1, typename M2>
777
struct AnyOfResult2 {
778
typedef EitherOfMatcher<
779
typename AnyOfResult1<M1>::type,
780
typename AnyOfResult1<M2>::type
784
template <typename M1, typename M2, typename M3>
785
struct AnyOfResult3 {
786
typedef EitherOfMatcher<
787
typename AnyOfResult1<M1>::type,
788
typename AnyOfResult2<M2, M3>::type
792
template <typename M1, typename M2, typename M3, typename M4>
793
struct AnyOfResult4 {
794
typedef EitherOfMatcher<
795
typename AnyOfResult2<M1, M2>::type,
796
typename AnyOfResult2<M3, M4>::type
800
template <typename M1, typename M2, typename M3, typename M4, typename M5>
801
struct AnyOfResult5 {
802
typedef EitherOfMatcher<
803
typename AnyOfResult2<M1, M2>::type,
804
typename AnyOfResult3<M3, M4, M5>::type
808
template <typename M1, typename M2, typename M3, typename M4, typename M5,
810
struct AnyOfResult6 {
811
typedef EitherOfMatcher<
812
typename AnyOfResult3<M1, M2, M3>::type,
813
typename AnyOfResult3<M4, M5, M6>::type
817
template <typename M1, typename M2, typename M3, typename M4, typename M5,
818
typename M6, typename M7>
819
struct AnyOfResult7 {
820
typedef EitherOfMatcher<
821
typename AnyOfResult3<M1, M2, M3>::type,
822
typename AnyOfResult4<M4, M5, M6, M7>::type
826
template <typename M1, typename M2, typename M3, typename M4, typename M5,
827
typename M6, typename M7, typename M8>
828
struct AnyOfResult8 {
829
typedef EitherOfMatcher<
830
typename AnyOfResult4<M1, M2, M3, M4>::type,
831
typename AnyOfResult4<M5, M6, M7, M8>::type
835
template <typename M1, typename M2, typename M3, typename M4, typename M5,
836
typename M6, typename M7, typename M8, typename M9>
837
struct AnyOfResult9 {
838
typedef EitherOfMatcher<
839
typename AnyOfResult4<M1, M2, M3, M4>::type,
840
typename AnyOfResult5<M5, M6, M7, M8, M9>::type
844
template <typename M1, typename M2, typename M3, typename M4, typename M5,
845
typename M6, typename M7, typename M8, typename M9, typename M10>
846
struct AnyOfResult10 {
847
typedef EitherOfMatcher<
848
typename AnyOfResult5<M1, M2, M3, M4, M5>::type,
849
typename AnyOfResult5<M6, M7, M8, M9, M10>::type
853
} // namespace internal
855
// 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.
858
template <typename InnerMatcher>
859
inline internal::ArgsMatcher<InnerMatcher>
860
Args(const InnerMatcher& matcher) {
861
return internal::ArgsMatcher<InnerMatcher>(matcher);
864
template <int k1, typename InnerMatcher>
865
inline internal::ArgsMatcher<InnerMatcher, k1>
866
Args(const InnerMatcher& matcher) {
867
return internal::ArgsMatcher<InnerMatcher, k1>(matcher);
870
template <int k1, int k2, typename InnerMatcher>
871
inline internal::ArgsMatcher<InnerMatcher, k1, k2>
872
Args(const InnerMatcher& matcher) {
873
return internal::ArgsMatcher<InnerMatcher, k1, k2>(matcher);
876
template <int k1, int k2, int k3, typename InnerMatcher>
877
inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3>
878
Args(const InnerMatcher& matcher) {
879
return internal::ArgsMatcher<InnerMatcher, k1, k2, k3>(matcher);
882
template <int k1, int k2, int k3, int k4, typename InnerMatcher>
883
inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>
884
Args(const InnerMatcher& matcher) {
885
return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>(matcher);
888
template <int k1, int k2, int k3, int k4, int k5, typename InnerMatcher>
889
inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>
890
Args(const InnerMatcher& matcher) {
891
return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>(matcher);
894
template <int k1, int k2, int k3, int k4, int k5, int k6, typename InnerMatcher>
895
inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>
896
Args(const InnerMatcher& matcher) {
897
return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>(matcher);
900
template <int k1, int k2, int k3, int k4, int k5, int k6, int k7,
901
typename InnerMatcher>
902
inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7>
903
Args(const InnerMatcher& matcher) {
904
return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6,
908
template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
909
typename InnerMatcher>
910
inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8>
911
Args(const InnerMatcher& matcher) {
912
return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7,
916
template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
917
int k9, typename InnerMatcher>
918
inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9>
919
Args(const InnerMatcher& matcher) {
920
return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
924
template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
925
int k9, int k10, typename InnerMatcher>
926
inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9,
928
Args(const InnerMatcher& matcher) {
929
return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
933
// 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
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).
943
inline internal::ElementsAreMatcher0 ElementsAre() {
944
return internal::ElementsAreMatcher0();
947
template <typename T1>
948
inline internal::ElementsAreMatcher1<T1> ElementsAre(const T1& e1) {
949
return internal::ElementsAreMatcher1<T1>(e1);
952
template <typename T1, typename T2>
953
inline internal::ElementsAreMatcher2<T1, T2> ElementsAre(const T1& e1,
955
return internal::ElementsAreMatcher2<T1, T2>(e1, e2);
958
template <typename T1, typename T2, typename T3>
959
inline 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);
964
template <typename T1, typename T2, typename T3, typename T4>
965
inline 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);
970
template <typename T1, typename T2, typename T3, typename T4, typename T5>
971
inline internal::ElementsAreMatcher5<T1, T2, T3, T4,
972
T5> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
974
return internal::ElementsAreMatcher5<T1, T2, T3, T4, T5>(e1, e2, e3, e4, e5);
977
template <typename T1, typename T2, typename T3, typename T4, typename T5,
979
inline 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,
986
template <typename T1, typename T2, typename T3, typename T4, typename T5,
987
typename T6, typename T7>
988
inline 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,
995
template <typename T1, typename T2, typename T3, typename T4, typename T5,
996
typename T6, typename T7, typename T8>
997
inline 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);
1004
template <typename T1, typename T2, typename T3, typename T4, typename T5,
1005
typename T6, typename T7, typename T8, typename T9>
1006
inline 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);
1013
template <typename T1, typename T2, typename T3, typename T4, typename T5,
1014
typename T6, typename T7, typename T8, typename T9, typename T10>
1015
inline 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,
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);
1023
// ElementsAreArray(array)
1024
// ElementsAreArray(pointer, count)
1025
// ElementsAreArray(vector)
1026
// ElementsAreArray(first, last)
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.
1033
// * The array form infers the size of 'array', which must be of a
1034
// statically-sized C-style array type.
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.
1040
// * The vector form can take a std::vector either of values or of matchers.
1042
// * The (first, last) form can take any STL iterator range.
1044
// All forms of ElementsAreArray() make a copy of the input sequence.
1045
template <typename T>
1046
inline internal::ElementsAreArrayMatcher<T> ElementsAreArray(
1047
const T* first, size_t count) {
1048
return internal::ElementsAreArrayMatcher<T>(first, first + count);
1051
template <typename T, size_t N>
1052
inline internal::ElementsAreArrayMatcher<T> ElementsAreArray(
1053
const T (&array)[N]) {
1054
return internal::ElementsAreArrayMatcher<T>(array, array + N);
1057
template <typename T, typename A>
1058
inline internal::ElementsAreArrayMatcher<T> ElementsAreArray(
1059
const std::vector<T, A>& vec) {
1060
return internal::ElementsAreArrayMatcher<T>(vec.begin(), vec.end());
1063
template <typename Iter>
1064
inline internal::ElementsAreArrayMatcher<
1065
typename std::iterator_traits<Iter>::value_type>
1066
ElementsAreArray(Iter first, Iter last) {
1067
typedef typename std::iterator_traits<Iter>::value_type T;
1068
return internal::ElementsAreArrayMatcher<T>(first, last);
1072
// AllOf(m1, m2, ..., mk) matches any value that matches all of the given
1073
// sub-matchers. AllOf is called fully qualified to prevent ADL from firing.
1075
template <typename M1, typename M2>
1076
inline typename internal::AllOfResult2<M1, M2>::type
1077
AllOf(M1 m1, M2 m2) {
1078
return typename internal::AllOfResult2<M1, M2>::type(
1083
template <typename M1, typename M2, typename M3>
1084
inline typename internal::AllOfResult3<M1, M2, M3>::type
1085
AllOf(M1 m1, M2 m2, M3 m3) {
1086
return typename internal::AllOfResult3<M1, M2, M3>::type(
1088
::testing::AllOf(m2, m3));
1091
template <typename M1, typename M2, typename M3, typename M4>
1092
inline typename internal::AllOfResult4<M1, M2, M3, M4>::type
1093
AllOf(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));
1099
template <typename M1, typename M2, typename M3, typename M4, typename M5>
1100
inline typename internal::AllOfResult5<M1, M2, M3, M4, M5>::type
1101
AllOf(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));
1107
template <typename M1, typename M2, typename M3, typename M4, typename M5,
1109
inline typename internal::AllOfResult6<M1, M2, M3, M4, M5, M6>::type
1110
AllOf(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));
1116
template <typename M1, typename M2, typename M3, typename M4, typename M5,
1117
typename M6, typename M7>
1118
inline typename internal::AllOfResult7<M1, M2, M3, M4, M5, M6, M7>::type
1119
AllOf(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));
1125
template <typename M1, typename M2, typename M3, typename M4, typename M5,
1126
typename M6, typename M7, typename M8>
1127
inline typename internal::AllOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type
1128
AllOf(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));
1134
template <typename M1, typename M2, typename M3, typename M4, typename M5,
1135
typename M6, typename M7, typename M8, typename M9>
1136
inline typename internal::AllOfResult9<M1, M2, M3, M4, M5, M6, M7, M8, M9>::type
1137
AllOf(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,
1140
::testing::AllOf(m1, m2, m3, m4),
1141
::testing::AllOf(m5, m6, m7, m8, m9));
1144
template <typename M1, typename M2, typename M3, typename M4, typename M5,
1145
typename M6, typename M7, typename M8, typename M9, typename M10>
1146
inline typename internal::AllOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
1148
AllOf(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,
1151
::testing::AllOf(m1, m2, m3, m4, m5),
1152
::testing::AllOf(m6, m7, m8, m9, m10));
1155
// AnyOf(m1, m2, ..., mk) matches any value that matches any of the given
1156
// sub-matchers. AnyOf is called fully qualified to prevent ADL from firing.
1158
template <typename M1, typename M2>
1159
inline typename internal::AnyOfResult2<M1, M2>::type
1160
AnyOf(M1 m1, M2 m2) {
1161
return typename internal::AnyOfResult2<M1, M2>::type(
1166
template <typename M1, typename M2, typename M3>
1167
inline typename internal::AnyOfResult3<M1, M2, M3>::type
1168
AnyOf(M1 m1, M2 m2, M3 m3) {
1169
return typename internal::AnyOfResult3<M1, M2, M3>::type(
1171
::testing::AnyOf(m2, m3));
1174
template <typename M1, typename M2, typename M3, typename M4>
1175
inline typename internal::AnyOfResult4<M1, M2, M3, M4>::type
1176
AnyOf(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));
1182
template <typename M1, typename M2, typename M3, typename M4, typename M5>
1183
inline typename internal::AnyOfResult5<M1, M2, M3, M4, M5>::type
1184
AnyOf(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));
1190
template <typename M1, typename M2, typename M3, typename M4, typename M5,
1192
inline typename internal::AnyOfResult6<M1, M2, M3, M4, M5, M6>::type
1193
AnyOf(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));
1199
template <typename M1, typename M2, typename M3, typename M4, typename M5,
1200
typename M6, typename M7>
1201
inline typename internal::AnyOfResult7<M1, M2, M3, M4, M5, M6, M7>::type
1202
AnyOf(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));
1208
template <typename M1, typename M2, typename M3, typename M4, typename M5,
1209
typename M6, typename M7, typename M8>
1210
inline typename internal::AnyOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type
1211
AnyOf(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));
1217
template <typename M1, typename M2, typename M3, typename M4, typename M5,
1218
typename M6, typename M7, typename M8, typename M9>
1219
inline typename internal::AnyOfResult9<M1, M2, M3, M4, M5, M6, M7, M8, M9>::type
1220
AnyOf(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,
1223
::testing::AnyOf(m1, m2, m3, m4),
1224
::testing::AnyOf(m5, m6, m7, m8, m9));
1227
template <typename M1, typename M2, typename M3, typename M4, typename M5,
1228
typename M6, typename M7, typename M8, typename M9, typename M10>
1229
inline typename internal::AnyOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
1231
AnyOf(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,
1234
::testing::AnyOf(m1, m2, m3, m4, m5),
1235
::testing::AnyOf(m6, m7, m8, m9, m10));
1238
} // namespace testing
1241
// The MATCHER* family of macros can be used in a namespace scope to
1242
// define custom matchers easily.
1249
// MATCHER(name, description_string) { statements; }
1251
// 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'.
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
1266
// MATCHER(IsEven, "") { return (arg % 2) == 0; }
1268
// allows you to write
1270
// // Expects mock_foo.Bar(n) to be called where n is even.
1271
// EXPECT_CALL(mock_foo, Bar(IsEven()));
1275
// // Verifies that the value of some_expression is even.
1276
// EXPECT_THAT(some_expression, IsEven());
1278
// If the above assertion fails, it will print something like:
1280
// Value of: some_expression
1281
// Expected: is even
1284
// where the description "is even" is automatically calculated from the
1285
// matcher name IsEven.
1290
// 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.
1300
// Parameterizing Matchers
1301
// =======================
1303
// Sometimes you'll want to parameterize the matcher. For that you
1304
// can use another macro:
1306
// MATCHER_P(name, param_name, description_string) { statements; }
1310
// MATCHER_P(HasAbsoluteValue, value, "") { return abs(arg) == value; }
1312
// will allow you to write:
1314
// EXPECT_THAT(Blah("a"), HasAbsoluteValue(n));
1316
// which may lead to this message (assuming n is 10):
1318
// Value of: Blah("a")
1319
// Expected: has absolute value 10
1322
// Note that both the matcher description and its parameter are
1323
// printed, making the message human-friendly.
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'.
1330
// We also provide MATCHER_P2, MATCHER_P3, ..., up to MATCHER_P10 to
1331
// support multi-parameter matchers.
1333
// Describing Parameterized Matchers
1334
// =================================
1336
// 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,
1343
// using testing::PrintToString;
1345
// MATCHER_P2(InClosedRange, low, hi,
1346
// string(negation ? "is not" : "is") + " in range [" +
1347
// PrintToString(low) + ", " + PrintToString(hi) + "]") {
1348
// return low <= arg && arg <= hi;
1351
// EXPECT_THAT(3, InClosedRange(4, 6));
1352
// EXPECT_THAT(3, Not(InClosedRange(2, 4)));
1354
// would generate two failures that contain the text:
1356
// Expected: is in range [4, 6]
1358
// Expected: is not in range [2, 4]
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,
1364
// MATCHER_P2(InClosedRange, low, hi, "") { ... }
1366
// EXPECT_THAT(3, InClosedRange(4, 6));
1367
// EXPECT_THAT(3, Not(InClosedRange(2, 4)));
1369
// would generate two failures that contain the text:
1371
// Expected: in closed range (4, 6)
1373
// Expected: not (in closed range (2, 4))
1375
// Types of Matcher Parameters
1376
// ===========================
1378
// For the purpose of typing, you can view
1380
// MATCHER_Pk(Foo, p1, ..., pk, description_string) { ... }
1384
// template <typename p1_type, ..., typename pk_type>
1385
// FooMatcherPk<p1_type, ..., pk_type>
1386
// Foo(p1_type p1, ..., pk_type pk) { ... }
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.
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
1405
// Explaining Match Results
1406
// ========================
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:
1416
// MATCHER_P(EqualsLongString, str, "") {
1417
// if (arg == str) return true;
1419
// *result_listener << "the difference: "
1420
/// << DiffStrings(str, arg);
1424
// Overloading Matchers
1425
// ====================
1427
// You can overload matchers with different numbers of parameters:
1429
// MATCHER_P(Blah, a, description_string1) { ... }
1430
// MATCHER_P2(Blah, a, b, description_string2) { ... }
1435
// 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).
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
1453
// To learn more about using these macros, please search for 'MATCHER'
1454
// on http://code.google.com/p/googlemock/wiki/CookBook.
1456
#define MATCHER(name, description)\
1457
class name##Matcher {\
1459
template <typename arg_type>\
1460
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1464
virtual bool MatchAndExplain(\
1465
arg_type arg, ::testing::MatchResultListener* result_listener) const;\
1466
virtual void DescribeTo(::std::ostream* gmock_os) const {\
1467
*gmock_os << FormatDescription(false);\
1469
virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1470
*gmock_os << FormatDescription(true);\
1473
::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(\
1479
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1480
::std::tr1::tuple<>()));\
1482
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1484
template <typename arg_type>\
1485
operator ::testing::Matcher<arg_type>() const {\
1486
return ::testing::Matcher<arg_type>(\
1487
new gmock_Impl<arg_type>());\
1492
GTEST_DISALLOW_ASSIGN_(name##Matcher);\
1494
inline name##Matcher name() {\
1495
return name##Matcher();\
1497
template <typename arg_type>\
1498
bool name##Matcher::gmock_Impl<arg_type>::MatchAndExplain(\
1500
::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1503
#define MATCHER_P(name, p0, description)\
1504
template <typename p0##_type>\
1505
class name##MatcherP {\
1507
template <typename arg_type>\
1508
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1510
explicit gmock_Impl(p0##_type gmock_p0)\
1512
virtual bool MatchAndExplain(\
1513
arg_type arg, ::testing::MatchResultListener* result_listener) const;\
1514
virtual void DescribeTo(::std::ostream* gmock_os) const {\
1515
*gmock_os << FormatDescription(false);\
1517
virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1518
*gmock_os << FormatDescription(true);\
1522
::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(\
1528
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1529
::std::tr1::tuple<p0##_type>(p0)));\
1531
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1533
template <typename arg_type>\
1534
operator ::testing::Matcher<arg_type>() const {\
1535
return ::testing::Matcher<arg_type>(\
1536
new gmock_Impl<arg_type>(p0));\
1538
name##MatcherP(p0##_type gmock_p0) : p0(gmock_p0) {\
1542
GTEST_DISALLOW_ASSIGN_(name##MatcherP);\
1544
template <typename p0##_type>\
1545
inline name##MatcherP<p0##_type> name(p0##_type p0) {\
1546
return name##MatcherP<p0##_type>(p0);\
1548
template <typename p0##_type>\
1549
template <typename arg_type>\
1550
bool name##MatcherP<p0##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1552
::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1555
#define MATCHER_P2(name, p0, p1, description)\
1556
template <typename p0##_type, typename p1##_type>\
1557
class name##MatcherP2 {\
1559
template <typename arg_type>\
1560
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1562
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1)\
1563
: p0(gmock_p0), p1(gmock_p1) {}\
1564
virtual bool MatchAndExplain(\
1565
arg_type arg, ::testing::MatchResultListener* result_listener) const;\
1566
virtual void DescribeTo(::std::ostream* gmock_os) const {\
1567
*gmock_os << FormatDescription(false);\
1569
virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1570
*gmock_os << FormatDescription(true);\
1575
::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(\
1581
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1582
::std::tr1::tuple<p0##_type, p1##_type>(p0, p1)));\
1584
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1586
template <typename arg_type>\
1587
operator ::testing::Matcher<arg_type>() const {\
1588
return ::testing::Matcher<arg_type>(\
1589
new gmock_Impl<arg_type>(p0, p1));\
1591
name##MatcherP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
1597
GTEST_DISALLOW_ASSIGN_(name##MatcherP2);\
1599
template <typename p0##_type, typename p1##_type>\
1600
inline name##MatcherP2<p0##_type, p1##_type> name(p0##_type p0, \
1602
return name##MatcherP2<p0##_type, p1##_type>(p0, p1);\
1604
template <typename p0##_type, typename p1##_type>\
1605
template <typename arg_type>\
1606
bool name##MatcherP2<p0##_type, \
1607
p1##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1609
::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
1612
#define MATCHER_P3(name, p0, p1, p2, description)\
1613
template <typename p0##_type, typename p1##_type, typename p2##_type>\
1614
class name##MatcherP3 {\
1616
template <typename arg_type>\
1617
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1619
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2)\
1620
: p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\
1621
virtual bool MatchAndExplain(\
1622
arg_type arg, ::testing::MatchResultListener* result_listener) const;\
1623
virtual void DescribeTo(::std::ostream* gmock_os) const {\
1624
*gmock_os << FormatDescription(false);\
1626
virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1627
*gmock_os << FormatDescription(true);\
1633
::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(\
1639
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1640
::std::tr1::tuple<p0##_type, p1##_type, p2##_type>(p0, p1, \
1643
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1645
template <typename arg_type>\
1646
operator ::testing::Matcher<arg_type>() const {\
1647
return ::testing::Matcher<arg_type>(\
1648
new gmock_Impl<arg_type>(p0, p1, p2));\
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) {\
1657
GTEST_DISALLOW_ASSIGN_(name##MatcherP3);\
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);\
1664
template <typename p0##_type, typename p1##_type, typename p2##_type>\
1665
template <typename arg_type>\
1666
bool name##MatcherP3<p0##_type, p1##_type, \
1667
p2##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1669
::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
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 {\
1677
template <typename arg_type>\
1678
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1680
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1681
p3##_type gmock_p3)\
1682
: p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3) {}\
1683
virtual bool MatchAndExplain(\
1684
arg_type arg, ::testing::MatchResultListener* result_listener) const;\
1685
virtual void DescribeTo(::std::ostream* gmock_os) const {\
1686
*gmock_os << FormatDescription(false);\
1688
virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1689
*gmock_os << FormatDescription(true);\
1696
::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(\
1702
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1703
::std::tr1::tuple<p0##_type, p1##_type, p2##_type, \
1704
p3##_type>(p0, p1, p2, p3)));\
1706
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1708
template <typename arg_type>\
1709
operator ::testing::Matcher<arg_type>() const {\
1710
return ::testing::Matcher<arg_type>(\
1711
new gmock_Impl<arg_type>(p0, p1, p2, p3));\
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) {\
1722
GTEST_DISALLOW_ASSIGN_(name##MatcherP4);\
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, \
1729
return name##MatcherP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, \
1732
template <typename p0##_type, typename p1##_type, typename p2##_type, \
1733
typename p3##_type>\
1734
template <typename arg_type>\
1735
bool name##MatcherP4<p0##_type, p1##_type, p2##_type, \
1736
p3##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1738
::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
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 {\
1746
template <typename arg_type>\
1747
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1749
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1750
p3##_type gmock_p3, p4##_type gmock_p4)\
1751
: p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1753
virtual bool MatchAndExplain(\
1754
arg_type arg, ::testing::MatchResultListener* result_listener) const;\
1755
virtual void DescribeTo(::std::ostream* gmock_os) const {\
1756
*gmock_os << FormatDescription(false);\
1758
virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1759
*gmock_os << FormatDescription(true);\
1767
::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(\
1773
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
1774
::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
1775
p4##_type>(p0, p1, p2, p3, p4)));\
1777
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1779
template <typename arg_type>\
1780
operator ::testing::Matcher<arg_type>() const {\
1781
return ::testing::Matcher<arg_type>(\
1782
new gmock_Impl<arg_type>(p0, p1, p2, p3, p4));\
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) {\
1795
GTEST_DISALLOW_ASSIGN_(name##MatcherP5);\
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, \
1802
return name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1803
p4##_type>(p0, p1, p2, p3, p4);\
1805
template <typename p0##_type, typename p1##_type, typename p2##_type, \
1806
typename p3##_type, typename p4##_type>\
1807
template <typename arg_type>\
1808
bool name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1809
p4##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1811
::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
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 {\
1819
template <typename arg_type>\
1820
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
1822
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1823
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5)\
1824
: p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1825
p4(gmock_p4), p5(gmock_p5) {}\
1826
virtual bool MatchAndExplain(\
1827
arg_type arg, ::testing::MatchResultListener* result_listener) const;\
1828
virtual void DescribeTo(::std::ostream* gmock_os) const {\
1829
*gmock_os << FormatDescription(false);\
1831
virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1832
*gmock_os << FormatDescription(true);\
1841
::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(\
1847
::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)));\
1851
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1853
template <typename arg_type>\
1854
operator ::testing::Matcher<arg_type>() const {\
1855
return ::testing::Matcher<arg_type>(\
1856
new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5));\
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) {\
1870
GTEST_DISALLOW_ASSIGN_(name##MatcherP6);\
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);\
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, \
1884
p5##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1886
::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
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 {\
1895
template <typename arg_type>\
1896
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
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, \
1900
p6##_type gmock_p6)\
1901
: p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1902
p4(gmock_p4), p5(gmock_p5), p6(gmock_p6) {}\
1903
virtual bool MatchAndExplain(\
1904
arg_type arg, ::testing::MatchResultListener* result_listener) const;\
1905
virtual void DescribeTo(::std::ostream* gmock_os) const {\
1906
*gmock_os << FormatDescription(false);\
1908
virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1909
*gmock_os << FormatDescription(true);\
1919
::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(\
1925
::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, \
1930
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1932
template <typename arg_type>\
1933
operator ::testing::Matcher<arg_type>() const {\
1934
return ::testing::Matcher<arg_type>(\
1935
new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6));\
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), \
1951
GTEST_DISALLOW_ASSIGN_(name##MatcherP7);\
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, \
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);\
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, \
1968
p5##_type, p6##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
1970
::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
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 {\
1979
template <typename arg_type>\
1980
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
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, \
1984
p6##_type gmock_p6, p7##_type gmock_p7)\
1985
: p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
1986
p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7) {}\
1987
virtual bool MatchAndExplain(\
1988
arg_type arg, ::testing::MatchResultListener* result_listener) const;\
1989
virtual void DescribeTo(::std::ostream* gmock_os) const {\
1990
*gmock_os << FormatDescription(false);\
1992
virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
1993
*gmock_os << FormatDescription(true);\
2004
::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(\
2010
::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)));\
2015
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
2017
template <typename arg_type>\
2018
operator ::testing::Matcher<arg_type>() const {\
2019
return ::testing::Matcher<arg_type>(\
2020
new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7));\
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), \
2038
GTEST_DISALLOW_ASSIGN_(name##MatcherP8);\
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, \
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, \
2056
p5##_type, p6##_type, \
2057
p7##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
2059
::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
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 {\
2068
template <typename arg_type>\
2069
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
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, \
2073
p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8)\
2074
: 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), \
2077
virtual bool MatchAndExplain(\
2078
arg_type arg, ::testing::MatchResultListener* result_listener) const;\
2079
virtual void DescribeTo(::std::ostream* gmock_os) const {\
2080
*gmock_os << FormatDescription(false);\
2082
virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
2083
*gmock_os << FormatDescription(true);\
2095
::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(\
2101
::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)));\
2106
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
2108
template <typename arg_type>\
2109
operator ::testing::Matcher<arg_type>() const {\
2110
return ::testing::Matcher<arg_type>(\
2111
new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8));\
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), \
2130
GTEST_DISALLOW_ASSIGN_(name##MatcherP9);\
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, \
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);\
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, \
2149
p5##_type, p6##_type, p7##_type, \
2150
p8##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
2152
::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
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 {\
2162
template <typename arg_type>\
2163
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
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, \
2168
p9##_type gmock_p9)\
2169
: 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), \
2171
p8(gmock_p8), p9(gmock_p9) {}\
2172
virtual bool MatchAndExplain(\
2173
arg_type arg, ::testing::MatchResultListener* result_listener) const;\
2174
virtual void DescribeTo(::std::ostream* gmock_os) const {\
2175
*gmock_os << FormatDescription(false);\
2177
virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
2178
*gmock_os << FormatDescription(true);\
2191
::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(\
2197
::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)));\
2202
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
2204
template <typename arg_type>\
2205
operator ::testing::Matcher<arg_type>() const {\
2206
return ::testing::Matcher<arg_type>(\
2207
new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9));\
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) {\
2227
GTEST_DISALLOW_ASSIGN_(name##MatcherP10);\
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, \
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);\
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, \
2248
p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
2249
p9##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
2251
::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
2254
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_