00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_H_
00037 #define GMOCK_INCLUDE_GMOCK_GMOCK_H_
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
00094 #define GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
00095
00096 #ifndef _WIN32_WCE
00097 # include <errno.h>
00098 #endif
00099
00100 #include <algorithm>
00101 #include <string>
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140 #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
00141 #define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
00142
00143 #include <stdio.h>
00144 #include <ostream>
00145 #include <string>
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187 #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
00188 #define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225 #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
00226 #define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
00227
00228 #include <assert.h>
00229 #include <stdlib.h>
00230 #include <iostream>
00231
00232
00233
00234 #include "gtest/gtest.h"
00235
00236
00237
00238
00239
00240
00241
00242
00243 #if defined(_MSC_VER) && _MSC_VER < 1310
00244 # error "At least Visual C++ 2003 (7.1) is required to compile Google Mock."
00245 #endif
00246
00247
00248
00249 #define GMOCK_FLAG(name) FLAGS_gmock_##name
00250
00251
00252 #define GMOCK_DECLARE_bool_(name) extern GTEST_API_ bool GMOCK_FLAG(name)
00253 #define GMOCK_DECLARE_int32_(name) \
00254 extern GTEST_API_ ::testing::internal::Int32 GMOCK_FLAG(name)
00255 #define GMOCK_DECLARE_string_(name) \
00256 extern GTEST_API_ ::std::string GMOCK_FLAG(name)
00257
00258
00259 #define GMOCK_DEFINE_bool_(name, default_val, doc) \
00260 GTEST_API_ bool GMOCK_FLAG(name) = (default_val)
00261 #define GMOCK_DEFINE_int32_(name, default_val, doc) \
00262 GTEST_API_ ::testing::internal::Int32 GMOCK_FLAG(name) = (default_val)
00263 #define GMOCK_DEFINE_string_(name, default_val, doc) \
00264 GTEST_API_ ::std::string GMOCK_FLAG(name) = (default_val)
00265
00266 #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
00267
00268 namespace testing {
00269
00270 template <typename T>
00271 class Matcher;
00272
00273 namespace internal {
00274
00275
00276
00277 class IgnoredValue {
00278 public:
00279
00280
00281
00282
00283
00284 template <typename T>
00285 IgnoredValue(const T& ) {}
00286 };
00287
00288
00289
00290 template <typename Tuple>
00291 struct MatcherTuple;
00292
00293 template <>
00294 struct MatcherTuple< ::std::tr1::tuple<> > {
00295 typedef ::std::tr1::tuple< > type;
00296 };
00297
00298 template <typename A1>
00299 struct MatcherTuple< ::std::tr1::tuple<A1> > {
00300 typedef ::std::tr1::tuple<Matcher<A1> > type;
00301 };
00302
00303 template <typename A1, typename A2>
00304 struct MatcherTuple< ::std::tr1::tuple<A1, A2> > {
00305 typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2> > type;
00306 };
00307
00308 template <typename A1, typename A2, typename A3>
00309 struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3> > {
00310 typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3> > type;
00311 };
00312
00313 template <typename A1, typename A2, typename A3, typename A4>
00314 struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4> > {
00315 typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>,
00316 Matcher<A4> > type;
00317 };
00318
00319 template <typename A1, typename A2, typename A3, typename A4, typename A5>
00320 struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5> > {
00321 typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
00322 Matcher<A5> > type;
00323 };
00324
00325 template <typename A1, typename A2, typename A3, typename A4, typename A5,
00326 typename A6>
00327 struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6> > {
00328 typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
00329 Matcher<A5>, Matcher<A6> > type;
00330 };
00331
00332 template <typename A1, typename A2, typename A3, typename A4, typename A5,
00333 typename A6, typename A7>
00334 struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7> > {
00335 typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
00336 Matcher<A5>, Matcher<A6>, Matcher<A7> > type;
00337 };
00338
00339 template <typename A1, typename A2, typename A3, typename A4, typename A5,
00340 typename A6, typename A7, typename A8>
00341 struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {
00342 typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
00343 Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8> > type;
00344 };
00345
00346 template <typename A1, typename A2, typename A3, typename A4, typename A5,
00347 typename A6, typename A7, typename A8, typename A9>
00348 struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > {
00349 typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
00350 Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>, Matcher<A9> > type;
00351 };
00352
00353 template <typename A1, typename A2, typename A3, typename A4, typename A5,
00354 typename A6, typename A7, typename A8, typename A9, typename A10>
00355 struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
00356 A10> > {
00357 typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
00358 Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>, Matcher<A9>,
00359 Matcher<A10> > type;
00360 };
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375 template <typename F>
00376 struct Function;
00377
00378 template <typename R>
00379 struct Function<R()> {
00380 typedef R Result;
00381 typedef ::std::tr1::tuple<> ArgumentTuple;
00382 typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
00383 typedef void MakeResultVoid();
00384 typedef IgnoredValue MakeResultIgnoredValue();
00385 };
00386
00387 template <typename R, typename A1>
00388 struct Function<R(A1)>
00389 : Function<R()> {
00390 typedef A1 Argument1;
00391 typedef ::std::tr1::tuple<A1> ArgumentTuple;
00392 typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
00393 typedef void MakeResultVoid(A1);
00394 typedef IgnoredValue MakeResultIgnoredValue(A1);
00395 };
00396
00397 template <typename R, typename A1, typename A2>
00398 struct Function<R(A1, A2)>
00399 : Function<R(A1)> {
00400 typedef A2 Argument2;
00401 typedef ::std::tr1::tuple<A1, A2> ArgumentTuple;
00402 typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
00403 typedef void MakeResultVoid(A1, A2);
00404 typedef IgnoredValue MakeResultIgnoredValue(A1, A2);
00405 };
00406
00407 template <typename R, typename A1, typename A2, typename A3>
00408 struct Function<R(A1, A2, A3)>
00409 : Function<R(A1, A2)> {
00410 typedef A3 Argument3;
00411 typedef ::std::tr1::tuple<A1, A2, A3> ArgumentTuple;
00412 typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
00413 typedef void MakeResultVoid(A1, A2, A3);
00414 typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3);
00415 };
00416
00417 template <typename R, typename A1, typename A2, typename A3, typename A4>
00418 struct Function<R(A1, A2, A3, A4)>
00419 : Function<R(A1, A2, A3)> {
00420 typedef A4 Argument4;
00421 typedef ::std::tr1::tuple<A1, A2, A3, A4> ArgumentTuple;
00422 typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
00423 typedef void MakeResultVoid(A1, A2, A3, A4);
00424 typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4);
00425 };
00426
00427 template <typename R, typename A1, typename A2, typename A3, typename A4,
00428 typename A5>
00429 struct Function<R(A1, A2, A3, A4, A5)>
00430 : Function<R(A1, A2, A3, A4)> {
00431 typedef A5 Argument5;
00432 typedef ::std::tr1::tuple<A1, A2, A3, A4, A5> ArgumentTuple;
00433 typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
00434 typedef void MakeResultVoid(A1, A2, A3, A4, A5);
00435 typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5);
00436 };
00437
00438 template <typename R, typename A1, typename A2, typename A3, typename A4,
00439 typename A5, typename A6>
00440 struct Function<R(A1, A2, A3, A4, A5, A6)>
00441 : Function<R(A1, A2, A3, A4, A5)> {
00442 typedef A6 Argument6;
00443 typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6> ArgumentTuple;
00444 typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
00445 typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6);
00446 typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6);
00447 };
00448
00449 template <typename R, typename A1, typename A2, typename A3, typename A4,
00450 typename A5, typename A6, typename A7>
00451 struct Function<R(A1, A2, A3, A4, A5, A6, A7)>
00452 : Function<R(A1, A2, A3, A4, A5, A6)> {
00453 typedef A7 Argument7;
00454 typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7> ArgumentTuple;
00455 typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
00456 typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7);
00457 typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7);
00458 };
00459
00460 template <typename R, typename A1, typename A2, typename A3, typename A4,
00461 typename A5, typename A6, typename A7, typename A8>
00462 struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8)>
00463 : Function<R(A1, A2, A3, A4, A5, A6, A7)> {
00464 typedef A8 Argument8;
00465 typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8> ArgumentTuple;
00466 typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
00467 typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8);
00468 typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8);
00469 };
00470
00471 template <typename R, typename A1, typename A2, typename A3, typename A4,
00472 typename A5, typename A6, typename A7, typename A8, typename A9>
00473 struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)>
00474 : Function<R(A1, A2, A3, A4, A5, A6, A7, A8)> {
00475 typedef A9 Argument9;
00476 typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> ArgumentTuple;
00477 typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
00478 typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9);
00479 typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8,
00480 A9);
00481 };
00482
00483 template <typename R, typename A1, typename A2, typename A3, typename A4,
00484 typename A5, typename A6, typename A7, typename A8, typename A9,
00485 typename A10>
00486 struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
00487 : Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
00488 typedef A10 Argument10;
00489 typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
00490 A10> ArgumentTuple;
00491 typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
00492 typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
00493 typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8,
00494 A9, A10);
00495 };
00496
00497 }
00498
00499 }
00500
00501 #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
00502
00503 namespace testing {
00504 namespace internal {
00505
00506
00507
00508
00509
00510 GTEST_API_ string ConvertIdentifierNameToWords(const char* id_name);
00511
00512
00513
00514
00515
00516 template <typename Pointer>
00517 struct PointeeOf {
00518
00519
00520 typedef typename Pointer::element_type type;
00521 };
00522
00523 template <typename T>
00524 struct PointeeOf<T*> { typedef T type; };
00525
00526
00527
00528
00529 template <typename Pointer>
00530 inline const typename Pointer::element_type* GetRawPointer(const Pointer& p) {
00531 return p.get();
00532 }
00533
00534 template <typename Element>
00535 inline Element* GetRawPointer(Element* p) { return p; }
00536
00537
00538 template <typename T>
00539 struct LinkedPtrLessThan {
00540 bool operator()(const ::testing::internal::linked_ptr<T>& lhs,
00541 const ::testing::internal::linked_ptr<T>& rhs) const {
00542 return lhs.get() < rhs.get();
00543 }
00544 };
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554 #if (GTEST_OS_SYMBIAN && defined(_STLP_NO_WCHAR_T)) || \
00555 (defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED))
00556
00557 #else
00558 # define GMOCK_WCHAR_T_IS_NATIVE_ 1
00559 #endif
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570 #ifdef __GNUC__
00571
00572 # define GMOCK_HAS_SIGNED_WCHAR_T_ 1
00573 #endif
00574
00575
00576
00577
00578
00579
00580 enum TypeKind {
00581 kBool, kInteger, kFloatingPoint, kOther
00582 };
00583
00584
00585 template <typename T> struct KindOf {
00586 enum { value = kOther };
00587 };
00588
00589
00590 #define GMOCK_DECLARE_KIND_(type, kind) \
00591 template <> struct KindOf<type> { enum { value = kind }; }
00592
00593 GMOCK_DECLARE_KIND_(bool, kBool);
00594
00595
00596 GMOCK_DECLARE_KIND_(char, kInteger);
00597 GMOCK_DECLARE_KIND_(signed char, kInteger);
00598 GMOCK_DECLARE_KIND_(unsigned char, kInteger);
00599 GMOCK_DECLARE_KIND_(short, kInteger);
00600 GMOCK_DECLARE_KIND_(unsigned short, kInteger);
00601 GMOCK_DECLARE_KIND_(int, kInteger);
00602 GMOCK_DECLARE_KIND_(unsigned int, kInteger);
00603 GMOCK_DECLARE_KIND_(long, kInteger);
00604 GMOCK_DECLARE_KIND_(unsigned long, kInteger);
00605
00606 #if GMOCK_WCHAR_T_IS_NATIVE_
00607 GMOCK_DECLARE_KIND_(wchar_t, kInteger);
00608 #endif
00609
00610
00611 GMOCK_DECLARE_KIND_(Int64, kInteger);
00612 GMOCK_DECLARE_KIND_(UInt64, kInteger);
00613
00614
00615 GMOCK_DECLARE_KIND_(float, kFloatingPoint);
00616 GMOCK_DECLARE_KIND_(double, kFloatingPoint);
00617 GMOCK_DECLARE_KIND_(long double, kFloatingPoint);
00618
00619 #undef GMOCK_DECLARE_KIND_
00620
00621
00622 #define GMOCK_KIND_OF_(type) \
00623 static_cast< ::testing::internal::TypeKind>( \
00624 ::testing::internal::KindOf<type>::value)
00625
00626
00627 #define GMOCK_IS_SIGNED_(T) (static_cast<T>(-1) < 0)
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638 template <TypeKind kFromKind, typename From, TypeKind kToKind, typename To>
00639 struct LosslessArithmeticConvertibleImpl : public false_type {};
00640
00641
00642 template <>
00643 struct LosslessArithmeticConvertibleImpl<kBool, bool, kBool, bool>
00644 : public true_type {};
00645
00646
00647 template <typename To>
00648 struct LosslessArithmeticConvertibleImpl<kBool, bool, kInteger, To>
00649 : public true_type {};
00650
00651
00652 template <typename To>
00653 struct LosslessArithmeticConvertibleImpl<kBool, bool, kFloatingPoint, To>
00654 : public true_type {};
00655
00656
00657 template <typename From>
00658 struct LosslessArithmeticConvertibleImpl<kInteger, From, kBool, bool>
00659 : public false_type {};
00660
00661
00662
00663 template <typename From, typename To>
00664 struct LosslessArithmeticConvertibleImpl<kInteger, From, kInteger, To>
00665 : public bool_constant<
00666
00667
00668 ((sizeof(From) < sizeof(To)) &&
00669 (!GMOCK_IS_SIGNED_(From) || GMOCK_IS_SIGNED_(To))) ||
00670
00671 ((sizeof(From) == sizeof(To)) &&
00672 (GMOCK_IS_SIGNED_(From) == GMOCK_IS_SIGNED_(To)))> {};
00673
00674 #undef GMOCK_IS_SIGNED_
00675
00676
00677
00678 template <typename From, typename To>
00679 struct LosslessArithmeticConvertibleImpl<kInteger, From, kFloatingPoint, To>
00680 : public false_type {};
00681
00682
00683 template <typename From>
00684 struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kBool, bool>
00685 : public false_type {};
00686
00687
00688 template <typename From, typename To>
00689 struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kInteger, To>
00690 : public false_type {};
00691
00692
00693
00694 template <typename From, typename To>
00695 struct LosslessArithmeticConvertibleImpl<
00696 kFloatingPoint, From, kFloatingPoint, To>
00697 : public bool_constant<sizeof(From) <= sizeof(To)> {};
00698
00699
00700
00701
00702
00703
00704
00705
00706 template <typename From, typename To>
00707 struct LosslessArithmeticConvertible
00708 : public LosslessArithmeticConvertibleImpl<
00709 GMOCK_KIND_OF_(From), From, GMOCK_KIND_OF_(To), To> {};
00710
00711
00712
00713 class FailureReporterInterface {
00714 public:
00715
00716 enum FailureType {
00717 kNonfatal, kFatal
00718 };
00719
00720 virtual ~FailureReporterInterface() {}
00721
00722
00723 virtual void ReportFailure(FailureType type, const char* file, int line,
00724 const string& message) = 0;
00725 };
00726
00727
00728 GTEST_API_ FailureReporterInterface* GetFailureReporter();
00729
00730
00731
00732
00733
00734
00735 inline void Assert(bool condition, const char* file, int line,
00736 const string& msg) {
00737 if (!condition) {
00738 GetFailureReporter()->ReportFailure(FailureReporterInterface::kFatal,
00739 file, line, msg);
00740 }
00741 }
00742 inline void Assert(bool condition, const char* file, int line) {
00743 Assert(condition, file, line, "Assertion failed.");
00744 }
00745
00746
00747
00748 inline void Expect(bool condition, const char* file, int line,
00749 const string& msg) {
00750 if (!condition) {
00751 GetFailureReporter()->ReportFailure(FailureReporterInterface::kNonfatal,
00752 file, line, msg);
00753 }
00754 }
00755 inline void Expect(bool condition, const char* file, int line) {
00756 Expect(condition, file, line, "Expectation failed.");
00757 }
00758
00759
00760 enum LogSeverity {
00761 kInfo = 0,
00762 kWarning = 1
00763 };
00764
00765
00766
00767
00768 const char kInfoVerbosity[] = "info";
00769
00770 const char kWarningVerbosity[] = "warning";
00771
00772 const char kErrorVerbosity[] = "error";
00773
00774
00775
00776 GTEST_API_ bool LogIsVisible(LogSeverity severity);
00777
00778
00779
00780
00781
00782
00783
00784
00785 GTEST_API_ void Log(LogSeverity severity,
00786 const string& message,
00787 int stack_frames_to_skip);
00788
00789
00790
00791
00792
00793
00794 template <typename T> struct is_reference : public false_type {};
00795 template <typename T> struct is_reference<T&> : public true_type {};
00796
00797
00798 template <typename T1, typename T2> struct type_equals : public false_type {};
00799 template <typename T> struct type_equals<T, T> : public true_type {};
00800
00801
00802 template <typename T> struct remove_reference { typedef T type; };
00803 template <typename T> struct remove_reference<T&> { typedef T type; };
00804
00805
00806
00807 template <typename T> struct DecayArray { typedef T type; };
00808 template <typename T, size_t N> struct DecayArray<T[N]> {
00809 typedef const T* type;
00810 };
00811
00812
00813
00814 template <typename T> struct DecayArray<T[]> {
00815 typedef const T* type;
00816 };
00817
00818
00819
00820
00821
00822 template <typename T>
00823 inline T Invalid() {
00824 return const_cast<typename remove_reference<T>::type&>(
00825 *static_cast<volatile typename remove_reference<T>::type*>(NULL));
00826 }
00827 template <>
00828 inline void Invalid<void>() {}
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846 template <class RawContainer>
00847 class StlContainerView {
00848 public:
00849 typedef RawContainer type;
00850 typedef const type& const_reference;
00851
00852 static const_reference ConstReference(const RawContainer& container) {
00853
00854 testing::StaticAssertTypeEq<RawContainer,
00855 GTEST_REMOVE_CONST_(RawContainer)>();
00856 return container;
00857 }
00858 static type Copy(const RawContainer& container) { return container; }
00859 };
00860
00861
00862 template <typename Element, size_t N>
00863 class StlContainerView<Element[N]> {
00864 public:
00865 typedef GTEST_REMOVE_CONST_(Element) RawElement;
00866 typedef internal::NativeArray<RawElement> type;
00867
00868
00869
00870
00871
00872 typedef const type const_reference;
00873
00874 static const_reference ConstReference(const Element (&array)[N]) {
00875
00876 testing::StaticAssertTypeEq<Element, RawElement>();
00877 #if GTEST_OS_SYMBIAN
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891 return type(const_cast<Element*>(&array[0]), N, kReference);
00892 #else
00893 return type(array, N, kReference);
00894 #endif // GTEST_OS_SYMBIAN
00895 }
00896 static type Copy(const Element (&array)[N]) {
00897 #if GTEST_OS_SYMBIAN
00898 return type(const_cast<Element*>(&array[0]), N, kCopy);
00899 #else
00900 return type(array, N, kCopy);
00901 #endif // GTEST_OS_SYMBIAN
00902 }
00903 };
00904
00905
00906
00907 template <typename ElementPointer, typename Size>
00908 class StlContainerView< ::std::tr1::tuple<ElementPointer, Size> > {
00909 public:
00910 typedef GTEST_REMOVE_CONST_(
00911 typename internal::PointeeOf<ElementPointer>::type) RawElement;
00912 typedef internal::NativeArray<RawElement> type;
00913 typedef const type const_reference;
00914
00915 static const_reference ConstReference(
00916 const ::std::tr1::tuple<ElementPointer, Size>& array) {
00917 using ::std::tr1::get;
00918 return type(get<0>(array), get<1>(array), kReference);
00919 }
00920 static type Copy(const ::std::tr1::tuple<ElementPointer, Size>& array) {
00921 using ::std::tr1::get;
00922 return type(get<0>(array), get<1>(array), kCopy);
00923 }
00924 };
00925
00926
00927
00928 template <typename T> class StlContainerView<T&>;
00929
00930
00931
00932
00933 template <typename T>
00934 struct RemoveConstFromKey {
00935 typedef T type;
00936 };
00937
00938
00939 template <typename K, typename V>
00940 struct RemoveConstFromKey<std::pair<const K, V> > {
00941 typedef std::pair<K, V> type;
00942 };
00943
00944
00945
00946 template <bool kValue>
00947 struct BooleanConstant {};
00948
00949 }
00950 }
00951
00952 #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
00953
00954 namespace testing {
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965 namespace internal {
00966
00967 template <typename F1, typename F2>
00968 class ActionAdaptor;
00969
00970
00971
00972
00973
00974
00975 template <typename T>
00976 class BuiltInDefaultValue {
00977 public:
00978
00979 static bool Exists() { return false; }
00980 static T Get() {
00981 Assert(false, __FILE__, __LINE__,
00982 "Default action undefined for the function return type.");
00983 return internal::Invalid<T>();
00984
00985
00986 }
00987 };
00988
00989
00990
00991 template <typename T>
00992 class BuiltInDefaultValue<const T> {
00993 public:
00994 static bool Exists() { return BuiltInDefaultValue<T>::Exists(); }
00995 static T Get() { return BuiltInDefaultValue<T>::Get(); }
00996 };
00997
00998
00999
01000 template <typename T>
01001 class BuiltInDefaultValue<T*> {
01002 public:
01003 static bool Exists() { return true; }
01004 static T* Get() { return NULL; }
01005 };
01006
01007
01008
01009 #define GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(type, value) \
01010 template <> \
01011 class BuiltInDefaultValue<type> { \
01012 public: \
01013 static bool Exists() { return true; } \
01014 static type Get() { return value; } \
01015 }
01016
01017 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(void, );
01018 #if GTEST_HAS_GLOBAL_STRING
01019 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(::string, "");
01020 #endif // GTEST_HAS_GLOBAL_STRING
01021 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(::std::string, "");
01022 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(bool, false);
01023 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned char, '\0');
01024 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed char, '\0');
01025 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(char, '\0');
01026
01027
01028
01029
01030
01031
01032
01033 #if GMOCK_WCHAR_T_IS_NATIVE_
01034 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(wchar_t, 0U);
01035 #endif
01036
01037 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned short, 0U);
01038 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed short, 0);
01039 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned int, 0U);
01040 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed int, 0);
01041 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned long, 0UL);
01042 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed long, 0L);
01043 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(UInt64, 0);
01044 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(Int64, 0);
01045 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(float, 0);
01046 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(double, 0);
01047
01048 #undef GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
01049
01050 }
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065 template <typename T>
01066 class DefaultValue {
01067 public:
01068
01069
01070 static void Set(T x) {
01071 delete value_;
01072 value_ = new T(x);
01073 }
01074
01075
01076 static void Clear() {
01077 delete value_;
01078 value_ = NULL;
01079 }
01080
01081
01082 static bool IsSet() { return value_ != NULL; }
01083
01084
01085
01086 static bool Exists() {
01087 return IsSet() || internal::BuiltInDefaultValue<T>::Exists();
01088 }
01089
01090
01091
01092
01093 static T Get() {
01094 return value_ == NULL ?
01095 internal::BuiltInDefaultValue<T>::Get() : *value_;
01096 }
01097
01098 private:
01099 static const T* value_;
01100 };
01101
01102
01103
01104 template <typename T>
01105 class DefaultValue<T&> {
01106 public:
01107
01108 static void Set(T& x) {
01109 address_ = &x;
01110 }
01111
01112
01113 static void Clear() {
01114 address_ = NULL;
01115 }
01116
01117
01118 static bool IsSet() { return address_ != NULL; }
01119
01120
01121
01122 static bool Exists() {
01123 return IsSet() || internal::BuiltInDefaultValue<T&>::Exists();
01124 }
01125
01126
01127
01128
01129 static T& Get() {
01130 return address_ == NULL ?
01131 internal::BuiltInDefaultValue<T&>::Get() : *address_;
01132 }
01133
01134 private:
01135 static T* address_;
01136 };
01137
01138
01139
01140 template <>
01141 class DefaultValue<void> {
01142 public:
01143 static bool Exists() { return true; }
01144 static void Get() {}
01145 };
01146
01147
01148 template <typename T>
01149 const T* DefaultValue<T>::value_ = NULL;
01150
01151
01152 template <typename T>
01153 T* DefaultValue<T&>::address_ = NULL;
01154
01155
01156 template <typename F>
01157 class ActionInterface {
01158 public:
01159 typedef typename internal::Function<F>::Result Result;
01160 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
01161
01162 ActionInterface() {}
01163 virtual ~ActionInterface() {}
01164
01165
01166
01167
01168
01169 virtual Result Perform(const ArgumentTuple& args) = 0;
01170
01171 private:
01172 GTEST_DISALLOW_COPY_AND_ASSIGN_(ActionInterface);
01173 };
01174
01175
01176
01177
01178
01179
01180
01181
01182
01183
01184 template <typename F>
01185 class Action {
01186 public:
01187 typedef typename internal::Function<F>::Result Result;
01188 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
01189
01190
01191
01192 Action() : impl_(NULL) {}
01193
01194
01195
01196 explicit Action(ActionInterface<F>* impl) : impl_(impl) {}
01197
01198
01199 Action(const Action& action) : impl_(action.impl_) {}
01200
01201
01202
01203
01204
01205 template <typename Func>
01206 explicit Action(const Action<Func>& action);
01207
01208
01209 bool IsDoDefault() const { return impl_.get() == NULL; }
01210
01211
01212
01213
01214
01215
01216
01217 Result Perform(const ArgumentTuple& args) const {
01218 internal::Assert(
01219 !IsDoDefault(), __FILE__, __LINE__,
01220 "You are using DoDefault() inside a composite action like "
01221 "DoAll() or WithArgs(). This is not supported for technical "
01222 "reasons. Please instead spell out the default action, or "
01223 "assign the default action to an Action variable and use "
01224 "the variable in various places.");
01225 return impl_->Perform(args);
01226 }
01227
01228 private:
01229 template <typename F1, typename F2>
01230 friend class internal::ActionAdaptor;
01231
01232 internal::linked_ptr<ActionInterface<F> > impl_;
01233 };
01234
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247
01248
01249
01250
01251
01252
01253
01254
01255
01256 template <typename Impl>
01257 class PolymorphicAction {
01258 public:
01259 explicit PolymorphicAction(const Impl& impl) : impl_(impl) {}
01260
01261 template <typename F>
01262 operator Action<F>() const {
01263 return Action<F>(new MonomorphicImpl<F>(impl_));
01264 }
01265
01266 private:
01267 template <typename F>
01268 class MonomorphicImpl : public ActionInterface<F> {
01269 public:
01270 typedef typename internal::Function<F>::Result Result;
01271 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
01272
01273 explicit MonomorphicImpl(const Impl& impl) : impl_(impl) {}
01274
01275 virtual Result Perform(const ArgumentTuple& args) {
01276 return impl_.template Perform<Result>(args);
01277 }
01278
01279 private:
01280 Impl impl_;
01281
01282 GTEST_DISALLOW_ASSIGN_(MonomorphicImpl);
01283 };
01284
01285 Impl impl_;
01286
01287 GTEST_DISALLOW_ASSIGN_(PolymorphicAction);
01288 };
01289
01290
01291
01292 template <typename F>
01293 Action<F> MakeAction(ActionInterface<F>* impl) {
01294 return Action<F>(impl);
01295 }
01296
01297
01298
01299
01300
01301
01302
01303
01304 template <typename Impl>
01305 inline PolymorphicAction<Impl> MakePolymorphicAction(const Impl& impl) {
01306 return PolymorphicAction<Impl>(impl);
01307 }
01308
01309 namespace internal {
01310
01311
01312
01313 template <typename F1, typename F2>
01314 class ActionAdaptor : public ActionInterface<F1> {
01315 public:
01316 typedef typename internal::Function<F1>::Result Result;
01317 typedef typename internal::Function<F1>::ArgumentTuple ArgumentTuple;
01318
01319 explicit ActionAdaptor(const Action<F2>& from) : impl_(from.impl_) {}
01320
01321 virtual Result Perform(const ArgumentTuple& args) {
01322 return impl_->Perform(args);
01323 }
01324
01325 private:
01326 const internal::linked_ptr<ActionInterface<F2> > impl_;
01327
01328 GTEST_DISALLOW_ASSIGN_(ActionAdaptor);
01329 };
01330
01331
01332
01333
01334
01335
01336
01337
01338
01339
01340
01341
01342
01343
01344
01345
01346
01347
01348
01349
01350
01351
01352
01353
01354
01355 template <typename R>
01356 class ReturnAction {
01357 public:
01358
01359
01360
01361 explicit ReturnAction(R value) : value_(value) {}
01362
01363
01364
01365 template <typename F>
01366 operator Action<F>() const {
01367
01368
01369
01370
01371
01372
01373
01374
01375 typedef typename Function<F>::Result Result;
01376 GTEST_COMPILE_ASSERT_(
01377 !internal::is_reference<Result>::value,
01378 use_ReturnRef_instead_of_Return_to_return_a_reference);
01379 return Action<F>(new Impl<F>(value_));
01380 }
01381
01382 private:
01383
01384 template <typename F>
01385 class Impl : public ActionInterface<F> {
01386 public:
01387 typedef typename Function<F>::Result Result;
01388 typedef typename Function<F>::ArgumentTuple ArgumentTuple;
01389
01390
01391
01392
01393
01394
01395
01396
01397 explicit Impl(R value)
01398 : value_(::testing::internal::ImplicitCast_<Result>(value)) {}
01399
01400 virtual Result Perform(const ArgumentTuple&) { return value_; }
01401
01402 private:
01403 GTEST_COMPILE_ASSERT_(!internal::is_reference<Result>::value,
01404 Result_cannot_be_a_reference_type);
01405 Result value_;
01406
01407 GTEST_DISALLOW_ASSIGN_(Impl);
01408 };
01409
01410 R value_;
01411
01412 GTEST_DISALLOW_ASSIGN_(ReturnAction);
01413 };
01414
01415
01416 class ReturnNullAction {
01417 public:
01418
01419 template <typename Result, typename ArgumentTuple>
01420 static Result Perform(const ArgumentTuple&) {
01421 GTEST_COMPILE_ASSERT_(internal::is_pointer<Result>::value,
01422 ReturnNull_can_be_used_to_return_a_pointer_only);
01423 return NULL;
01424 }
01425 };
01426
01427
01428 class ReturnVoidAction {
01429 public:
01430
01431 template <typename Result, typename ArgumentTuple>
01432 static void Perform(const ArgumentTuple&) {
01433 CompileAssertTypesEqual<void, Result>();
01434 }
01435 };
01436
01437
01438
01439
01440 template <typename T>
01441 class ReturnRefAction {
01442 public:
01443
01444 explicit ReturnRefAction(T& ref) : ref_(ref) {}
01445
01446
01447
01448 template <typename F>
01449 operator Action<F>() const {
01450 typedef typename Function<F>::Result Result;
01451
01452
01453
01454 GTEST_COMPILE_ASSERT_(internal::is_reference<Result>::value,
01455 use_Return_instead_of_ReturnRef_to_return_a_value);
01456 return Action<F>(new Impl<F>(ref_));
01457 }
01458
01459 private:
01460
01461 template <typename F>
01462 class Impl : public ActionInterface<F> {
01463 public:
01464 typedef typename Function<F>::Result Result;
01465 typedef typename Function<F>::ArgumentTuple ArgumentTuple;
01466
01467 explicit Impl(T& ref) : ref_(ref) {}
01468
01469 virtual Result Perform(const ArgumentTuple&) {
01470 return ref_;
01471 }
01472
01473 private:
01474 T& ref_;
01475
01476 GTEST_DISALLOW_ASSIGN_(Impl);
01477 };
01478
01479 T& ref_;
01480
01481 GTEST_DISALLOW_ASSIGN_(ReturnRefAction);
01482 };
01483
01484
01485
01486
01487 template <typename T>
01488 class ReturnRefOfCopyAction {
01489 public:
01490
01491
01492 explicit ReturnRefOfCopyAction(const T& value) : value_(value) {}
01493
01494
01495
01496 template <typename F>
01497 operator Action<F>() const {
01498 typedef typename Function<F>::Result Result;
01499
01500
01501
01502 GTEST_COMPILE_ASSERT_(
01503 internal::is_reference<Result>::value,
01504 use_Return_instead_of_ReturnRefOfCopy_to_return_a_value);
01505 return Action<F>(new Impl<F>(value_));
01506 }
01507
01508 private:
01509
01510 template <typename F>
01511 class Impl : public ActionInterface<F> {
01512 public:
01513 typedef typename Function<F>::Result Result;
01514 typedef typename Function<F>::ArgumentTuple ArgumentTuple;
01515
01516 explicit Impl(const T& value) : value_(value) {}
01517
01518 virtual Result Perform(const ArgumentTuple&) {
01519 return value_;
01520 }
01521
01522 private:
01523 T value_;
01524
01525 GTEST_DISALLOW_ASSIGN_(Impl);
01526 };
01527
01528 const T value_;
01529
01530 GTEST_DISALLOW_ASSIGN_(ReturnRefOfCopyAction);
01531 };
01532
01533
01534 class DoDefaultAction {
01535 public:
01536
01537
01538 template <typename F>
01539 operator Action<F>() const { return Action<F>(NULL); }
01540 };
01541
01542
01543
01544 template <typename T1, typename T2>
01545 class AssignAction {
01546 public:
01547 AssignAction(T1* ptr, T2 value) : ptr_(ptr), value_(value) {}
01548
01549 template <typename Result, typename ArgumentTuple>
01550 void Perform(const ArgumentTuple& ) const {
01551 *ptr_ = value_;
01552 }
01553
01554 private:
01555 T1* const ptr_;
01556 const T2 value_;
01557
01558 GTEST_DISALLOW_ASSIGN_(AssignAction);
01559 };
01560
01561 #if !GTEST_OS_WINDOWS_MOBILE
01562
01563
01564
01565 template <typename T>
01566 class SetErrnoAndReturnAction {
01567 public:
01568 SetErrnoAndReturnAction(int errno_value, T result)
01569 : errno_(errno_value),
01570 result_(result) {}
01571 template <typename Result, typename ArgumentTuple>
01572 Result Perform(const ArgumentTuple& ) const {
01573 errno = errno_;
01574 return result_;
01575 }
01576
01577 private:
01578 const int errno_;
01579 const T result_;
01580
01581 GTEST_DISALLOW_ASSIGN_(SetErrnoAndReturnAction);
01582 };
01583
01584 #endif // !GTEST_OS_WINDOWS_MOBILE
01585
01586
01587
01588
01589
01590 template <size_t N, typename A, bool kIsProto>
01591 class SetArgumentPointeeAction {
01592 public:
01593
01594
01595 explicit SetArgumentPointeeAction(const A& value) : value_(value) {}
01596
01597 template <typename Result, typename ArgumentTuple>
01598 void Perform(const ArgumentTuple& args) const {
01599 CompileAssertTypesEqual<void, Result>();
01600 *::std::tr1::get<N>(args) = value_;
01601 }
01602
01603 private:
01604 const A value_;
01605
01606 GTEST_DISALLOW_ASSIGN_(SetArgumentPointeeAction);
01607 };
01608
01609 template <size_t N, typename Proto>
01610 class SetArgumentPointeeAction<N, Proto, true> {
01611 public:
01612
01613
01614
01615
01616 explicit SetArgumentPointeeAction(const Proto& proto) : proto_(new Proto) {
01617 proto_->CopyFrom(proto);
01618 }
01619
01620 template <typename Result, typename ArgumentTuple>
01621 void Perform(const ArgumentTuple& args) const {
01622 CompileAssertTypesEqual<void, Result>();
01623 ::std::tr1::get<N>(args)->CopyFrom(*proto_);
01624 }
01625
01626 private:
01627 const internal::linked_ptr<Proto> proto_;
01628
01629 GTEST_DISALLOW_ASSIGN_(SetArgumentPointeeAction);
01630 };
01631
01632
01633
01634
01635
01636
01637 template <typename FunctionImpl>
01638 class InvokeWithoutArgsAction {
01639 public:
01640
01641
01642 explicit InvokeWithoutArgsAction(FunctionImpl function_impl)
01643 : function_impl_(function_impl) {}
01644
01645
01646
01647 template <typename Result, typename ArgumentTuple>
01648 Result Perform(const ArgumentTuple&) { return function_impl_(); }
01649
01650 private:
01651 FunctionImpl function_impl_;
01652
01653 GTEST_DISALLOW_ASSIGN_(InvokeWithoutArgsAction);
01654 };
01655
01656
01657 template <class Class, typename MethodPtr>
01658 class InvokeMethodWithoutArgsAction {
01659 public:
01660 InvokeMethodWithoutArgsAction(Class* obj_ptr, MethodPtr method_ptr)
01661 : obj_ptr_(obj_ptr), method_ptr_(method_ptr) {}
01662
01663 template <typename Result, typename ArgumentTuple>
01664 Result Perform(const ArgumentTuple&) const {
01665 return (obj_ptr_->*method_ptr_)();
01666 }
01667
01668 private:
01669 Class* const obj_ptr_;
01670 const MethodPtr method_ptr_;
01671
01672 GTEST_DISALLOW_ASSIGN_(InvokeMethodWithoutArgsAction);
01673 };
01674
01675
01676 template <typename A>
01677 class IgnoreResultAction {
01678 public:
01679 explicit IgnoreResultAction(const A& action) : action_(action) {}
01680
01681 template <typename F>
01682 operator Action<F>() const {
01683
01684
01685
01686
01687
01688
01689
01690
01691 typedef typename internal::Function<F>::Result Result;
01692
01693
01694 CompileAssertTypesEqual<void, Result>();
01695
01696 return Action<F>(new Impl<F>(action_));
01697 }
01698
01699 private:
01700 template <typename F>
01701 class Impl : public ActionInterface<F> {
01702 public:
01703 typedef typename internal::Function<F>::Result Result;
01704 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
01705
01706 explicit Impl(const A& action) : action_(action) {}
01707
01708 virtual void Perform(const ArgumentTuple& args) {
01709
01710 action_.Perform(args);
01711 }
01712
01713 private:
01714
01715
01716 typedef typename internal::Function<F>::MakeResultIgnoredValue
01717 OriginalFunction;
01718
01719 const Action<OriginalFunction> action_;
01720
01721 GTEST_DISALLOW_ASSIGN_(Impl);
01722 };
01723
01724 const A action_;
01725
01726 GTEST_DISALLOW_ASSIGN_(IgnoreResultAction);
01727 };
01728
01729
01730
01731
01732
01733
01734
01735
01736 template <typename T>
01737 class ReferenceWrapper {
01738 public:
01739
01740 explicit ReferenceWrapper(T& l_value) : pointer_(&l_value) {}
01741
01742
01743
01744 operator T&() const { return *pointer_; }
01745 private:
01746 T* pointer_;
01747 };
01748
01749
01750 template <typename T>
01751 void PrintTo(const ReferenceWrapper<T>& ref, ::std::ostream* os) {
01752 T& value = ref;
01753 UniversalPrinter<T&>::Print(value, os);
01754 }
01755
01756
01757
01758 template <typename Action1, typename Action2>
01759 class DoBothAction {
01760 public:
01761 DoBothAction(Action1 action1, Action2 action2)
01762 : action1_(action1), action2_(action2) {}
01763
01764
01765
01766 template <typename F>
01767 operator Action<F>() const {
01768 return Action<F>(new Impl<F>(action1_, action2_));
01769 }
01770
01771 private:
01772
01773 template <typename F>
01774 class Impl : public ActionInterface<F> {
01775 public:
01776 typedef typename Function<F>::Result Result;
01777 typedef typename Function<F>::ArgumentTuple ArgumentTuple;
01778 typedef typename Function<F>::MakeResultVoid VoidResult;
01779
01780 Impl(const Action<VoidResult>& action1, const Action<F>& action2)
01781 : action1_(action1), action2_(action2) {}
01782
01783 virtual Result Perform(const ArgumentTuple& args) {
01784 action1_.Perform(args);
01785 return action2_.Perform(args);
01786 }
01787
01788 private:
01789 const Action<VoidResult> action1_;
01790 const Action<F> action2_;
01791
01792 GTEST_DISALLOW_ASSIGN_(Impl);
01793 };
01794
01795 Action1 action1_;
01796 Action2 action2_;
01797
01798 GTEST_DISALLOW_ASSIGN_(DoBothAction);
01799 };
01800
01801 }
01802
01803
01804
01805
01806
01807
01808
01809
01810
01811
01812
01813
01814
01815
01816
01817
01818
01819
01820
01821
01822
01823
01824
01825
01826
01827
01828
01829
01830
01831
01832
01833 typedef internal::IgnoredValue Unused;
01834
01835
01836
01837
01838
01839 template <typename To>
01840 template <typename From>
01841 Action<To>::Action(const Action<From>& from)
01842 : impl_(new internal::ActionAdaptor<To, From>(from)) {}
01843
01844
01845
01846
01847 template <typename R>
01848 internal::ReturnAction<R> Return(R value) {
01849 return internal::ReturnAction<R>(value);
01850 }
01851
01852
01853 inline PolymorphicAction<internal::ReturnNullAction> ReturnNull() {
01854 return MakePolymorphicAction(internal::ReturnNullAction());
01855 }
01856
01857
01858 inline PolymorphicAction<internal::ReturnVoidAction> Return() {
01859 return MakePolymorphicAction(internal::ReturnVoidAction());
01860 }
01861
01862
01863 template <typename R>
01864 inline internal::ReturnRefAction<R> ReturnRef(R& x) {
01865 return internal::ReturnRefAction<R>(x);
01866 }
01867
01868
01869
01870
01871 template <typename R>
01872 inline internal::ReturnRefOfCopyAction<R> ReturnRefOfCopy(const R& x) {
01873 return internal::ReturnRefOfCopyAction<R>(x);
01874 }
01875
01876
01877 inline internal::DoDefaultAction DoDefault() {
01878 return internal::DoDefaultAction();
01879 }
01880
01881
01882
01883 template <size_t N, typename T>
01884 PolymorphicAction<
01885 internal::SetArgumentPointeeAction<
01886 N, T, internal::IsAProtocolMessage<T>::value> >
01887 SetArgPointee(const T& x) {
01888 return MakePolymorphicAction(internal::SetArgumentPointeeAction<
01889 N, T, internal::IsAProtocolMessage<T>::value>(x));
01890 }
01891
01892 #if !((GTEST_GCC_VER_ && GTEST_GCC_VER_ < 40000) || GTEST_OS_SYMBIAN)
01893
01894
01895
01896 template <size_t N>
01897 PolymorphicAction<
01898 internal::SetArgumentPointeeAction<N, const char*, false> >
01899 SetArgPointee(const char* p) {
01900 return MakePolymorphicAction(internal::SetArgumentPointeeAction<
01901 N, const char*, false>(p));
01902 }
01903
01904 template <size_t N>
01905 PolymorphicAction<
01906 internal::SetArgumentPointeeAction<N, const wchar_t*, false> >
01907 SetArgPointee(const wchar_t* p) {
01908 return MakePolymorphicAction(internal::SetArgumentPointeeAction<
01909 N, const wchar_t*, false>(p));
01910 }
01911 #endif
01912
01913
01914 template <size_t N, typename T>
01915 PolymorphicAction<
01916 internal::SetArgumentPointeeAction<
01917 N, T, internal::IsAProtocolMessage<T>::value> >
01918 SetArgumentPointee(const T& x) {
01919 return MakePolymorphicAction(internal::SetArgumentPointeeAction<
01920 N, T, internal::IsAProtocolMessage<T>::value>(x));
01921 }
01922
01923
01924 template <typename T1, typename T2>
01925 PolymorphicAction<internal::AssignAction<T1, T2> > Assign(T1* ptr, T2 val) {
01926 return MakePolymorphicAction(internal::AssignAction<T1, T2>(ptr, val));
01927 }
01928
01929 #if !GTEST_OS_WINDOWS_MOBILE
01930
01931
01932 template <typename T>
01933 PolymorphicAction<internal::SetErrnoAndReturnAction<T> >
01934 SetErrnoAndReturn(int errval, T result) {
01935 return MakePolymorphicAction(
01936 internal::SetErrnoAndReturnAction<T>(errval, result));
01937 }
01938
01939 #endif // !GTEST_OS_WINDOWS_MOBILE
01940
01941
01942
01943
01944 template <typename FunctionImpl>
01945 PolymorphicAction<internal::InvokeWithoutArgsAction<FunctionImpl> >
01946 InvokeWithoutArgs(FunctionImpl function_impl) {
01947 return MakePolymorphicAction(
01948 internal::InvokeWithoutArgsAction<FunctionImpl>(function_impl));
01949 }
01950
01951
01952
01953 template <class Class, typename MethodPtr>
01954 PolymorphicAction<internal::InvokeMethodWithoutArgsAction<Class, MethodPtr> >
01955 InvokeWithoutArgs(Class* obj_ptr, MethodPtr method_ptr) {
01956 return MakePolymorphicAction(
01957 internal::InvokeMethodWithoutArgsAction<Class, MethodPtr>(
01958 obj_ptr, method_ptr));
01959 }
01960
01961
01962
01963
01964 template <typename A>
01965 inline internal::IgnoreResultAction<A> IgnoreResult(const A& an_action) {
01966 return internal::IgnoreResultAction<A>(an_action);
01967 }
01968
01969
01970
01971
01972
01973
01974
01975
01976 template <typename T>
01977 inline internal::ReferenceWrapper<T> ByRef(T& l_value) {
01978 return internal::ReferenceWrapper<T>(l_value);
01979 }
01980
01981 }
01982
01983 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
01984
01985
01986
01987
01988
01989
01990
01991
01992
01993
01994
01995
01996
01997
01998
01999
02000
02001
02002
02003
02004
02005
02006
02007
02008
02009
02010
02011
02012
02013
02014
02015
02016
02017
02018
02019
02020
02021 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
02022 #define GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
02023
02024 #include <limits.h>
02025 #include <ostream>
02026
02027 namespace testing {
02028
02029
02030
02031
02032
02033
02034
02035
02036
02037
02038
02039
02040 class CardinalityInterface {
02041 public:
02042 virtual ~CardinalityInterface() {}
02043
02044
02045
02046 virtual int ConservativeLowerBound() const { return 0; }
02047 virtual int ConservativeUpperBound() const { return INT_MAX; }
02048
02049
02050 virtual bool IsSatisfiedByCallCount(int call_count) const = 0;
02051
02052
02053 virtual bool IsSaturatedByCallCount(int call_count) const = 0;
02054
02055
02056 virtual void DescribeTo(::std::ostream* os) const = 0;
02057 };
02058
02059
02060
02061
02062
02063
02064 class GTEST_API_ Cardinality {
02065 public:
02066
02067
02068 Cardinality() {}
02069
02070
02071 explicit Cardinality(const CardinalityInterface* impl) : impl_(impl) {}
02072
02073
02074
02075 int ConservativeLowerBound() const { return impl_->ConservativeLowerBound(); }
02076 int ConservativeUpperBound() const { return impl_->ConservativeUpperBound(); }
02077
02078
02079 bool IsSatisfiedByCallCount(int call_count) const {
02080 return impl_->IsSatisfiedByCallCount(call_count);
02081 }
02082
02083
02084 bool IsSaturatedByCallCount(int call_count) const {
02085 return impl_->IsSaturatedByCallCount(call_count);
02086 }
02087
02088
02089
02090 bool IsOverSaturatedByCallCount(int call_count) const {
02091 return impl_->IsSaturatedByCallCount(call_count) &&
02092 !impl_->IsSatisfiedByCallCount(call_count);
02093 }
02094
02095
02096 void DescribeTo(::std::ostream* os) const { impl_->DescribeTo(os); }
02097
02098
02099 static void DescribeActualCallCountTo(int actual_call_count,
02100 ::std::ostream* os);
02101
02102 private:
02103 internal::linked_ptr<const CardinalityInterface> impl_;
02104 };
02105
02106
02107 GTEST_API_ Cardinality AtLeast(int n);
02108
02109
02110 GTEST_API_ Cardinality AtMost(int n);
02111
02112
02113 GTEST_API_ Cardinality AnyNumber();
02114
02115
02116 GTEST_API_ Cardinality Between(int min, int max);
02117
02118
02119 GTEST_API_ Cardinality Exactly(int n);
02120
02121
02122 inline Cardinality MakeCardinality(const CardinalityInterface* c) {
02123 return Cardinality(c);
02124 }
02125
02126 }
02127
02128 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
02129
02130
02131
02132
02133
02134
02135
02136
02137
02138
02139
02140
02141
02142
02143
02144
02145
02146
02147
02148
02149
02150
02151
02152
02153
02154
02155
02156
02157
02158
02159
02160
02161
02162
02163
02164
02165
02166 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
02167 #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
02168
02169
02170 namespace testing {
02171 namespace internal {
02172
02173
02174
02175
02176 template <typename Result, typename ArgumentTuple>
02177 class InvokeHelper;
02178
02179 template <typename R>
02180 class InvokeHelper<R, ::std::tr1::tuple<> > {
02181 public:
02182 template <typename Function>
02183 static R Invoke(Function function, const ::std::tr1::tuple<>&) {
02184 return function();
02185 }
02186
02187 template <class Class, typename MethodPtr>
02188 static R InvokeMethod(Class* obj_ptr,
02189 MethodPtr method_ptr,
02190 const ::std::tr1::tuple<>&) {
02191 return (obj_ptr->*method_ptr)();
02192 }
02193 };
02194
02195 template <typename R, typename A1>
02196 class InvokeHelper<R, ::std::tr1::tuple<A1> > {
02197 public:
02198 template <typename Function>
02199 static R Invoke(Function function, const ::std::tr1::tuple<A1>& args) {
02200 using ::std::tr1::get;
02201 return function(get<0>(args));
02202 }
02203
02204 template <class Class, typename MethodPtr>
02205 static R InvokeMethod(Class* obj_ptr,
02206 MethodPtr method_ptr,
02207 const ::std::tr1::tuple<A1>& args) {
02208 using ::std::tr1::get;
02209 return (obj_ptr->*method_ptr)(get<0>(args));
02210 }
02211 };
02212
02213 template <typename R, typename A1, typename A2>
02214 class InvokeHelper<R, ::std::tr1::tuple<A1, A2> > {
02215 public:
02216 template <typename Function>
02217 static R Invoke(Function function, const ::std::tr1::tuple<A1, A2>& args) {
02218 using ::std::tr1::get;
02219 return function(get<0>(args), get<1>(args));
02220 }
02221
02222 template <class Class, typename MethodPtr>
02223 static R InvokeMethod(Class* obj_ptr,
02224 MethodPtr method_ptr,
02225 const ::std::tr1::tuple<A1, A2>& args) {
02226 using ::std::tr1::get;
02227 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args));
02228 }
02229 };
02230
02231 template <typename R, typename A1, typename A2, typename A3>
02232 class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3> > {
02233 public:
02234 template <typename Function>
02235 static R Invoke(Function function, const ::std::tr1::tuple<A1, A2,
02236 A3>& args) {
02237 using ::std::tr1::get;
02238 return function(get<0>(args), get<1>(args), get<2>(args));
02239 }
02240
02241 template <class Class, typename MethodPtr>
02242 static R InvokeMethod(Class* obj_ptr,
02243 MethodPtr method_ptr,
02244 const ::std::tr1::tuple<A1, A2, A3>& args) {
02245 using ::std::tr1::get;
02246 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args));
02247 }
02248 };
02249
02250 template <typename R, typename A1, typename A2, typename A3, typename A4>
02251 class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4> > {
02252 public:
02253 template <typename Function>
02254 static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3,
02255 A4>& args) {
02256 using ::std::tr1::get;
02257 return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args));
02258 }
02259
02260 template <class Class, typename MethodPtr>
02261 static R InvokeMethod(Class* obj_ptr,
02262 MethodPtr method_ptr,
02263 const ::std::tr1::tuple<A1, A2, A3, A4>& args) {
02264 using ::std::tr1::get;
02265 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
02266 get<3>(args));
02267 }
02268 };
02269
02270 template <typename R, typename A1, typename A2, typename A3, typename A4,
02271 typename A5>
02272 class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5> > {
02273 public:
02274 template <typename Function>
02275 static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
02276 A5>& args) {
02277 using ::std::tr1::get;
02278 return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
02279 get<4>(args));
02280 }
02281
02282 template <class Class, typename MethodPtr>
02283 static R InvokeMethod(Class* obj_ptr,
02284 MethodPtr method_ptr,
02285 const ::std::tr1::tuple<A1, A2, A3, A4, A5>& args) {
02286 using ::std::tr1::get;
02287 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
02288 get<3>(args), get<4>(args));
02289 }
02290 };
02291
02292 template <typename R, typename A1, typename A2, typename A3, typename A4,
02293 typename A5, typename A6>
02294 class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6> > {
02295 public:
02296 template <typename Function>
02297 static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
02298 A5, A6>& args) {
02299 using ::std::tr1::get;
02300 return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
02301 get<4>(args), get<5>(args));
02302 }
02303
02304 template <class Class, typename MethodPtr>
02305 static R InvokeMethod(Class* obj_ptr,
02306 MethodPtr method_ptr,
02307 const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6>& args) {
02308 using ::std::tr1::get;
02309 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
02310 get<3>(args), get<4>(args), get<5>(args));
02311 }
02312 };
02313
02314 template <typename R, typename A1, typename A2, typename A3, typename A4,
02315 typename A5, typename A6, typename A7>
02316 class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7> > {
02317 public:
02318 template <typename Function>
02319 static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
02320 A5, A6, A7>& args) {
02321 using ::std::tr1::get;
02322 return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
02323 get<4>(args), get<5>(args), get<6>(args));
02324 }
02325
02326 template <class Class, typename MethodPtr>
02327 static R InvokeMethod(Class* obj_ptr,
02328 MethodPtr method_ptr,
02329 const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6,
02330 A7>& args) {
02331 using ::std::tr1::get;
02332 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
02333 get<3>(args), get<4>(args), get<5>(args), get<6>(args));
02334 }
02335 };
02336
02337 template <typename R, typename A1, typename A2, typename A3, typename A4,
02338 typename A5, typename A6, typename A7, typename A8>
02339 class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {
02340 public:
02341 template <typename Function>
02342 static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
02343 A5, A6, A7, A8>& args) {
02344 using ::std::tr1::get;
02345 return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
02346 get<4>(args), get<5>(args), get<6>(args), get<7>(args));
02347 }
02348
02349 template <class Class, typename MethodPtr>
02350 static R InvokeMethod(Class* obj_ptr,
02351 MethodPtr method_ptr,
02352 const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7,
02353 A8>& args) {
02354 using ::std::tr1::get;
02355 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
02356 get<3>(args), get<4>(args), get<5>(args), get<6>(args), get<7>(args));
02357 }
02358 };
02359
02360 template <typename R, typename A1, typename A2, typename A3, typename A4,
02361 typename A5, typename A6, typename A7, typename A8, typename A9>
02362 class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > {
02363 public:
02364 template <typename Function>
02365 static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
02366 A5, A6, A7, A8, A9>& args) {
02367 using ::std::tr1::get;
02368 return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
02369 get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args));
02370 }
02371
02372 template <class Class, typename MethodPtr>
02373 static R InvokeMethod(Class* obj_ptr,
02374 MethodPtr method_ptr,
02375 const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8,
02376 A9>& args) {
02377 using ::std::tr1::get;
02378 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
02379 get<3>(args), get<4>(args), get<5>(args), get<6>(args), get<7>(args),
02380 get<8>(args));
02381 }
02382 };
02383
02384 template <typename R, typename A1, typename A2, typename A3, typename A4,
02385 typename A5, typename A6, typename A7, typename A8, typename A9,
02386 typename A10>
02387 class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
02388 A10> > {
02389 public:
02390 template <typename Function>
02391 static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
02392 A5, A6, A7, A8, A9, A10>& args) {
02393 using ::std::tr1::get;
02394 return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
02395 get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args),
02396 get<9>(args));
02397 }
02398
02399 template <class Class, typename MethodPtr>
02400 static R InvokeMethod(Class* obj_ptr,
02401 MethodPtr method_ptr,
02402 const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8,
02403 A9, A10>& args) {
02404 using ::std::tr1::get;
02405 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
02406 get<3>(args), get<4>(args), get<5>(args), get<6>(args), get<7>(args),
02407 get<8>(args), get<9>(args));
02408 }
02409 };
02410
02411
02412
02413
02414
02415
02416
02417
02418
02419
02420
02421 template <typename R>
02422 class CallableHelper {
02423 public:
02424
02425 template <typename Function>
02426 static R Call(Function function) { return function(); }
02427
02428
02429
02430
02431
02432
02433
02434
02435
02436
02437
02438
02439
02440
02441 template <typename Function, typename A1>
02442 static R Call(Function function, A1 a1) { return function(a1); }
02443
02444
02445 template <typename Function, typename A1, typename A2>
02446 static R Call(Function function, A1 a1, A2 a2) {
02447 return function(a1, a2);
02448 }
02449
02450
02451 template <typename Function, typename A1, typename A2, typename A3>
02452 static R Call(Function function, A1 a1, A2 a2, A3 a3) {
02453 return function(a1, a2, a3);
02454 }
02455
02456
02457 template <typename Function, typename A1, typename A2, typename A3,
02458 typename A4>
02459 static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4) {
02460 return function(a1, a2, a3, a4);
02461 }
02462
02463
02464 template <typename Function, typename A1, typename A2, typename A3,
02465 typename A4, typename A5>
02466 static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {
02467 return function(a1, a2, a3, a4, a5);
02468 }
02469
02470
02471 template <typename Function, typename A1, typename A2, typename A3,
02472 typename A4, typename A5, typename A6>
02473 static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) {
02474 return function(a1, a2, a3, a4, a5, a6);
02475 }
02476
02477
02478 template <typename Function, typename A1, typename A2, typename A3,
02479 typename A4, typename A5, typename A6, typename A7>
02480 static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
02481 A7 a7) {
02482 return function(a1, a2, a3, a4, a5, a6, a7);
02483 }
02484
02485
02486 template <typename Function, typename A1, typename A2, typename A3,
02487 typename A4, typename A5, typename A6, typename A7, typename A8>
02488 static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
02489 A7 a7, A8 a8) {
02490 return function(a1, a2, a3, a4, a5, a6, a7, a8);
02491 }
02492
02493
02494 template <typename Function, typename A1, typename A2, typename A3,
02495 typename A4, typename A5, typename A6, typename A7, typename A8,
02496 typename A9>
02497 static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
02498 A7 a7, A8 a8, A9 a9) {
02499 return function(a1, a2, a3, a4, a5, a6, a7, a8, a9);
02500 }
02501
02502
02503 template <typename Function, typename A1, typename A2, typename A3,
02504 typename A4, typename A5, typename A6, typename A7, typename A8,
02505 typename A9, typename A10>
02506 static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
02507 A7 a7, A8 a8, A9 a9, A10 a10) {
02508 return function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
02509 }
02510 };
02511
02512
02513
02514 #define GMOCK_FIELD_(Tuple, N) \
02515 typename ::std::tr1::tuple_element<N, Tuple>::type
02516
02517
02518
02519
02520
02521
02522
02523
02524
02525
02526
02527
02528
02529
02530
02531
02532
02533
02534
02535 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
02536 int k4, int k5, int k6, int k7, int k8, int k9, int k10>
02537 class SelectArgs {
02538 public:
02539 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
02540 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
02541 GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
02542 GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7),
02543 GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9),
02544 GMOCK_FIELD_(ArgumentTuple, k10));
02545 typedef typename Function<type>::ArgumentTuple SelectedArgs;
02546 static SelectedArgs Select(const ArgumentTuple& args) {
02547 using ::std::tr1::get;
02548 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
02549 get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
02550 get<k8>(args), get<k9>(args), get<k10>(args));
02551 }
02552 };
02553
02554 template <typename Result, typename ArgumentTuple>
02555 class SelectArgs<Result, ArgumentTuple,
02556 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
02557 public:
02558 typedef Result type();
02559 typedef typename Function<type>::ArgumentTuple SelectedArgs;
02560 static SelectedArgs Select(const ArgumentTuple& ) {
02561 using ::std::tr1::get;
02562 return SelectedArgs();
02563 }
02564 };
02565
02566 template <typename Result, typename ArgumentTuple, int k1>
02567 class SelectArgs<Result, ArgumentTuple,
02568 k1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
02569 public:
02570 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1));
02571 typedef typename Function<type>::ArgumentTuple SelectedArgs;
02572 static SelectedArgs Select(const ArgumentTuple& args) {
02573 using ::std::tr1::get;
02574 return SelectedArgs(get<k1>(args));
02575 }
02576 };
02577
02578 template <typename Result, typename ArgumentTuple, int k1, int k2>
02579 class SelectArgs<Result, ArgumentTuple,
02580 k1, k2, -1, -1, -1, -1, -1, -1, -1, -1> {
02581 public:
02582 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
02583 GMOCK_FIELD_(ArgumentTuple, k2));
02584 typedef typename Function<type>::ArgumentTuple SelectedArgs;
02585 static SelectedArgs Select(const ArgumentTuple& args) {
02586 using ::std::tr1::get;
02587 return SelectedArgs(get<k1>(args), get<k2>(args));
02588 }
02589 };
02590
02591 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3>
02592 class SelectArgs<Result, ArgumentTuple,
02593 k1, k2, k3, -1, -1, -1, -1, -1, -1, -1> {
02594 public:
02595 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
02596 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3));
02597 typedef typename Function<type>::ArgumentTuple SelectedArgs;
02598 static SelectedArgs Select(const ArgumentTuple& args) {
02599 using ::std::tr1::get;
02600 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args));
02601 }
02602 };
02603
02604 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
02605 int k4>
02606 class SelectArgs<Result, ArgumentTuple,
02607 k1, k2, k3, k4, -1, -1, -1, -1, -1, -1> {
02608 public:
02609 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
02610 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
02611 GMOCK_FIELD_(ArgumentTuple, k4));
02612 typedef typename Function<type>::ArgumentTuple SelectedArgs;
02613 static SelectedArgs Select(const ArgumentTuple& args) {
02614 using ::std::tr1::get;
02615 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
02616 get<k4>(args));
02617 }
02618 };
02619
02620 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
02621 int k4, int k5>
02622 class SelectArgs<Result, ArgumentTuple,
02623 k1, k2, k3, k4, k5, -1, -1, -1, -1, -1> {
02624 public:
02625 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
02626 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
02627 GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5));
02628 typedef typename Function<type>::ArgumentTuple SelectedArgs;
02629 static SelectedArgs Select(const ArgumentTuple& args) {
02630 using ::std::tr1::get;
02631 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
02632 get<k4>(args), get<k5>(args));
02633 }
02634 };
02635
02636 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
02637 int k4, int k5, int k6>
02638 class SelectArgs<Result, ArgumentTuple,
02639 k1, k2, k3, k4, k5, k6, -1, -1, -1, -1> {
02640 public:
02641 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
02642 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
02643 GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
02644 GMOCK_FIELD_(ArgumentTuple, k6));
02645 typedef typename Function<type>::ArgumentTuple SelectedArgs;
02646 static SelectedArgs Select(const ArgumentTuple& args) {
02647 using ::std::tr1::get;
02648 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
02649 get<k4>(args), get<k5>(args), get<k6>(args));
02650 }
02651 };
02652
02653 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
02654 int k4, int k5, int k6, int k7>
02655 class SelectArgs<Result, ArgumentTuple,
02656 k1, k2, k3, k4, k5, k6, k7, -1, -1, -1> {
02657 public:
02658 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
02659 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
02660 GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
02661 GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7));
02662 typedef typename Function<type>::ArgumentTuple SelectedArgs;
02663 static SelectedArgs Select(const ArgumentTuple& args) {
02664 using ::std::tr1::get;
02665 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
02666 get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args));
02667 }
02668 };
02669
02670 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
02671 int k4, int k5, int k6, int k7, int k8>
02672 class SelectArgs<Result, ArgumentTuple,
02673 k1, k2, k3, k4, k5, k6, k7, k8, -1, -1> {
02674 public:
02675 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
02676 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
02677 GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
02678 GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7),
02679 GMOCK_FIELD_(ArgumentTuple, k8));
02680 typedef typename Function<type>::ArgumentTuple SelectedArgs;
02681 static SelectedArgs Select(const ArgumentTuple& args) {
02682 using ::std::tr1::get;
02683 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
02684 get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
02685 get<k8>(args));
02686 }
02687 };
02688
02689 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
02690 int k4, int k5, int k6, int k7, int k8, int k9>
02691 class SelectArgs<Result, ArgumentTuple,
02692 k1, k2, k3, k4, k5, k6, k7, k8, k9, -1> {
02693 public:
02694 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
02695 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
02696 GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
02697 GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7),
02698 GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9));
02699 typedef typename Function<type>::ArgumentTuple SelectedArgs;
02700 static SelectedArgs Select(const ArgumentTuple& args) {
02701 using ::std::tr1::get;
02702 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
02703 get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
02704 get<k8>(args), get<k9>(args));
02705 }
02706 };
02707
02708 #undef GMOCK_FIELD_
02709
02710
02711 template <typename InnerAction, int k1 = -1, int k2 = -1, int k3 = -1,
02712 int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
02713 int k9 = -1, int k10 = -1>
02714 class WithArgsAction {
02715 public:
02716 explicit WithArgsAction(const InnerAction& action) : action_(action) {}
02717
02718 template <typename F>
02719 operator Action<F>() const { return MakeAction(new Impl<F>(action_)); }
02720
02721 private:
02722 template <typename F>
02723 class Impl : public ActionInterface<F> {
02724 public:
02725 typedef typename Function<F>::Result Result;
02726 typedef typename Function<F>::ArgumentTuple ArgumentTuple;
02727
02728 explicit Impl(const InnerAction& action) : action_(action) {}
02729
02730 virtual Result Perform(const ArgumentTuple& args) {
02731 return action_.Perform(SelectArgs<Result, ArgumentTuple, k1, k2, k3, k4,
02732 k5, k6, k7, k8, k9, k10>::Select(args));
02733 }
02734
02735 private:
02736 typedef typename SelectArgs<Result, ArgumentTuple,
02737 k1, k2, k3, k4, k5, k6, k7, k8, k9, k10>::type InnerFunctionType;
02738
02739 Action<InnerFunctionType> action_;
02740 };
02741
02742 const InnerAction action_;
02743
02744 GTEST_DISALLOW_ASSIGN_(WithArgsAction);
02745 };
02746
02747
02748
02749
02750
02751
02752
02753
02754
02755
02756
02757
02758
02759
02760
02761 struct ExcessiveArg {};
02762
02763
02764 template <typename Result, class Impl>
02765 class ActionHelper {
02766 public:
02767 static Result Perform(Impl* impl, const ::std::tr1::tuple<>& args) {
02768 using ::std::tr1::get;
02769 return impl->template gmock_PerformImpl<>(args, ExcessiveArg(),
02770 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
02771 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
02772 ExcessiveArg());
02773 }
02774
02775 template <typename A0>
02776 static Result Perform(Impl* impl, const ::std::tr1::tuple<A0>& args) {
02777 using ::std::tr1::get;
02778 return impl->template gmock_PerformImpl<A0>(args, get<0>(args),
02779 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
02780 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
02781 ExcessiveArg());
02782 }
02783
02784 template <typename A0, typename A1>
02785 static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1>& args) {
02786 using ::std::tr1::get;
02787 return impl->template gmock_PerformImpl<A0, A1>(args, get<0>(args),
02788 get<1>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
02789 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
02790 ExcessiveArg());
02791 }
02792
02793 template <typename A0, typename A1, typename A2>
02794 static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2>& args) {
02795 using ::std::tr1::get;
02796 return impl->template gmock_PerformImpl<A0, A1, A2>(args, get<0>(args),
02797 get<1>(args), get<2>(args), ExcessiveArg(), ExcessiveArg(),
02798 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
02799 ExcessiveArg());
02800 }
02801
02802 template <typename A0, typename A1, typename A2, typename A3>
02803 static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2,
02804 A3>& args) {
02805 using ::std::tr1::get;
02806 return impl->template gmock_PerformImpl<A0, A1, A2, A3>(args, get<0>(args),
02807 get<1>(args), get<2>(args), get<3>(args), ExcessiveArg(),
02808 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
02809 ExcessiveArg());
02810 }
02811
02812 template <typename A0, typename A1, typename A2, typename A3, typename A4>
02813 static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3,
02814 A4>& args) {
02815 using ::std::tr1::get;
02816 return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4>(args,
02817 get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),
02818 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
02819 ExcessiveArg());
02820 }
02821
02822 template <typename A0, typename A1, typename A2, typename A3, typename A4,
02823 typename A5>
02824 static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,
02825 A5>& args) {
02826 using ::std::tr1::get;
02827 return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5>(args,
02828 get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),
02829 get<5>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
02830 ExcessiveArg());
02831 }
02832
02833 template <typename A0, typename A1, typename A2, typename A3, typename A4,
02834 typename A5, typename A6>
02835 static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,
02836 A5, A6>& args) {
02837 using ::std::tr1::get;
02838 return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6>(args,
02839 get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),
02840 get<5>(args), get<6>(args), ExcessiveArg(), ExcessiveArg(),
02841 ExcessiveArg());
02842 }
02843
02844 template <typename A0, typename A1, typename A2, typename A3, typename A4,
02845 typename A5, typename A6, typename A7>
02846 static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,
02847 A5, A6, A7>& args) {
02848 using ::std::tr1::get;
02849 return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6,
02850 A7>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),
02851 get<4>(args), get<5>(args), get<6>(args), get<7>(args), ExcessiveArg(),
02852 ExcessiveArg());
02853 }
02854
02855 template <typename A0, typename A1, typename A2, typename A3, typename A4,
02856 typename A5, typename A6, typename A7, typename A8>
02857 static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,
02858 A5, A6, A7, A8>& args) {
02859 using ::std::tr1::get;
02860 return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, A7,
02861 A8>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),
02862 get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args),
02863 ExcessiveArg());
02864 }
02865
02866 template <typename A0, typename A1, typename A2, typename A3, typename A4,
02867 typename A5, typename A6, typename A7, typename A8, typename A9>
02868 static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,
02869 A5, A6, A7, A8, A9>& args) {
02870 using ::std::tr1::get;
02871 return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, A7, A8,
02872 A9>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),
02873 get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args),
02874 get<9>(args));
02875 }
02876 };
02877
02878 }
02879
02880
02881
02882
02883
02884
02885
02886
02887 template <int k1, typename InnerAction>
02888 inline internal::WithArgsAction<InnerAction, k1>
02889 WithArgs(const InnerAction& action) {
02890 return internal::WithArgsAction<InnerAction, k1>(action);
02891 }
02892
02893 template <int k1, int k2, typename InnerAction>
02894 inline internal::WithArgsAction<InnerAction, k1, k2>
02895 WithArgs(const InnerAction& action) {
02896 return internal::WithArgsAction<InnerAction, k1, k2>(action);
02897 }
02898
02899 template <int k1, int k2, int k3, typename InnerAction>
02900 inline internal::WithArgsAction<InnerAction, k1, k2, k3>
02901 WithArgs(const InnerAction& action) {
02902 return internal::WithArgsAction<InnerAction, k1, k2, k3>(action);
02903 }
02904
02905 template <int k1, int k2, int k3, int k4, typename InnerAction>
02906 inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4>
02907 WithArgs(const InnerAction& action) {
02908 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4>(action);
02909 }
02910
02911 template <int k1, int k2, int k3, int k4, int k5, typename InnerAction>
02912 inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5>
02913 WithArgs(const InnerAction& action) {
02914 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5>(action);
02915 }
02916
02917 template <int k1, int k2, int k3, int k4, int k5, int k6, typename InnerAction>
02918 inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6>
02919 WithArgs(const InnerAction& action) {
02920 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6>(action);
02921 }
02922
02923 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7,
02924 typename InnerAction>
02925 inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7>
02926 WithArgs(const InnerAction& action) {
02927 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6,
02928 k7>(action);
02929 }
02930
02931 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
02932 typename InnerAction>
02933 inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8>
02934 WithArgs(const InnerAction& action) {
02935 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7,
02936 k8>(action);
02937 }
02938
02939 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
02940 int k9, typename InnerAction>
02941 inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8, k9>
02942 WithArgs(const InnerAction& action) {
02943 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8,
02944 k9>(action);
02945 }
02946
02947 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
02948 int k9, int k10, typename InnerAction>
02949 inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8,
02950 k9, k10>
02951 WithArgs(const InnerAction& action) {
02952 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8,
02953 k9, k10>(action);
02954 }
02955
02956
02957
02958 template <typename Action1, typename Action2>
02959 inline internal::DoBothAction<Action1, Action2>
02960 DoAll(Action1 a1, Action2 a2) {
02961 return internal::DoBothAction<Action1, Action2>(a1, a2);
02962 }
02963
02964 template <typename Action1, typename Action2, typename Action3>
02965 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
02966 Action3> >
02967 DoAll(Action1 a1, Action2 a2, Action3 a3) {
02968 return DoAll(a1, DoAll(a2, a3));
02969 }
02970
02971 template <typename Action1, typename Action2, typename Action3,
02972 typename Action4>
02973 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
02974 internal::DoBothAction<Action3, Action4> > >
02975 DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4) {
02976 return DoAll(a1, DoAll(a2, a3, a4));
02977 }
02978
02979 template <typename Action1, typename Action2, typename Action3,
02980 typename Action4, typename Action5>
02981 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
02982 internal::DoBothAction<Action3, internal::DoBothAction<Action4,
02983 Action5> > > >
02984 DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5) {
02985 return DoAll(a1, DoAll(a2, a3, a4, a5));
02986 }
02987
02988 template <typename Action1, typename Action2, typename Action3,
02989 typename Action4, typename Action5, typename Action6>
02990 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
02991 internal::DoBothAction<Action3, internal::DoBothAction<Action4,
02992 internal::DoBothAction<Action5, Action6> > > > >
02993 DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6) {
02994 return DoAll(a1, DoAll(a2, a3, a4, a5, a6));
02995 }
02996
02997 template <typename Action1, typename Action2, typename Action3,
02998 typename Action4, typename Action5, typename Action6, typename Action7>
02999 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
03000 internal::DoBothAction<Action3, internal::DoBothAction<Action4,
03001 internal::DoBothAction<Action5, internal::DoBothAction<Action6,
03002 Action7> > > > > >
03003 DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
03004 Action7 a7) {
03005 return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7));
03006 }
03007
03008 template <typename Action1, typename Action2, typename Action3,
03009 typename Action4, typename Action5, typename Action6, typename Action7,
03010 typename Action8>
03011 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
03012 internal::DoBothAction<Action3, internal::DoBothAction<Action4,
03013 internal::DoBothAction<Action5, internal::DoBothAction<Action6,
03014 internal::DoBothAction<Action7, Action8> > > > > > >
03015 DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
03016 Action7 a7, Action8 a8) {
03017 return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8));
03018 }
03019
03020 template <typename Action1, typename Action2, typename Action3,
03021 typename Action4, typename Action5, typename Action6, typename Action7,
03022 typename Action8, typename Action9>
03023 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
03024 internal::DoBothAction<Action3, internal::DoBothAction<Action4,
03025 internal::DoBothAction<Action5, internal::DoBothAction<Action6,
03026 internal::DoBothAction<Action7, internal::DoBothAction<Action8,
03027 Action9> > > > > > > >
03028 DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
03029 Action7 a7, Action8 a8, Action9 a9) {
03030 return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8, a9));
03031 }
03032
03033 template <typename Action1, typename Action2, typename Action3,
03034 typename Action4, typename Action5, typename Action6, typename Action7,
03035 typename Action8, typename Action9, typename Action10>
03036 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
03037 internal::DoBothAction<Action3, internal::DoBothAction<Action4,
03038 internal::DoBothAction<Action5, internal::DoBothAction<Action6,
03039 internal::DoBothAction<Action7, internal::DoBothAction<Action8,
03040 internal::DoBothAction<Action9, Action10> > > > > > > > >
03041 DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
03042 Action7 a7, Action8 a8, Action9 a9, Action10 a10) {
03043 return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8, a9, a10));
03044 }
03045
03046 }
03047
03048
03049
03050
03051
03052
03053
03054
03055
03056
03057
03058
03059
03060
03061
03062
03063
03064
03065
03066
03067
03068
03069
03070
03071
03072
03073
03074
03075
03076
03077
03078
03079
03080
03081
03082
03083
03084
03085
03086
03087
03088
03089
03090
03091
03092
03093
03094
03095
03096
03097
03098
03099
03100
03101
03102
03103
03104
03105
03106
03107
03108
03109
03110
03111
03112
03113
03114
03115
03116
03117
03118
03119
03120
03121
03122
03123
03124
03125
03126
03127
03128
03129
03130
03131
03132
03133
03134
03135
03136
03137
03138
03139
03140
03141
03142
03143
03144
03145 #define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_\
03146 const args_type& args GTEST_ATTRIBUTE_UNUSED_, \
03147 arg0_type arg0 GTEST_ATTRIBUTE_UNUSED_, \
03148 arg1_type arg1 GTEST_ATTRIBUTE_UNUSED_, \
03149 arg2_type arg2 GTEST_ATTRIBUTE_UNUSED_, \
03150 arg3_type arg3 GTEST_ATTRIBUTE_UNUSED_, \
03151 arg4_type arg4 GTEST_ATTRIBUTE_UNUSED_, \
03152 arg5_type arg5 GTEST_ATTRIBUTE_UNUSED_, \
03153 arg6_type arg6 GTEST_ATTRIBUTE_UNUSED_, \
03154 arg7_type arg7 GTEST_ATTRIBUTE_UNUSED_, \
03155 arg8_type arg8 GTEST_ATTRIBUTE_UNUSED_, \
03156 arg9_type arg9 GTEST_ATTRIBUTE_UNUSED_
03157
03158
03159
03160
03161
03162
03163
03164
03165
03166
03167
03168
03169
03170
03171
03172
03173
03174
03175
03176
03177
03178
03179
03180
03181
03182
03183
03184
03185
03186
03187
03188
03189
03190
03191
03192
03193
03194
03195
03196
03197
03198
03199
03200
03201
03202
03203
03204
03205
03206
03207
03208
03209
03210
03211
03212
03213
03214
03215
03216
03217
03218
03219
03220
03221
03222
03223
03224
03225
03226
03227
03228
03229
03230
03231
03232
03233
03234
03235
03236
03237
03238
03239
03240 #define GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(kind0, name0) kind0 name0
03241 #define GMOCK_INTERNAL_DECL_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \
03242 name1) kind0 name0, kind1 name1
03243 #define GMOCK_INTERNAL_DECL_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
03244 kind2, name2) kind0 name0, kind1 name1, kind2 name2
03245 #define GMOCK_INTERNAL_DECL_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
03246 kind2, name2, kind3, name3) kind0 name0, kind1 name1, kind2 name2, \
03247 kind3 name3
03248 #define GMOCK_INTERNAL_DECL_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
03249 kind2, name2, kind3, name3, kind4, name4) kind0 name0, kind1 name1, \
03250 kind2 name2, kind3 name3, kind4 name4
03251 #define GMOCK_INTERNAL_DECL_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
03252 kind2, name2, kind3, name3, kind4, name4, kind5, name5) kind0 name0, \
03253 kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5
03254 #define GMOCK_INTERNAL_DECL_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
03255 kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
03256 name6) kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \
03257 kind5 name5, kind6 name6
03258 #define GMOCK_INTERNAL_DECL_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
03259 kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
03260 kind7, name7) kind0 name0, kind1 name1, kind2 name2, kind3 name3, \
03261 kind4 name4, kind5 name5, kind6 name6, kind7 name7
03262 #define GMOCK_INTERNAL_DECL_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
03263 kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
03264 kind7, name7, kind8, name8) kind0 name0, kind1 name1, kind2 name2, \
03265 kind3 name3, kind4 name4, kind5 name5, kind6 name6, kind7 name7, \
03266 kind8 name8
03267 #define GMOCK_INTERNAL_DECL_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \
03268 name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
03269 name6, kind7, name7, kind8, name8, kind9, name9) kind0 name0, \
03270 kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5, \
03271 kind6 name6, kind7 name7, kind8 name8, kind9 name9
03272
03273
03274 #define GMOCK_INTERNAL_LIST_HAS_1_TEMPLATE_PARAMS(kind0, name0) name0
03275 #define GMOCK_INTERNAL_LIST_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \
03276 name1) name0, name1
03277 #define GMOCK_INTERNAL_LIST_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
03278 kind2, name2) name0, name1, name2
03279 #define GMOCK_INTERNAL_LIST_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
03280 kind2, name2, kind3, name3) name0, name1, name2, name3
03281 #define GMOCK_INTERNAL_LIST_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
03282 kind2, name2, kind3, name3, kind4, name4) name0, name1, name2, name3, \
03283 name4
03284 #define GMOCK_INTERNAL_LIST_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
03285 kind2, name2, kind3, name3, kind4, name4, kind5, name5) name0, name1, \
03286 name2, name3, name4, name5
03287 #define GMOCK_INTERNAL_LIST_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
03288 kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
03289 name6) name0, name1, name2, name3, name4, name5, name6
03290 #define GMOCK_INTERNAL_LIST_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
03291 kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
03292 kind7, name7) name0, name1, name2, name3, name4, name5, name6, name7
03293 #define GMOCK_INTERNAL_LIST_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
03294 kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
03295 kind7, name7, kind8, name8) name0, name1, name2, name3, name4, name5, \
03296 name6, name7, name8
03297 #define GMOCK_INTERNAL_LIST_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \
03298 name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
03299 name6, kind7, name7, kind8, name8, kind9, name9) name0, name1, name2, \
03300 name3, name4, name5, name6, name7, name8, name9
03301
03302
03303 #define GMOCK_INTERNAL_DECL_TYPE_AND_0_VALUE_PARAMS()
03304 #define GMOCK_INTERNAL_DECL_TYPE_AND_1_VALUE_PARAMS(p0) , typename p0##_type
03305 #define GMOCK_INTERNAL_DECL_TYPE_AND_2_VALUE_PARAMS(p0, p1) , \
03306 typename p0##_type, typename p1##_type
03307 #define GMOCK_INTERNAL_DECL_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , \
03308 typename p0##_type, typename p1##_type, typename p2##_type
03309 #define GMOCK_INTERNAL_DECL_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \
03310 typename p0##_type, typename p1##_type, typename p2##_type, \
03311 typename p3##_type
03312 #define GMOCK_INTERNAL_DECL_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \
03313 typename p0##_type, typename p1##_type, typename p2##_type, \
03314 typename p3##_type, typename p4##_type
03315 #define GMOCK_INTERNAL_DECL_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \
03316 typename p0##_type, typename p1##_type, typename p2##_type, \
03317 typename p3##_type, typename p4##_type, typename p5##_type
03318 #define GMOCK_INTERNAL_DECL_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
03319 p6) , typename p0##_type, typename p1##_type, typename p2##_type, \
03320 typename p3##_type, typename p4##_type, typename p5##_type, \
03321 typename p6##_type
03322 #define GMOCK_INTERNAL_DECL_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
03323 p6, p7) , typename p0##_type, typename p1##_type, typename p2##_type, \
03324 typename p3##_type, typename p4##_type, typename p5##_type, \
03325 typename p6##_type, typename p7##_type
03326 #define GMOCK_INTERNAL_DECL_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
03327 p6, p7, p8) , typename p0##_type, typename p1##_type, typename p2##_type, \
03328 typename p3##_type, typename p4##_type, typename p5##_type, \
03329 typename p6##_type, typename p7##_type, typename p8##_type
03330 #define GMOCK_INTERNAL_DECL_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
03331 p6, p7, p8, p9) , typename p0##_type, typename p1##_type, \
03332 typename p2##_type, typename p3##_type, typename p4##_type, \
03333 typename p5##_type, typename p6##_type, typename p7##_type, \
03334 typename p8##_type, typename p9##_type
03335
03336
03337 #define GMOCK_INTERNAL_INIT_AND_0_VALUE_PARAMS()\
03338 ()
03339 #define GMOCK_INTERNAL_INIT_AND_1_VALUE_PARAMS(p0)\
03340 (p0##_type gmock_p0) : p0(gmock_p0)
03341 #define GMOCK_INTERNAL_INIT_AND_2_VALUE_PARAMS(p0, p1)\
03342 (p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), p1(gmock_p1)
03343 #define GMOCK_INTERNAL_INIT_AND_3_VALUE_PARAMS(p0, p1, p2)\
03344 (p0##_type gmock_p0, p1##_type gmock_p1, \
03345 p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2)
03346 #define GMOCK_INTERNAL_INIT_AND_4_VALUE_PARAMS(p0, p1, p2, p3)\
03347 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
03348 p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
03349 p3(gmock_p3)
03350 #define GMOCK_INTERNAL_INIT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)\
03351 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
03352 p3##_type gmock_p3, p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), \
03353 p2(gmock_p2), p3(gmock_p3), p4(gmock_p4)
03354 #define GMOCK_INTERNAL_INIT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)\
03355 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
03356 p3##_type gmock_p3, p4##_type gmock_p4, \
03357 p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
03358 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5)
03359 #define GMOCK_INTERNAL_INIT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)\
03360 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
03361 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
03362 p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
03363 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6)
03364 #define GMOCK_INTERNAL_INIT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)\
03365 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
03366 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
03367 p6##_type gmock_p6, p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), \
03368 p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
03369 p7(gmock_p7)
03370 #define GMOCK_INTERNAL_INIT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
03371 p7, p8)\
03372 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
03373 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
03374 p6##_type gmock_p6, p7##_type gmock_p7, \
03375 p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
03376 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
03377 p8(gmock_p8)
03378 #define GMOCK_INTERNAL_INIT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
03379 p7, p8, p9)\
03380 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
03381 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
03382 p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
03383 p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
03384 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
03385 p8(gmock_p8), p9(gmock_p9)
03386
03387
03388 #define GMOCK_INTERNAL_DEFN_AND_0_VALUE_PARAMS()
03389 #define GMOCK_INTERNAL_DEFN_AND_1_VALUE_PARAMS(p0) p0##_type p0;
03390 #define GMOCK_INTERNAL_DEFN_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0; \
03391 p1##_type p1;
03392 #define GMOCK_INTERNAL_DEFN_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0; \
03393 p1##_type p1; p2##_type p2;
03394 #define GMOCK_INTERNAL_DEFN_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0; \
03395 p1##_type p1; p2##_type p2; p3##_type p3;
03396 #define GMOCK_INTERNAL_DEFN_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \
03397 p4) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4;
03398 #define GMOCK_INTERNAL_DEFN_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \
03399 p5) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
03400 p5##_type p5;
03401 #define GMOCK_INTERNAL_DEFN_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
03402 p6) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
03403 p5##_type p5; p6##_type p6;
03404 #define GMOCK_INTERNAL_DEFN_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
03405 p7) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
03406 p5##_type p5; p6##_type p6; p7##_type p7;
03407 #define GMOCK_INTERNAL_DEFN_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
03408 p7, p8) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \
03409 p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8;
03410 #define GMOCK_INTERNAL_DEFN_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
03411 p7, p8, p9) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \
03412 p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8; \
03413 p9##_type p9;
03414
03415
03416 #define GMOCK_INTERNAL_LIST_AND_0_VALUE_PARAMS()
03417 #define GMOCK_INTERNAL_LIST_AND_1_VALUE_PARAMS(p0) p0
03418 #define GMOCK_INTERNAL_LIST_AND_2_VALUE_PARAMS(p0, p1) p0, p1
03419 #define GMOCK_INTERNAL_LIST_AND_3_VALUE_PARAMS(p0, p1, p2) p0, p1, p2
03420 #define GMOCK_INTERNAL_LIST_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0, p1, p2, p3
03421 #define GMOCK_INTERNAL_LIST_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) p0, p1, \
03422 p2, p3, p4
03423 #define GMOCK_INTERNAL_LIST_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) p0, \
03424 p1, p2, p3, p4, p5
03425 #define GMOCK_INTERNAL_LIST_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
03426 p6) p0, p1, p2, p3, p4, p5, p6
03427 #define GMOCK_INTERNAL_LIST_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
03428 p7) p0, p1, p2, p3, p4, p5, p6, p7
03429 #define GMOCK_INTERNAL_LIST_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
03430 p7, p8) p0, p1, p2, p3, p4, p5, p6, p7, p8
03431 #define GMOCK_INTERNAL_LIST_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
03432 p7, p8, p9) p0, p1, p2, p3, p4, p5, p6, p7, p8, p9
03433
03434
03435 #define GMOCK_INTERNAL_LIST_TYPE_AND_0_VALUE_PARAMS()
03436 #define GMOCK_INTERNAL_LIST_TYPE_AND_1_VALUE_PARAMS(p0) , p0##_type
03437 #define GMOCK_INTERNAL_LIST_TYPE_AND_2_VALUE_PARAMS(p0, p1) , p0##_type, \
03438 p1##_type
03439 #define GMOCK_INTERNAL_LIST_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , p0##_type, \
03440 p1##_type, p2##_type
03441 #define GMOCK_INTERNAL_LIST_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \
03442 p0##_type, p1##_type, p2##_type, p3##_type
03443 #define GMOCK_INTERNAL_LIST_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \
03444 p0##_type, p1##_type, p2##_type, p3##_type, p4##_type
03445 #define GMOCK_INTERNAL_LIST_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \
03446 p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type
03447 #define GMOCK_INTERNAL_LIST_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
03448 p6) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, \
03449 p6##_type
03450 #define GMOCK_INTERNAL_LIST_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
03451 p6, p7) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
03452 p5##_type, p6##_type, p7##_type
03453 #define GMOCK_INTERNAL_LIST_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
03454 p6, p7, p8) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
03455 p5##_type, p6##_type, p7##_type, p8##_type
03456 #define GMOCK_INTERNAL_LIST_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
03457 p6, p7, p8, p9) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
03458 p5##_type, p6##_type, p7##_type, p8##_type, p9##_type
03459
03460
03461 #define GMOCK_INTERNAL_DECL_AND_0_VALUE_PARAMS()
03462 #define GMOCK_INTERNAL_DECL_AND_1_VALUE_PARAMS(p0) p0##_type p0
03463 #define GMOCK_INTERNAL_DECL_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0, \
03464 p1##_type p1
03465 #define GMOCK_INTERNAL_DECL_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0, \
03466 p1##_type p1, p2##_type p2
03467 #define GMOCK_INTERNAL_DECL_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0, \
03468 p1##_type p1, p2##_type p2, p3##_type p3
03469 #define GMOCK_INTERNAL_DECL_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \
03470 p4) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4
03471 #define GMOCK_INTERNAL_DECL_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \
03472 p5) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
03473 p5##_type p5
03474 #define GMOCK_INTERNAL_DECL_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
03475 p6) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
03476 p5##_type p5, p6##_type p6
03477 #define GMOCK_INTERNAL_DECL_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
03478 p7) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
03479 p5##_type p5, p6##_type p6, p7##_type p7
03480 #define GMOCK_INTERNAL_DECL_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
03481 p7, p8) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
03482 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8
03483 #define GMOCK_INTERNAL_DECL_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
03484 p7, p8, p9) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
03485 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
03486 p9##_type p9
03487
03488
03489 #define GMOCK_INTERNAL_COUNT_AND_0_VALUE_PARAMS()
03490 #define GMOCK_INTERNAL_COUNT_AND_1_VALUE_PARAMS(p0) P
03491 #define GMOCK_INTERNAL_COUNT_AND_2_VALUE_PARAMS(p0, p1) P2
03492 #define GMOCK_INTERNAL_COUNT_AND_3_VALUE_PARAMS(p0, p1, p2) P3
03493 #define GMOCK_INTERNAL_COUNT_AND_4_VALUE_PARAMS(p0, p1, p2, p3) P4
03494 #define GMOCK_INTERNAL_COUNT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) P5
03495 #define GMOCK_INTERNAL_COUNT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) P6
03496 #define GMOCK_INTERNAL_COUNT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) P7
03497 #define GMOCK_INTERNAL_COUNT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
03498 p7) P8
03499 #define GMOCK_INTERNAL_COUNT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
03500 p7, p8) P9
03501 #define GMOCK_INTERNAL_COUNT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
03502 p7, p8, p9) P10
03503
03504
03505 #define GMOCK_ACTION_CLASS_(name, value_params)\
03506 GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params)
03507
03508 #define ACTION_TEMPLATE(name, template_params, value_params)\
03509 template <GMOCK_INTERNAL_DECL_##template_params\
03510 GMOCK_INTERNAL_DECL_TYPE_##value_params>\
03511 class GMOCK_ACTION_CLASS_(name, value_params) {\
03512 public:\
03513 GMOCK_ACTION_CLASS_(name, value_params)\
03514 GMOCK_INTERNAL_INIT_##value_params {}\
03515 template <typename F>\
03516 class gmock_Impl : public ::testing::ActionInterface<F> {\
03517 public:\
03518 typedef F function_type;\
03519 typedef typename ::testing::internal::Function<F>::Result return_type;\
03520 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
03521 args_type;\
03522 explicit gmock_Impl GMOCK_INTERNAL_INIT_##value_params {}\
03523 virtual return_type Perform(const args_type& args) {\
03524 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
03525 Perform(this, args);\
03526 }\
03527 template <typename arg0_type, typename arg1_type, typename arg2_type, \
03528 typename arg3_type, typename arg4_type, typename arg5_type, \
03529 typename arg6_type, typename arg7_type, typename arg8_type, \
03530 typename arg9_type>\
03531 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
03532 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
03533 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
03534 arg9_type arg9) const;\
03535 GMOCK_INTERNAL_DEFN_##value_params\
03536 private:\
03537 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
03538 };\
03539 template <typename F> operator ::testing::Action<F>() const {\
03540 return ::testing::Action<F>(\
03541 new gmock_Impl<F>(GMOCK_INTERNAL_LIST_##value_params));\
03542 }\
03543 GMOCK_INTERNAL_DEFN_##value_params\
03544 private:\
03545 GTEST_DISALLOW_ASSIGN_(GMOCK_ACTION_CLASS_(name, value_params));\
03546 };\
03547 template <GMOCK_INTERNAL_DECL_##template_params\
03548 GMOCK_INTERNAL_DECL_TYPE_##value_params>\
03549 inline GMOCK_ACTION_CLASS_(name, value_params)<\
03550 GMOCK_INTERNAL_LIST_##template_params\
03551 GMOCK_INTERNAL_LIST_TYPE_##value_params> name(\
03552 GMOCK_INTERNAL_DECL_##value_params) {\
03553 return GMOCK_ACTION_CLASS_(name, value_params)<\
03554 GMOCK_INTERNAL_LIST_##template_params\
03555 GMOCK_INTERNAL_LIST_TYPE_##value_params>(\
03556 GMOCK_INTERNAL_LIST_##value_params);\
03557 }\
03558 template <GMOCK_INTERNAL_DECL_##template_params\
03559 GMOCK_INTERNAL_DECL_TYPE_##value_params>\
03560 template <typename F>\
03561 template <typename arg0_type, typename arg1_type, typename arg2_type, \
03562 typename arg3_type, typename arg4_type, typename arg5_type, \
03563 typename arg6_type, typename arg7_type, typename arg8_type, \
03564 typename arg9_type>\
03565 typename ::testing::internal::Function<F>::Result\
03566 GMOCK_ACTION_CLASS_(name, value_params)<\
03567 GMOCK_INTERNAL_LIST_##template_params\
03568 GMOCK_INTERNAL_LIST_TYPE_##value_params>::gmock_Impl<F>::\
03569 gmock_PerformImpl(\
03570 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
03571
03572 #define ACTION(name)\
03573 class name##Action {\
03574 public:\
03575 name##Action() {}\
03576 template <typename F>\
03577 class gmock_Impl : public ::testing::ActionInterface<F> {\
03578 public:\
03579 typedef F function_type;\
03580 typedef typename ::testing::internal::Function<F>::Result return_type;\
03581 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
03582 args_type;\
03583 gmock_Impl() {}\
03584 virtual return_type Perform(const args_type& args) {\
03585 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
03586 Perform(this, args);\
03587 }\
03588 template <typename arg0_type, typename arg1_type, typename arg2_type, \
03589 typename arg3_type, typename arg4_type, typename arg5_type, \
03590 typename arg6_type, typename arg7_type, typename arg8_type, \
03591 typename arg9_type>\
03592 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
03593 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
03594 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
03595 arg9_type arg9) const;\
03596 private:\
03597 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
03598 };\
03599 template <typename F> operator ::testing::Action<F>() const {\
03600 return ::testing::Action<F>(new gmock_Impl<F>());\
03601 }\
03602 private:\
03603 GTEST_DISALLOW_ASSIGN_(name##Action);\
03604 };\
03605 inline name##Action name() {\
03606 return name##Action();\
03607 }\
03608 template <typename F>\
03609 template <typename arg0_type, typename arg1_type, typename arg2_type, \
03610 typename arg3_type, typename arg4_type, typename arg5_type, \
03611 typename arg6_type, typename arg7_type, typename arg8_type, \
03612 typename arg9_type>\
03613 typename ::testing::internal::Function<F>::Result\
03614 name##Action::gmock_Impl<F>::gmock_PerformImpl(\
03615 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
03616
03617 #define ACTION_P(name, p0)\
03618 template <typename p0##_type>\
03619 class name##ActionP {\
03620 public:\
03621 name##ActionP(p0##_type gmock_p0) : p0(gmock_p0) {}\
03622 template <typename F>\
03623 class gmock_Impl : public ::testing::ActionInterface<F> {\
03624 public:\
03625 typedef F function_type;\
03626 typedef typename ::testing::internal::Function<F>::Result return_type;\
03627 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
03628 args_type;\
03629 explicit gmock_Impl(p0##_type gmock_p0) : p0(gmock_p0) {}\
03630 virtual return_type Perform(const args_type& args) {\
03631 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
03632 Perform(this, args);\
03633 }\
03634 template <typename arg0_type, typename arg1_type, typename arg2_type, \
03635 typename arg3_type, typename arg4_type, typename arg5_type, \
03636 typename arg6_type, typename arg7_type, typename arg8_type, \
03637 typename arg9_type>\
03638 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
03639 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
03640 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
03641 arg9_type arg9) const;\
03642 p0##_type p0;\
03643 private:\
03644 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
03645 };\
03646 template <typename F> operator ::testing::Action<F>() const {\
03647 return ::testing::Action<F>(new gmock_Impl<F>(p0));\
03648 }\
03649 p0##_type p0;\
03650 private:\
03651 GTEST_DISALLOW_ASSIGN_(name##ActionP);\
03652 };\
03653 template <typename p0##_type>\
03654 inline name##ActionP<p0##_type> name(p0##_type p0) {\
03655 return name##ActionP<p0##_type>(p0);\
03656 }\
03657 template <typename p0##_type>\
03658 template <typename F>\
03659 template <typename arg0_type, typename arg1_type, typename arg2_type, \
03660 typename arg3_type, typename arg4_type, typename arg5_type, \
03661 typename arg6_type, typename arg7_type, typename arg8_type, \
03662 typename arg9_type>\
03663 typename ::testing::internal::Function<F>::Result\
03664 name##ActionP<p0##_type>::gmock_Impl<F>::gmock_PerformImpl(\
03665 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
03666
03667 #define ACTION_P2(name, p0, p1)\
03668 template <typename p0##_type, typename p1##_type>\
03669 class name##ActionP2 {\
03670 public:\
03671 name##ActionP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
03672 p1(gmock_p1) {}\
03673 template <typename F>\
03674 class gmock_Impl : public ::testing::ActionInterface<F> {\
03675 public:\
03676 typedef F function_type;\
03677 typedef typename ::testing::internal::Function<F>::Result return_type;\
03678 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
03679 args_type;\
03680 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
03681 p1(gmock_p1) {}\
03682 virtual return_type Perform(const args_type& args) {\
03683 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
03684 Perform(this, args);\
03685 }\
03686 template <typename arg0_type, typename arg1_type, typename arg2_type, \
03687 typename arg3_type, typename arg4_type, typename arg5_type, \
03688 typename arg6_type, typename arg7_type, typename arg8_type, \
03689 typename arg9_type>\
03690 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
03691 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
03692 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
03693 arg9_type arg9) const;\
03694 p0##_type p0;\
03695 p1##_type p1;\
03696 private:\
03697 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
03698 };\
03699 template <typename F> operator ::testing::Action<F>() const {\
03700 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1));\
03701 }\
03702 p0##_type p0;\
03703 p1##_type p1;\
03704 private:\
03705 GTEST_DISALLOW_ASSIGN_(name##ActionP2);\
03706 };\
03707 template <typename p0##_type, typename p1##_type>\
03708 inline name##ActionP2<p0##_type, p1##_type> name(p0##_type p0, \
03709 p1##_type p1) {\
03710 return name##ActionP2<p0##_type, p1##_type>(p0, p1);\
03711 }\
03712 template <typename p0##_type, typename p1##_type>\
03713 template <typename F>\
03714 template <typename arg0_type, typename arg1_type, typename arg2_type, \
03715 typename arg3_type, typename arg4_type, typename arg5_type, \
03716 typename arg6_type, typename arg7_type, typename arg8_type, \
03717 typename arg9_type>\
03718 typename ::testing::internal::Function<F>::Result\
03719 name##ActionP2<p0##_type, p1##_type>::gmock_Impl<F>::gmock_PerformImpl(\
03720 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
03721
03722 #define ACTION_P3(name, p0, p1, p2)\
03723 template <typename p0##_type, typename p1##_type, typename p2##_type>\
03724 class name##ActionP3 {\
03725 public:\
03726 name##ActionP3(p0##_type gmock_p0, p1##_type gmock_p1, \
03727 p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\
03728 template <typename F>\
03729 class gmock_Impl : public ::testing::ActionInterface<F> {\
03730 public:\
03731 typedef F function_type;\
03732 typedef typename ::testing::internal::Function<F>::Result return_type;\
03733 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
03734 args_type;\
03735 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, \
03736 p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\
03737 virtual return_type Perform(const args_type& args) {\
03738 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
03739 Perform(this, args);\
03740 }\
03741 template <typename arg0_type, typename arg1_type, typename arg2_type, \
03742 typename arg3_type, typename arg4_type, typename arg5_type, \
03743 typename arg6_type, typename arg7_type, typename arg8_type, \
03744 typename arg9_type>\
03745 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
03746 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
03747 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
03748 arg9_type arg9) const;\
03749 p0##_type p0;\
03750 p1##_type p1;\
03751 p2##_type p2;\
03752 private:\
03753 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
03754 };\
03755 template <typename F> operator ::testing::Action<F>() const {\
03756 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2));\
03757 }\
03758 p0##_type p0;\
03759 p1##_type p1;\
03760 p2##_type p2;\
03761 private:\
03762 GTEST_DISALLOW_ASSIGN_(name##ActionP3);\
03763 };\
03764 template <typename p0##_type, typename p1##_type, typename p2##_type>\
03765 inline name##ActionP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0, \
03766 p1##_type p1, p2##_type p2) {\
03767 return name##ActionP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\
03768 }\
03769 template <typename p0##_type, typename p1##_type, typename p2##_type>\
03770 template <typename F>\
03771 template <typename arg0_type, typename arg1_type, typename arg2_type, \
03772 typename arg3_type, typename arg4_type, typename arg5_type, \
03773 typename arg6_type, typename arg7_type, typename arg8_type, \
03774 typename arg9_type>\
03775 typename ::testing::internal::Function<F>::Result\
03776 name##ActionP3<p0##_type, p1##_type, \
03777 p2##_type>::gmock_Impl<F>::gmock_PerformImpl(\
03778 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
03779
03780 #define ACTION_P4(name, p0, p1, p2, p3)\
03781 template <typename p0##_type, typename p1##_type, typename p2##_type, \
03782 typename p3##_type>\
03783 class name##ActionP4 {\
03784 public:\
03785 name##ActionP4(p0##_type gmock_p0, p1##_type gmock_p1, \
03786 p2##_type gmock_p2, p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), \
03787 p2(gmock_p2), p3(gmock_p3) {}\
03788 template <typename F>\
03789 class gmock_Impl : public ::testing::ActionInterface<F> {\
03790 public:\
03791 typedef F function_type;\
03792 typedef typename ::testing::internal::Function<F>::Result return_type;\
03793 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
03794 args_type;\
03795 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
03796 p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
03797 p3(gmock_p3) {}\
03798 virtual return_type Perform(const args_type& args) {\
03799 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
03800 Perform(this, args);\
03801 }\
03802 template <typename arg0_type, typename arg1_type, typename arg2_type, \
03803 typename arg3_type, typename arg4_type, typename arg5_type, \
03804 typename arg6_type, typename arg7_type, typename arg8_type, \
03805 typename arg9_type>\
03806 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
03807 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
03808 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
03809 arg9_type arg9) const;\
03810 p0##_type p0;\
03811 p1##_type p1;\
03812 p2##_type p2;\
03813 p3##_type p3;\
03814 private:\
03815 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
03816 };\
03817 template <typename F> operator ::testing::Action<F>() const {\
03818 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3));\
03819 }\
03820 p0##_type p0;\
03821 p1##_type p1;\
03822 p2##_type p2;\
03823 p3##_type p3;\
03824 private:\
03825 GTEST_DISALLOW_ASSIGN_(name##ActionP4);\
03826 };\
03827 template <typename p0##_type, typename p1##_type, typename p2##_type, \
03828 typename p3##_type>\
03829 inline name##ActionP4<p0##_type, p1##_type, p2##_type, \
03830 p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
03831 p3##_type p3) {\
03832 return name##ActionP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, p1, \
03833 p2, p3);\
03834 }\
03835 template <typename p0##_type, typename p1##_type, typename p2##_type, \
03836 typename p3##_type>\
03837 template <typename F>\
03838 template <typename arg0_type, typename arg1_type, typename arg2_type, \
03839 typename arg3_type, typename arg4_type, typename arg5_type, \
03840 typename arg6_type, typename arg7_type, typename arg8_type, \
03841 typename arg9_type>\
03842 typename ::testing::internal::Function<F>::Result\
03843 name##ActionP4<p0##_type, p1##_type, p2##_type, \
03844 p3##_type>::gmock_Impl<F>::gmock_PerformImpl(\
03845 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
03846
03847 #define ACTION_P5(name, p0, p1, p2, p3, p4)\
03848 template <typename p0##_type, typename p1##_type, typename p2##_type, \
03849 typename p3##_type, typename p4##_type>\
03850 class name##ActionP5 {\
03851 public:\
03852 name##ActionP5(p0##_type gmock_p0, p1##_type gmock_p1, \
03853 p2##_type gmock_p2, p3##_type gmock_p3, \
03854 p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
03855 p3(gmock_p3), p4(gmock_p4) {}\
03856 template <typename F>\
03857 class gmock_Impl : public ::testing::ActionInterface<F> {\
03858 public:\
03859 typedef F function_type;\
03860 typedef typename ::testing::internal::Function<F>::Result return_type;\
03861 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
03862 args_type;\
03863 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
03864 p3##_type gmock_p3, p4##_type gmock_p4) : p0(gmock_p0), \
03865 p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), p4(gmock_p4) {}\
03866 virtual return_type Perform(const args_type& args) {\
03867 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
03868 Perform(this, args);\
03869 }\
03870 template <typename arg0_type, typename arg1_type, typename arg2_type, \
03871 typename arg3_type, typename arg4_type, typename arg5_type, \
03872 typename arg6_type, typename arg7_type, typename arg8_type, \
03873 typename arg9_type>\
03874 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
03875 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
03876 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
03877 arg9_type arg9) const;\
03878 p0##_type p0;\
03879 p1##_type p1;\
03880 p2##_type p2;\
03881 p3##_type p3;\
03882 p4##_type p4;\
03883 private:\
03884 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
03885 };\
03886 template <typename F> operator ::testing::Action<F>() const {\
03887 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4));\
03888 }\
03889 p0##_type p0;\
03890 p1##_type p1;\
03891 p2##_type p2;\
03892 p3##_type p3;\
03893 p4##_type p4;\
03894 private:\
03895 GTEST_DISALLOW_ASSIGN_(name##ActionP5);\
03896 };\
03897 template <typename p0##_type, typename p1##_type, typename p2##_type, \
03898 typename p3##_type, typename p4##_type>\
03899 inline name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \
03900 p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
03901 p4##_type p4) {\
03902 return name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \
03903 p4##_type>(p0, p1, p2, p3, p4);\
03904 }\
03905 template <typename p0##_type, typename p1##_type, typename p2##_type, \
03906 typename p3##_type, typename p4##_type>\
03907 template <typename F>\
03908 template <typename arg0_type, typename arg1_type, typename arg2_type, \
03909 typename arg3_type, typename arg4_type, typename arg5_type, \
03910 typename arg6_type, typename arg7_type, typename arg8_type, \
03911 typename arg9_type>\
03912 typename ::testing::internal::Function<F>::Result\
03913 name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \
03914 p4##_type>::gmock_Impl<F>::gmock_PerformImpl(\
03915 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
03916
03917 #define ACTION_P6(name, p0, p1, p2, p3, p4, p5)\
03918 template <typename p0##_type, typename p1##_type, typename p2##_type, \
03919 typename p3##_type, typename p4##_type, typename p5##_type>\
03920 class name##ActionP6 {\
03921 public:\
03922 name##ActionP6(p0##_type gmock_p0, p1##_type gmock_p1, \
03923 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
03924 p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
03925 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {}\
03926 template <typename F>\
03927 class gmock_Impl : public ::testing::ActionInterface<F> {\
03928 public:\
03929 typedef F function_type;\
03930 typedef typename ::testing::internal::Function<F>::Result return_type;\
03931 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
03932 args_type;\
03933 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
03934 p3##_type gmock_p3, p4##_type gmock_p4, \
03935 p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
03936 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {}\
03937 virtual return_type Perform(const args_type& args) {\
03938 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
03939 Perform(this, args);\
03940 }\
03941 template <typename arg0_type, typename arg1_type, typename arg2_type, \
03942 typename arg3_type, typename arg4_type, typename arg5_type, \
03943 typename arg6_type, typename arg7_type, typename arg8_type, \
03944 typename arg9_type>\
03945 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
03946 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
03947 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
03948 arg9_type arg9) const;\
03949 p0##_type p0;\
03950 p1##_type p1;\
03951 p2##_type p2;\
03952 p3##_type p3;\
03953 p4##_type p4;\
03954 p5##_type p5;\
03955 private:\
03956 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
03957 };\
03958 template <typename F> operator ::testing::Action<F>() const {\
03959 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5));\
03960 }\
03961 p0##_type p0;\
03962 p1##_type p1;\
03963 p2##_type p2;\
03964 p3##_type p3;\
03965 p4##_type p4;\
03966 p5##_type p5;\
03967 private:\
03968 GTEST_DISALLOW_ASSIGN_(name##ActionP6);\
03969 };\
03970 template <typename p0##_type, typename p1##_type, typename p2##_type, \
03971 typename p3##_type, typename p4##_type, typename p5##_type>\
03972 inline name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, \
03973 p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
03974 p3##_type p3, p4##_type p4, p5##_type p5) {\
03975 return name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, \
03976 p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\
03977 }\
03978 template <typename p0##_type, typename p1##_type, typename p2##_type, \
03979 typename p3##_type, typename p4##_type, typename p5##_type>\
03980 template <typename F>\
03981 template <typename arg0_type, typename arg1_type, typename arg2_type, \
03982 typename arg3_type, typename arg4_type, typename arg5_type, \
03983 typename arg6_type, typename arg7_type, typename arg8_type, \
03984 typename arg9_type>\
03985 typename ::testing::internal::Function<F>::Result\
03986 name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
03987 p5##_type>::gmock_Impl<F>::gmock_PerformImpl(\
03988 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
03989
03990 #define ACTION_P7(name, p0, p1, p2, p3, p4, p5, p6)\
03991 template <typename p0##_type, typename p1##_type, typename p2##_type, \
03992 typename p3##_type, typename p4##_type, typename p5##_type, \
03993 typename p6##_type>\
03994 class name##ActionP7 {\
03995 public:\
03996 name##ActionP7(p0##_type gmock_p0, p1##_type gmock_p1, \
03997 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
03998 p5##_type gmock_p5, p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), \
03999 p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), \
04000 p6(gmock_p6) {}\
04001 template <typename F>\
04002 class gmock_Impl : public ::testing::ActionInterface<F> {\
04003 public:\
04004 typedef F function_type;\
04005 typedef typename ::testing::internal::Function<F>::Result return_type;\
04006 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
04007 args_type;\
04008 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
04009 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
04010 p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
04011 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6) {}\
04012 virtual return_type Perform(const args_type& args) {\
04013 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
04014 Perform(this, args);\
04015 }\
04016 template <typename arg0_type, typename arg1_type, typename arg2_type, \
04017 typename arg3_type, typename arg4_type, typename arg5_type, \
04018 typename arg6_type, typename arg7_type, typename arg8_type, \
04019 typename arg9_type>\
04020 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
04021 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
04022 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
04023 arg9_type arg9) const;\
04024 p0##_type p0;\
04025 p1##_type p1;\
04026 p2##_type p2;\
04027 p3##_type p3;\
04028 p4##_type p4;\
04029 p5##_type p5;\
04030 p6##_type p6;\
04031 private:\
04032 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
04033 };\
04034 template <typename F> operator ::testing::Action<F>() const {\
04035 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
04036 p6));\
04037 }\
04038 p0##_type p0;\
04039 p1##_type p1;\
04040 p2##_type p2;\
04041 p3##_type p3;\
04042 p4##_type p4;\
04043 p5##_type p5;\
04044 p6##_type p6;\
04045 private:\
04046 GTEST_DISALLOW_ASSIGN_(name##ActionP7);\
04047 };\
04048 template <typename p0##_type, typename p1##_type, typename p2##_type, \
04049 typename p3##_type, typename p4##_type, typename p5##_type, \
04050 typename p6##_type>\
04051 inline name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, \
04052 p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \
04053 p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
04054 p6##_type p6) {\
04055 return name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, \
04056 p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\
04057 }\
04058 template <typename p0##_type, typename p1##_type, typename p2##_type, \
04059 typename p3##_type, typename p4##_type, typename p5##_type, \
04060 typename p6##_type>\
04061 template <typename F>\
04062 template <typename arg0_type, typename arg1_type, typename arg2_type, \
04063 typename arg3_type, typename arg4_type, typename arg5_type, \
04064 typename arg6_type, typename arg7_type, typename arg8_type, \
04065 typename arg9_type>\
04066 typename ::testing::internal::Function<F>::Result\
04067 name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
04068 p5##_type, p6##_type>::gmock_Impl<F>::gmock_PerformImpl(\
04069 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
04070
04071 #define ACTION_P8(name, p0, p1, p2, p3, p4, p5, p6, p7)\
04072 template <typename p0##_type, typename p1##_type, typename p2##_type, \
04073 typename p3##_type, typename p4##_type, typename p5##_type, \
04074 typename p6##_type, typename p7##_type>\
04075 class name##ActionP8 {\
04076 public:\
04077 name##ActionP8(p0##_type gmock_p0, p1##_type gmock_p1, \
04078 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
04079 p5##_type gmock_p5, p6##_type gmock_p6, \
04080 p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
04081 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
04082 p7(gmock_p7) {}\
04083 template <typename F>\
04084 class gmock_Impl : public ::testing::ActionInterface<F> {\
04085 public:\
04086 typedef F function_type;\
04087 typedef typename ::testing::internal::Function<F>::Result return_type;\
04088 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
04089 args_type;\
04090 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
04091 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
04092 p6##_type gmock_p6, p7##_type gmock_p7) : p0(gmock_p0), \
04093 p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), \
04094 p5(gmock_p5), p6(gmock_p6), p7(gmock_p7) {}\
04095 virtual return_type Perform(const args_type& args) {\
04096 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
04097 Perform(this, args);\
04098 }\
04099 template <typename arg0_type, typename arg1_type, typename arg2_type, \
04100 typename arg3_type, typename arg4_type, typename arg5_type, \
04101 typename arg6_type, typename arg7_type, typename arg8_type, \
04102 typename arg9_type>\
04103 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
04104 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
04105 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
04106 arg9_type arg9) const;\
04107 p0##_type p0;\
04108 p1##_type p1;\
04109 p2##_type p2;\
04110 p3##_type p3;\
04111 p4##_type p4;\
04112 p5##_type p5;\
04113 p6##_type p6;\
04114 p7##_type p7;\
04115 private:\
04116 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
04117 };\
04118 template <typename F> operator ::testing::Action<F>() const {\
04119 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
04120 p6, p7));\
04121 }\
04122 p0##_type p0;\
04123 p1##_type p1;\
04124 p2##_type p2;\
04125 p3##_type p3;\
04126 p4##_type p4;\
04127 p5##_type p5;\
04128 p6##_type p6;\
04129 p7##_type p7;\
04130 private:\
04131 GTEST_DISALLOW_ASSIGN_(name##ActionP8);\
04132 };\
04133 template <typename p0##_type, typename p1##_type, typename p2##_type, \
04134 typename p3##_type, typename p4##_type, typename p5##_type, \
04135 typename p6##_type, typename p7##_type>\
04136 inline name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, \
04137 p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \
04138 p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
04139 p6##_type p6, p7##_type p7) {\
04140 return name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, \
04141 p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5, \
04142 p6, p7);\
04143 }\
04144 template <typename p0##_type, typename p1##_type, typename p2##_type, \
04145 typename p3##_type, typename p4##_type, typename p5##_type, \
04146 typename p6##_type, typename p7##_type>\
04147 template <typename F>\
04148 template <typename arg0_type, typename arg1_type, typename arg2_type, \
04149 typename arg3_type, typename arg4_type, typename arg5_type, \
04150 typename arg6_type, typename arg7_type, typename arg8_type, \
04151 typename arg9_type>\
04152 typename ::testing::internal::Function<F>::Result\
04153 name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
04154 p5##_type, p6##_type, \
04155 p7##_type>::gmock_Impl<F>::gmock_PerformImpl(\
04156 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
04157
04158 #define ACTION_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8)\
04159 template <typename p0##_type, typename p1##_type, typename p2##_type, \
04160 typename p3##_type, typename p4##_type, typename p5##_type, \
04161 typename p6##_type, typename p7##_type, typename p8##_type>\
04162 class name##ActionP9 {\
04163 public:\
04164 name##ActionP9(p0##_type gmock_p0, p1##_type gmock_p1, \
04165 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
04166 p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
04167 p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
04168 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
04169 p8(gmock_p8) {}\
04170 template <typename F>\
04171 class gmock_Impl : public ::testing::ActionInterface<F> {\
04172 public:\
04173 typedef F function_type;\
04174 typedef typename ::testing::internal::Function<F>::Result return_type;\
04175 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
04176 args_type;\
04177 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
04178 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
04179 p6##_type gmock_p6, p7##_type gmock_p7, \
04180 p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
04181 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
04182 p7(gmock_p7), p8(gmock_p8) {}\
04183 virtual return_type Perform(const args_type& args) {\
04184 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
04185 Perform(this, args);\
04186 }\
04187 template <typename arg0_type, typename arg1_type, typename arg2_type, \
04188 typename arg3_type, typename arg4_type, typename arg5_type, \
04189 typename arg6_type, typename arg7_type, typename arg8_type, \
04190 typename arg9_type>\
04191 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
04192 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
04193 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
04194 arg9_type arg9) const;\
04195 p0##_type p0;\
04196 p1##_type p1;\
04197 p2##_type p2;\
04198 p3##_type p3;\
04199 p4##_type p4;\
04200 p5##_type p5;\
04201 p6##_type p6;\
04202 p7##_type p7;\
04203 p8##_type p8;\
04204 private:\
04205 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
04206 };\
04207 template <typename F> operator ::testing::Action<F>() const {\
04208 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
04209 p6, p7, p8));\
04210 }\
04211 p0##_type p0;\
04212 p1##_type p1;\
04213 p2##_type p2;\
04214 p3##_type p3;\
04215 p4##_type p4;\
04216 p5##_type p5;\
04217 p6##_type p6;\
04218 p7##_type p7;\
04219 p8##_type p8;\
04220 private:\
04221 GTEST_DISALLOW_ASSIGN_(name##ActionP9);\
04222 };\
04223 template <typename p0##_type, typename p1##_type, typename p2##_type, \
04224 typename p3##_type, typename p4##_type, typename p5##_type, \
04225 typename p6##_type, typename p7##_type, typename p8##_type>\
04226 inline name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, \
04227 p4##_type, p5##_type, p6##_type, p7##_type, \
04228 p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
04229 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \
04230 p8##_type p8) {\
04231 return name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, \
04232 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type>(p0, p1, p2, \
04233 p3, p4, p5, p6, p7, p8);\
04234 }\
04235 template <typename p0##_type, typename p1##_type, typename p2##_type, \
04236 typename p3##_type, typename p4##_type, typename p5##_type, \
04237 typename p6##_type, typename p7##_type, typename p8##_type>\
04238 template <typename F>\
04239 template <typename arg0_type, typename arg1_type, typename arg2_type, \
04240 typename arg3_type, typename arg4_type, typename arg5_type, \
04241 typename arg6_type, typename arg7_type, typename arg8_type, \
04242 typename arg9_type>\
04243 typename ::testing::internal::Function<F>::Result\
04244 name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
04245 p5##_type, p6##_type, p7##_type, \
04246 p8##_type>::gmock_Impl<F>::gmock_PerformImpl(\
04247 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
04248
04249 #define ACTION_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)\
04250 template <typename p0##_type, typename p1##_type, typename p2##_type, \
04251 typename p3##_type, typename p4##_type, typename p5##_type, \
04252 typename p6##_type, typename p7##_type, typename p8##_type, \
04253 typename p9##_type>\
04254 class name##ActionP10 {\
04255 public:\
04256 name##ActionP10(p0##_type gmock_p0, p1##_type gmock_p1, \
04257 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
04258 p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
04259 p8##_type gmock_p8, p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), \
04260 p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
04261 p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {}\
04262 template <typename F>\
04263 class gmock_Impl : public ::testing::ActionInterface<F> {\
04264 public:\
04265 typedef F function_type;\
04266 typedef typename ::testing::internal::Function<F>::Result return_type;\
04267 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
04268 args_type;\
04269 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
04270 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
04271 p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
04272 p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
04273 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
04274 p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {}\
04275 virtual return_type Perform(const args_type& args) {\
04276 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
04277 Perform(this, args);\
04278 }\
04279 template <typename arg0_type, typename arg1_type, typename arg2_type, \
04280 typename arg3_type, typename arg4_type, typename arg5_type, \
04281 typename arg6_type, typename arg7_type, typename arg8_type, \
04282 typename arg9_type>\
04283 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
04284 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
04285 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
04286 arg9_type arg9) const;\
04287 p0##_type p0;\
04288 p1##_type p1;\
04289 p2##_type p2;\
04290 p3##_type p3;\
04291 p4##_type p4;\
04292 p5##_type p5;\
04293 p6##_type p6;\
04294 p7##_type p7;\
04295 p8##_type p8;\
04296 p9##_type p9;\
04297 private:\
04298 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
04299 };\
04300 template <typename F> operator ::testing::Action<F>() const {\
04301 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
04302 p6, p7, p8, p9));\
04303 }\
04304 p0##_type p0;\
04305 p1##_type p1;\
04306 p2##_type p2;\
04307 p3##_type p3;\
04308 p4##_type p4;\
04309 p5##_type p5;\
04310 p6##_type p6;\
04311 p7##_type p7;\
04312 p8##_type p8;\
04313 p9##_type p9;\
04314 private:\
04315 GTEST_DISALLOW_ASSIGN_(name##ActionP10);\
04316 };\
04317 template <typename p0##_type, typename p1##_type, typename p2##_type, \
04318 typename p3##_type, typename p4##_type, typename p5##_type, \
04319 typename p6##_type, typename p7##_type, typename p8##_type, \
04320 typename p9##_type>\
04321 inline name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, \
04322 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
04323 p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
04324 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
04325 p9##_type p9) {\
04326 return name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, \
04327 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>(p0, \
04328 p1, p2, p3, p4, p5, p6, p7, p8, p9);\
04329 }\
04330 template <typename p0##_type, typename p1##_type, typename p2##_type, \
04331 typename p3##_type, typename p4##_type, typename p5##_type, \
04332 typename p6##_type, typename p7##_type, typename p8##_type, \
04333 typename p9##_type>\
04334 template <typename F>\
04335 template <typename arg0_type, typename arg1_type, typename arg2_type, \
04336 typename arg3_type, typename arg4_type, typename arg5_type, \
04337 typename arg6_type, typename arg7_type, typename arg8_type, \
04338 typename arg9_type>\
04339 typename ::testing::internal::Function<F>::Result\
04340 name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
04341 p5##_type, p6##_type, p7##_type, p8##_type, \
04342 p9##_type>::gmock_Impl<F>::gmock_PerformImpl(\
04343 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
04344
04345 namespace testing {
04346
04347
04348
04349
04350
04351
04352 #ifdef _MSC_VER
04353 # pragma warning(push)
04354 # pragma warning(disable:4100)
04355 #endif
04356
04357
04358
04359
04360
04361
04362
04363
04364
04365
04366
04367
04368
04369
04370
04371
04372
04373
04374
04375
04376
04377
04378
04379
04380
04381
04382
04383
04384
04385
04386
04387 ACTION_TEMPLATE(InvokeArgument,
04388 HAS_1_TEMPLATE_PARAMS(int, k),
04389 AND_0_VALUE_PARAMS()) {
04390 return internal::CallableHelper<return_type>::Call(
04391 ::std::tr1::get<k>(args));
04392 }
04393
04394 ACTION_TEMPLATE(InvokeArgument,
04395 HAS_1_TEMPLATE_PARAMS(int, k),
04396 AND_1_VALUE_PARAMS(p0)) {
04397 return internal::CallableHelper<return_type>::Call(
04398 ::std::tr1::get<k>(args), p0);
04399 }
04400
04401 ACTION_TEMPLATE(InvokeArgument,
04402 HAS_1_TEMPLATE_PARAMS(int, k),
04403 AND_2_VALUE_PARAMS(p0, p1)) {
04404 return internal::CallableHelper<return_type>::Call(
04405 ::std::tr1::get<k>(args), p0, p1);
04406 }
04407
04408 ACTION_TEMPLATE(InvokeArgument,
04409 HAS_1_TEMPLATE_PARAMS(int, k),
04410 AND_3_VALUE_PARAMS(p0, p1, p2)) {
04411 return internal::CallableHelper<return_type>::Call(
04412 ::std::tr1::get<k>(args), p0, p1, p2);
04413 }
04414
04415 ACTION_TEMPLATE(InvokeArgument,
04416 HAS_1_TEMPLATE_PARAMS(int, k),
04417 AND_4_VALUE_PARAMS(p0, p1, p2, p3)) {
04418 return internal::CallableHelper<return_type>::Call(
04419 ::std::tr1::get<k>(args), p0, p1, p2, p3);
04420 }
04421
04422 ACTION_TEMPLATE(InvokeArgument,
04423 HAS_1_TEMPLATE_PARAMS(int, k),
04424 AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) {
04425 return internal::CallableHelper<return_type>::Call(
04426 ::std::tr1::get<k>(args), p0, p1, p2, p3, p4);
04427 }
04428
04429 ACTION_TEMPLATE(InvokeArgument,
04430 HAS_1_TEMPLATE_PARAMS(int, k),
04431 AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) {
04432 return internal::CallableHelper<return_type>::Call(
04433 ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5);
04434 }
04435
04436 ACTION_TEMPLATE(InvokeArgument,
04437 HAS_1_TEMPLATE_PARAMS(int, k),
04438 AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) {
04439 return internal::CallableHelper<return_type>::Call(
04440 ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6);
04441 }
04442
04443 ACTION_TEMPLATE(InvokeArgument,
04444 HAS_1_TEMPLATE_PARAMS(int, k),
04445 AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) {
04446 return internal::CallableHelper<return_type>::Call(
04447 ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7);
04448 }
04449
04450 ACTION_TEMPLATE(InvokeArgument,
04451 HAS_1_TEMPLATE_PARAMS(int, k),
04452 AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) {
04453 return internal::CallableHelper<return_type>::Call(
04454 ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8);
04455 }
04456
04457 ACTION_TEMPLATE(InvokeArgument,
04458 HAS_1_TEMPLATE_PARAMS(int, k),
04459 AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) {
04460 return internal::CallableHelper<return_type>::Call(
04461 ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
04462 }
04463
04464
04465
04466
04467
04468
04469 ACTION_TEMPLATE(ReturnNew,
04470 HAS_1_TEMPLATE_PARAMS(typename, T),
04471 AND_0_VALUE_PARAMS()) {
04472 return new T();
04473 }
04474
04475 ACTION_TEMPLATE(ReturnNew,
04476 HAS_1_TEMPLATE_PARAMS(typename, T),
04477 AND_1_VALUE_PARAMS(p0)) {
04478 return new T(p0);
04479 }
04480
04481 ACTION_TEMPLATE(ReturnNew,
04482 HAS_1_TEMPLATE_PARAMS(typename, T),
04483 AND_2_VALUE_PARAMS(p0, p1)) {
04484 return new T(p0, p1);
04485 }
04486
04487 ACTION_TEMPLATE(ReturnNew,
04488 HAS_1_TEMPLATE_PARAMS(typename, T),
04489 AND_3_VALUE_PARAMS(p0, p1, p2)) {
04490 return new T(p0, p1, p2);
04491 }
04492
04493 ACTION_TEMPLATE(ReturnNew,
04494 HAS_1_TEMPLATE_PARAMS(typename, T),
04495 AND_4_VALUE_PARAMS(p0, p1, p2, p3)) {
04496 return new T(p0, p1, p2, p3);
04497 }
04498
04499 ACTION_TEMPLATE(ReturnNew,
04500 HAS_1_TEMPLATE_PARAMS(typename, T),
04501 AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) {
04502 return new T(p0, p1, p2, p3, p4);
04503 }
04504
04505 ACTION_TEMPLATE(ReturnNew,
04506 HAS_1_TEMPLATE_PARAMS(typename, T),
04507 AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) {
04508 return new T(p0, p1, p2, p3, p4, p5);
04509 }
04510
04511 ACTION_TEMPLATE(ReturnNew,
04512 HAS_1_TEMPLATE_PARAMS(typename, T),
04513 AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) {
04514 return new T(p0, p1, p2, p3, p4, p5, p6);
04515 }
04516
04517 ACTION_TEMPLATE(ReturnNew,
04518 HAS_1_TEMPLATE_PARAMS(typename, T),
04519 AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) {
04520 return new T(p0, p1, p2, p3, p4, p5, p6, p7);
04521 }
04522
04523 ACTION_TEMPLATE(ReturnNew,
04524 HAS_1_TEMPLATE_PARAMS(typename, T),
04525 AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) {
04526 return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8);
04527 }
04528
04529 ACTION_TEMPLATE(ReturnNew,
04530 HAS_1_TEMPLATE_PARAMS(typename, T),
04531 AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) {
04532 return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
04533 }
04534
04535 #ifdef _MSC_VER
04536 # pragma warning(pop)
04537 #endif
04538
04539 }
04540
04541 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
04542
04543
04544
04545
04546
04547
04548
04549
04550
04551
04552
04553
04554
04555
04556
04557
04558
04559
04560
04561
04562
04563
04564
04565
04566
04567
04568
04569
04570
04571
04572
04573
04574
04575
04576
04577
04578
04579
04580
04581 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
04582 #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
04583
04584
04585
04586
04587
04588
04589
04590
04591
04592
04593
04594
04595
04596
04597
04598
04599
04600
04601
04602
04603
04604
04605
04606
04607
04608
04609
04610
04611
04612
04613
04614
04615
04616
04617
04618
04619
04620
04621
04622
04623
04624
04625
04626
04627
04628
04629
04630
04631
04632
04633
04634
04635
04636
04637
04638
04639
04640
04641
04642
04643 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
04644 #define GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
04645
04646 #include <map>
04647 #include <set>
04648 #include <sstream>
04649 #include <string>
04650 #include <vector>
04651
04652 #if GTEST_HAS_EXCEPTIONS
04653 # include <stdexcept>
04654 #endif
04655
04656
04657
04658
04659
04660
04661
04662
04663
04664
04665
04666
04667
04668
04669
04670
04671
04672
04673
04674
04675
04676
04677
04678
04679
04680
04681
04682
04683
04684
04685
04686
04687
04688
04689
04690
04691
04692
04693 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
04694 #define GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
04695
04696 #include <math.h>
04697 #include <algorithm>
04698 #include <iterator>
04699 #include <limits>
04700 #include <ostream>
04701 #include <sstream>
04702 #include <string>
04703 #include <utility>
04704 #include <vector>
04705
04706
04707 #if GTEST_LANG_CXX11
04708 #include <initializer_list>
04709 #endif
04710
04711 namespace testing {
04712
04713
04714
04715
04716
04717
04718
04719
04720
04721
04722
04723
04724
04725
04726
04727
04728
04729
04730
04731
04732 class MatchResultListener {
04733 public:
04734
04735
04736
04737 explicit MatchResultListener(::std::ostream* os) : stream_(os) {}
04738 virtual ~MatchResultListener() = 0;
04739
04740
04741
04742 template <typename T>
04743 MatchResultListener& operator<<(const T& x) {
04744 if (stream_ != NULL)
04745 *stream_ << x;
04746 return *this;
04747 }
04748
04749
04750 ::std::ostream* stream() { return stream_; }
04751
04752
04753
04754
04755
04756 bool IsInterested() const { return stream_ != NULL; }
04757
04758 private:
04759 ::std::ostream* const stream_;
04760
04761 GTEST_DISALLOW_COPY_AND_ASSIGN_(MatchResultListener);
04762 };
04763
04764 inline MatchResultListener::~MatchResultListener() {
04765 }
04766
04767
04768
04769 class MatcherDescriberInterface {
04770 public:
04771 virtual ~MatcherDescriberInterface() {}
04772
04773
04774
04775
04776
04777
04778 virtual void DescribeTo(::std::ostream* os) const = 0;
04779
04780
04781
04782
04783
04784
04785
04786 virtual void DescribeNegationTo(::std::ostream* os) const {
04787 *os << "not (";
04788 DescribeTo(os);
04789 *os << ")";
04790 }
04791 };
04792
04793
04794 template <typename T>
04795 class MatcherInterface : public MatcherDescriberInterface {
04796 public:
04797
04798
04799
04800
04801
04802
04803
04804
04805
04806
04807
04808
04809
04810
04811
04812
04813
04814
04815
04816
04817
04818
04819
04820
04821
04822
04823
04824
04825
04826
04827
04828 virtual bool MatchAndExplain(T x, MatchResultListener* listener) const = 0;
04829
04830
04831
04832
04833 };
04834
04835
04836 class StringMatchResultListener : public MatchResultListener {
04837 public:
04838 StringMatchResultListener() : MatchResultListener(&ss_) {}
04839
04840
04841 internal::string str() const { return ss_.str(); }
04842
04843
04844 void Clear() { ss_.str(""); }
04845
04846 private:
04847 ::std::stringstream ss_;
04848
04849 GTEST_DISALLOW_COPY_AND_ASSIGN_(StringMatchResultListener);
04850 };
04851
04852 namespace internal {
04853
04854
04855 class DummyMatchResultListener : public MatchResultListener {
04856 public:
04857 DummyMatchResultListener() : MatchResultListener(NULL) {}
04858
04859 private:
04860 GTEST_DISALLOW_COPY_AND_ASSIGN_(DummyMatchResultListener);
04861 };
04862
04863
04864
04865
04866 class StreamMatchResultListener : public MatchResultListener {
04867 public:
04868 explicit StreamMatchResultListener(::std::ostream* os)
04869 : MatchResultListener(os) {}
04870
04871 private:
04872 GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamMatchResultListener);
04873 };
04874
04875
04876
04877
04878 template <typename T>
04879 class MatcherBase {
04880 public:
04881
04882
04883 bool MatchAndExplain(T x, MatchResultListener* listener) const {
04884 return impl_->MatchAndExplain(x, listener);
04885 }
04886
04887
04888 bool Matches(T x) const {
04889 DummyMatchResultListener dummy;
04890 return MatchAndExplain(x, &dummy);
04891 }
04892
04893
04894 void DescribeTo(::std::ostream* os) const { impl_->DescribeTo(os); }
04895
04896
04897 void DescribeNegationTo(::std::ostream* os) const {
04898 impl_->DescribeNegationTo(os);
04899 }
04900
04901
04902 void ExplainMatchResultTo(T x, ::std::ostream* os) const {
04903 StreamMatchResultListener listener(os);
04904 MatchAndExplain(x, &listener);
04905 }
04906
04907
04908
04909
04910 const MatcherDescriberInterface* GetDescriber() const {
04911 return impl_.get();
04912 }
04913
04914 protected:
04915 MatcherBase() {}
04916
04917
04918 explicit MatcherBase(const MatcherInterface<T>* impl)
04919 : impl_(impl) {}
04920
04921 virtual ~MatcherBase() {}
04922
04923 private:
04924
04925
04926
04927
04928
04929
04930
04931
04932
04933
04934
04935 ::testing::internal::linked_ptr<const MatcherInterface<T> > impl_;
04936 };
04937
04938 }
04939
04940
04941
04942
04943
04944
04945 template <typename T>
04946 class Matcher : public internal::MatcherBase<T> {
04947 public:
04948
04949
04950
04951 Matcher() {}
04952
04953
04954 explicit Matcher(const MatcherInterface<T>* impl)
04955 : internal::MatcherBase<T>(impl) {}
04956
04957
04958
04959 Matcher(T value);
04960 };
04961
04962
04963
04964
04965 template <>
04966 class GTEST_API_ Matcher<const internal::string&>
04967 : public internal::MatcherBase<const internal::string&> {
04968 public:
04969 Matcher() {}
04970
04971 explicit Matcher(const MatcherInterface<const internal::string&>* impl)
04972 : internal::MatcherBase<const internal::string&>(impl) {}
04973
04974
04975
04976 Matcher(const internal::string& s);
04977
04978
04979 Matcher(const char* s);
04980 };
04981
04982 template <>
04983 class GTEST_API_ Matcher<internal::string>
04984 : public internal::MatcherBase<internal::string> {
04985 public:
04986 Matcher() {}
04987
04988 explicit Matcher(const MatcherInterface<internal::string>* impl)
04989 : internal::MatcherBase<internal::string>(impl) {}
04990
04991
04992
04993 Matcher(const internal::string& s);
04994
04995
04996 Matcher(const char* s);
04997 };
04998
04999 #if GTEST_HAS_STRING_PIECE_
05000
05001
05002
05003 template <>
05004 class GTEST_API_ Matcher<const StringPiece&>
05005 : public internal::MatcherBase<const StringPiece&> {
05006 public:
05007 Matcher() {}
05008
05009 explicit Matcher(const MatcherInterface<const StringPiece&>* impl)
05010 : internal::MatcherBase<const StringPiece&>(impl) {}
05011
05012
05013
05014 Matcher(const internal::string& s);
05015
05016
05017 Matcher(const char* s);
05018
05019
05020 Matcher(StringPiece s);
05021 };
05022
05023 template <>
05024 class GTEST_API_ Matcher<StringPiece>
05025 : public internal::MatcherBase<StringPiece> {
05026 public:
05027 Matcher() {}
05028
05029 explicit Matcher(const MatcherInterface<StringPiece>* impl)
05030 : internal::MatcherBase<StringPiece>(impl) {}
05031
05032
05033
05034 Matcher(const internal::string& s);
05035
05036
05037 Matcher(const char* s);
05038
05039
05040 Matcher(StringPiece s);
05041 };
05042 #endif // GTEST_HAS_STRING_PIECE_
05043
05044
05045
05046
05047
05048
05049
05050
05051
05052
05053
05054
05055
05056 template <class Impl>
05057 class PolymorphicMatcher {
05058 public:
05059 explicit PolymorphicMatcher(const Impl& an_impl) : impl_(an_impl) {}
05060
05061
05062
05063 Impl& mutable_impl() { return impl_; }
05064
05065
05066
05067 const Impl& impl() const { return impl_; }
05068
05069 template <typename T>
05070 operator Matcher<T>() const {
05071 return Matcher<T>(new MonomorphicImpl<T>(impl_));
05072 }
05073
05074 private:
05075 template <typename T>
05076 class MonomorphicImpl : public MatcherInterface<T> {
05077 public:
05078 explicit MonomorphicImpl(const Impl& impl) : impl_(impl) {}
05079
05080 virtual void DescribeTo(::std::ostream* os) const {
05081 impl_.DescribeTo(os);
05082 }
05083
05084 virtual void DescribeNegationTo(::std::ostream* os) const {
05085 impl_.DescribeNegationTo(os);
05086 }
05087
05088 virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {
05089 return impl_.MatchAndExplain(x, listener);
05090 }
05091
05092 private:
05093 const Impl impl_;
05094
05095 GTEST_DISALLOW_ASSIGN_(MonomorphicImpl);
05096 };
05097
05098 Impl impl_;
05099
05100 GTEST_DISALLOW_ASSIGN_(PolymorphicMatcher);
05101 };
05102
05103
05104
05105
05106
05107
05108
05109
05110 template <typename T>
05111 inline Matcher<T> MakeMatcher(const MatcherInterface<T>* impl) {
05112 return Matcher<T>(impl);
05113 }
05114
05115
05116
05117
05118
05119
05120
05121
05122 template <class Impl>
05123 inline PolymorphicMatcher<Impl> MakePolymorphicMatcher(const Impl& impl) {
05124 return PolymorphicMatcher<Impl>(impl);
05125 }
05126
05127
05128
05129 namespace internal {
05130
05131
05132
05133
05134
05135
05136
05137
05138
05139
05140
05141 template <typename T, typename M>
05142 class MatcherCastImpl {
05143 public:
05144 static Matcher<T> Cast(M polymorphic_matcher_or_value) {
05145
05146
05147
05148
05149
05150
05151
05152
05153
05154
05155
05156
05157
05158 return CastImpl(
05159 polymorphic_matcher_or_value,
05160 BooleanConstant<
05161 internal::ImplicitlyConvertible<M, Matcher<T> >::value>());
05162 }
05163
05164 private:
05165 static Matcher<T> CastImpl(M value, BooleanConstant<false>) {
05166
05167
05168
05169 return Matcher<T>(ImplicitCast_<T>(value));
05170 }
05171
05172 static Matcher<T> CastImpl(M polymorphic_matcher_or_value,
05173 BooleanConstant<true>) {
05174
05175
05176
05177
05178
05179
05180
05181
05182 return polymorphic_matcher_or_value;
05183 }
05184 };
05185
05186
05187
05188
05189 template <typename T, typename U>
05190 class MatcherCastImpl<T, Matcher<U> > {
05191 public:
05192 static Matcher<T> Cast(const Matcher<U>& source_matcher) {
05193 return Matcher<T>(new Impl(source_matcher));
05194 }
05195
05196 private:
05197 class Impl : public MatcherInterface<T> {
05198 public:
05199 explicit Impl(const Matcher<U>& source_matcher)
05200 : source_matcher_(source_matcher) {}
05201
05202
05203 virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {
05204 return source_matcher_.MatchAndExplain(static_cast<U>(x), listener);
05205 }
05206
05207 virtual void DescribeTo(::std::ostream* os) const {
05208 source_matcher_.DescribeTo(os);
05209 }
05210
05211 virtual void DescribeNegationTo(::std::ostream* os) const {
05212 source_matcher_.DescribeNegationTo(os);
05213 }
05214
05215 private:
05216 const Matcher<U> source_matcher_;
05217
05218 GTEST_DISALLOW_ASSIGN_(Impl);
05219 };
05220 };
05221
05222
05223
05224 template <typename T>
05225 class MatcherCastImpl<T, Matcher<T> > {
05226 public:
05227 static Matcher<T> Cast(const Matcher<T>& matcher) { return matcher; }
05228 };
05229
05230 }
05231
05232
05233
05234
05235
05236 template <typename T, typename M>
05237 inline Matcher<T> MatcherCast(M matcher) {
05238 return internal::MatcherCastImpl<T, M>::Cast(matcher);
05239 }
05240
05241
05242
05243
05244
05245
05246
05247
05248 template <typename T>
05249 class SafeMatcherCastImpl {
05250 public:
05251
05252
05253 template <typename M>
05254 static inline Matcher<T> Cast(M polymorphic_matcher_or_value) {
05255 return internal::MatcherCastImpl<T, M>::Cast(polymorphic_matcher_or_value);
05256 }
05257
05258
05259
05260
05261
05262
05263
05264
05265
05266
05267 template <typename U>
05268 static inline Matcher<T> Cast(const Matcher<U>& matcher) {
05269
05270 GTEST_COMPILE_ASSERT_((internal::ImplicitlyConvertible<T, U>::value),
05271 T_must_be_implicitly_convertible_to_U);
05272
05273
05274 GTEST_COMPILE_ASSERT_(
05275 internal::is_reference<T>::value || !internal::is_reference<U>::value,
05276 cannot_convert_non_referentce_arg_to_reference);
05277
05278
05279 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(T) RawT;
05280 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(U) RawU;
05281 const bool kTIsOther = GMOCK_KIND_OF_(RawT) == internal::kOther;
05282 const bool kUIsOther = GMOCK_KIND_OF_(RawU) == internal::kOther;
05283 GTEST_COMPILE_ASSERT_(
05284 kTIsOther || kUIsOther ||
05285 (internal::LosslessArithmeticConvertible<RawT, RawU>::value),
05286 conversion_of_arithmetic_types_must_be_lossless);
05287 return MatcherCast<T>(matcher);
05288 }
05289 };
05290
05291 template <typename T, typename M>
05292 inline Matcher<T> SafeMatcherCast(const M& polymorphic_matcher) {
05293 return SafeMatcherCastImpl<T>::Cast(polymorphic_matcher);
05294 }
05295
05296
05297 template <typename T>
05298 Matcher<T> A();
05299
05300
05301
05302 namespace internal {
05303
05304
05305 inline void PrintIfNotEmpty(const internal::string& explanation,
05306 ::std::ostream* os) {
05307 if (explanation != "" && os != NULL) {
05308 *os << ", " << explanation;
05309 }
05310 }
05311
05312
05313
05314
05315 inline bool IsReadableTypeName(const string& type_name) {
05316
05317
05318 return (type_name.length() <= 20 ||
05319 type_name.find_first_of("<(") == string::npos);
05320 }
05321
05322
05323
05324
05325
05326
05327 template <typename Value, typename T>
05328 bool MatchPrintAndExplain(Value& value, const Matcher<T>& matcher,
05329 MatchResultListener* listener) {
05330 if (!listener->IsInterested()) {
05331
05332
05333 return matcher.Matches(value);
05334 }
05335
05336 StringMatchResultListener inner_listener;
05337 const bool match = matcher.MatchAndExplain(value, &inner_listener);
05338
05339 UniversalPrint(value, listener->stream());
05340 #if GTEST_HAS_RTTI
05341 const string& type_name = GetTypeName<Value>();
05342 if (IsReadableTypeName(type_name))
05343 *listener->stream() << " (of type " << type_name << ")";
05344 #endif
05345 PrintIfNotEmpty(inner_listener.str(), listener->stream());
05346
05347 return match;
05348 }
05349
05350
05351
05352 template <size_t N>
05353 class TuplePrefix {
05354 public:
05355
05356
05357
05358 template <typename MatcherTuple, typename ValueTuple>
05359 static bool Matches(const MatcherTuple& matcher_tuple,
05360 const ValueTuple& value_tuple) {
05361 using ::std::tr1::get;
05362 return TuplePrefix<N - 1>::Matches(matcher_tuple, value_tuple)
05363 && get<N - 1>(matcher_tuple).Matches(get<N - 1>(value_tuple));
05364 }
05365
05366
05367
05368
05369
05370 template <typename MatcherTuple, typename ValueTuple>
05371 static void ExplainMatchFailuresTo(const MatcherTuple& matchers,
05372 const ValueTuple& values,
05373 ::std::ostream* os) {
05374 using ::std::tr1::tuple_element;
05375 using ::std::tr1::get;
05376
05377
05378 TuplePrefix<N - 1>::ExplainMatchFailuresTo(matchers, values, os);
05379
05380
05381
05382 typename tuple_element<N - 1, MatcherTuple>::type matcher =
05383 get<N - 1>(matchers);
05384 typedef typename tuple_element<N - 1, ValueTuple>::type Value;
05385 Value value = get<N - 1>(values);
05386 StringMatchResultListener listener;
05387 if (!matcher.MatchAndExplain(value, &listener)) {
05388
05389
05390 *os << " Expected arg #" << N - 1 << ": ";
05391 get<N - 1>(matchers).DescribeTo(os);
05392 *os << "\n Actual: ";
05393
05394
05395
05396
05397
05398 internal::UniversalPrint(value, os);
05399 PrintIfNotEmpty(listener.str(), os);
05400 *os << "\n";
05401 }
05402 }
05403 };
05404
05405
05406 template <>
05407 class TuplePrefix<0> {
05408 public:
05409 template <typename MatcherTuple, typename ValueTuple>
05410 static bool Matches(const MatcherTuple& ,
05411 const ValueTuple& ) {
05412 return true;
05413 }
05414
05415 template <typename MatcherTuple, typename ValueTuple>
05416 static void ExplainMatchFailuresTo(const MatcherTuple& ,
05417 const ValueTuple& ,
05418 ::std::ostream* ) {}
05419 };
05420
05421
05422
05423
05424
05425
05426 template <typename MatcherTuple, typename ValueTuple>
05427 bool TupleMatches(const MatcherTuple& matcher_tuple,
05428 const ValueTuple& value_tuple) {
05429 using ::std::tr1::tuple_size;
05430
05431
05432 GTEST_COMPILE_ASSERT_(tuple_size<MatcherTuple>::value ==
05433 tuple_size<ValueTuple>::value,
05434 matcher_and_value_have_different_numbers_of_fields);
05435 return TuplePrefix<tuple_size<ValueTuple>::value>::
05436 Matches(matcher_tuple, value_tuple);
05437 }
05438
05439
05440
05441 template <typename MatcherTuple, typename ValueTuple>
05442 void ExplainMatchFailureTupleTo(const MatcherTuple& matchers,
05443 const ValueTuple& values,
05444 ::std::ostream* os) {
05445 using ::std::tr1::tuple_size;
05446 TuplePrefix<tuple_size<MatcherTuple>::value>::ExplainMatchFailuresTo(
05447 matchers, values, os);
05448 }
05449
05450
05451
05452
05453
05454 template <typename Tuple, typename Func, typename OutIter>
05455 class TransformTupleValuesHelper {
05456 private:
05457 typedef typename ::std::tr1::tuple_size<Tuple> TupleSize;
05458
05459 public:
05460
05461
05462 static OutIter Run(Func f, const Tuple& t, OutIter out) {
05463 return IterateOverTuple<Tuple, TupleSize::value>()(f, t, out);
05464 }
05465
05466 private:
05467 template <typename Tup, size_t kRemainingSize>
05468 struct IterateOverTuple {
05469 OutIter operator() (Func f, const Tup& t, OutIter out) const {
05470 *out++ = f(::std::tr1::get<TupleSize::value - kRemainingSize>(t));
05471 return IterateOverTuple<Tup, kRemainingSize - 1>()(f, t, out);
05472 }
05473 };
05474 template <typename Tup>
05475 struct IterateOverTuple<Tup, 0> {
05476 OutIter operator() (Func , const Tup& , OutIter out) const {
05477 return out;
05478 }
05479 };
05480 };
05481
05482
05483
05484
05485 template <typename Tuple, typename Func, typename OutIter>
05486 OutIter TransformTupleValues(Func f, const Tuple& t, OutIter out) {
05487 return TransformTupleValuesHelper<Tuple, Func, OutIter>::Run(f, t, out);
05488 }
05489
05490
05491 template <typename T>
05492 class AnyMatcherImpl : public MatcherInterface<T> {
05493 public:
05494 virtual bool MatchAndExplain(
05495 T , MatchResultListener* ) const { return true; }
05496 virtual void DescribeTo(::std::ostream* os) const { *os << "is anything"; }
05497 virtual void DescribeNegationTo(::std::ostream* os) const {
05498
05499
05500
05501 *os << "never matches";
05502 }
05503 };
05504
05505
05506
05507
05508
05509 class AnythingMatcher {
05510 public:
05511 template <typename T>
05512 operator Matcher<T>() const { return A<T>(); }
05513 };
05514
05515
05516
05517
05518
05519
05520
05521
05522
05523
05524
05525
05526
05527
05528 #define GMOCK_IMPLEMENT_COMPARISON_MATCHER_( \
05529 name, op, relation, negated_relation) \
05530 template <typename Rhs> class name##Matcher { \
05531 public: \
05532 explicit name##Matcher(const Rhs& rhs) : rhs_(rhs) {} \
05533 template <typename Lhs> \
05534 operator Matcher<Lhs>() const { \
05535 return MakeMatcher(new Impl<Lhs>(rhs_)); \
05536 } \
05537 private: \
05538 template <typename Lhs> \
05539 class Impl : public MatcherInterface<Lhs> { \
05540 public: \
05541 explicit Impl(const Rhs& rhs) : rhs_(rhs) {} \
05542 virtual bool MatchAndExplain(\
05543 Lhs lhs, MatchResultListener* ) const { \
05544 return lhs op rhs_; \
05545 } \
05546 virtual void DescribeTo(::std::ostream* os) const { \
05547 *os << relation " "; \
05548 UniversalPrint(rhs_, os); \
05549 } \
05550 virtual void DescribeNegationTo(::std::ostream* os) const { \
05551 *os << negated_relation " "; \
05552 UniversalPrint(rhs_, os); \
05553 } \
05554 private: \
05555 Rhs rhs_; \
05556 GTEST_DISALLOW_ASSIGN_(Impl); \
05557 }; \
05558 Rhs rhs_; \
05559 GTEST_DISALLOW_ASSIGN_(name##Matcher); \
05560 }
05561
05562
05563
05564 GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Eq, ==, "is equal to", "isn't equal to");
05565 GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Ge, >=, "is >=", "isn't >=");
05566 GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Gt, >, "is >", "isn't >");
05567 GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Le, <=, "is <=", "isn't <=");
05568 GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Lt, <, "is <", "isn't <");
05569 GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Ne, !=, "isn't equal to", "is equal to");
05570
05571 #undef GMOCK_IMPLEMENT_COMPARISON_MATCHER_
05572
05573
05574
05575 class IsNullMatcher {
05576 public:
05577 template <typename Pointer>
05578 bool MatchAndExplain(const Pointer& p,
05579 MatchResultListener* ) const {
05580 return GetRawPointer(p) == NULL;
05581 }
05582
05583 void DescribeTo(::std::ostream* os) const { *os << "is NULL"; }
05584 void DescribeNegationTo(::std::ostream* os) const {
05585 *os << "isn't NULL";
05586 }
05587 };
05588
05589
05590
05591 class NotNullMatcher {
05592 public:
05593 template <typename Pointer>
05594 bool MatchAndExplain(const Pointer& p,
05595 MatchResultListener* ) const {
05596 return GetRawPointer(p) != NULL;
05597 }
05598
05599 void DescribeTo(::std::ostream* os) const { *os << "isn't NULL"; }
05600 void DescribeNegationTo(::std::ostream* os) const {
05601 *os << "is NULL";
05602 }
05603 };
05604
05605
05606
05607
05608
05609
05610
05611
05612
05613
05614
05615
05616
05617
05618 template <typename T>
05619 class RefMatcher;
05620
05621 template <typename T>
05622 class RefMatcher<T&> {
05623
05624
05625
05626
05627
05628 public:
05629
05630
05631
05632 explicit RefMatcher(T& x) : object_(x) {}
05633
05634 template <typename Super>
05635 operator Matcher<Super&>() const {
05636
05637
05638
05639
05640
05641 return MakeMatcher(new Impl<Super>(object_));
05642 }
05643
05644 private:
05645 template <typename Super>
05646 class Impl : public MatcherInterface<Super&> {
05647 public:
05648 explicit Impl(Super& x) : object_(x) {}
05649
05650
05651
05652 virtual bool MatchAndExplain(
05653 Super& x, MatchResultListener* listener) const {
05654 *listener << "which is located @" << static_cast<const void*>(&x);
05655 return &x == &object_;
05656 }
05657
05658 virtual void DescribeTo(::std::ostream* os) const {
05659 *os << "references the variable ";
05660 UniversalPrinter<Super&>::Print(object_, os);
05661 }
05662
05663 virtual void DescribeNegationTo(::std::ostream* os) const {
05664 *os << "does not reference the variable ";
05665 UniversalPrinter<Super&>::Print(object_, os);
05666 }
05667
05668 private:
05669 const Super& object_;
05670
05671 GTEST_DISALLOW_ASSIGN_(Impl);
05672 };
05673
05674 T& object_;
05675
05676 GTEST_DISALLOW_ASSIGN_(RefMatcher);
05677 };
05678
05679
05680 inline bool CaseInsensitiveCStringEquals(const char* lhs, const char* rhs) {
05681 return String::CaseInsensitiveCStringEquals(lhs, rhs);
05682 }
05683
05684 inline bool CaseInsensitiveCStringEquals(const wchar_t* lhs,
05685 const wchar_t* rhs) {
05686 return String::CaseInsensitiveWideCStringEquals(lhs, rhs);
05687 }
05688
05689
05690
05691 template <typename StringType>
05692 bool CaseInsensitiveStringEquals(const StringType& s1,
05693 const StringType& s2) {
05694
05695 if (!CaseInsensitiveCStringEquals(s1.c_str(), s2.c_str())) {
05696 return false;
05697 }
05698
05699
05700 const typename StringType::value_type nul = 0;
05701 const size_t i1 = s1.find(nul), i2 = s2.find(nul);
05702
05703
05704 if (i1 == StringType::npos || i2 == StringType::npos) {
05705 return i1 == i2;
05706 }
05707
05708
05709 return CaseInsensitiveStringEquals(s1.substr(i1 + 1), s2.substr(i2 + 1));
05710 }
05711
05712
05713
05714
05715 template <typename StringType>
05716 class StrEqualityMatcher {
05717 public:
05718 StrEqualityMatcher(const StringType& str, bool expect_eq,
05719 bool case_sensitive)
05720 : string_(str), expect_eq_(expect_eq), case_sensitive_(case_sensitive) {}
05721
05722
05723
05724
05725
05726
05727 template <typename CharType>
05728 bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {
05729 if (s == NULL) {
05730 return !expect_eq_;
05731 }
05732 return MatchAndExplain(StringType(s), listener);
05733 }
05734
05735
05736
05737
05738
05739 template <typename MatcheeStringType>
05740 bool MatchAndExplain(const MatcheeStringType& s,
05741 MatchResultListener* ) const {
05742 const StringType& s2(s);
05743 const bool eq = case_sensitive_ ? s2 == string_ :
05744 CaseInsensitiveStringEquals(s2, string_);
05745 return expect_eq_ == eq;
05746 }
05747
05748 void DescribeTo(::std::ostream* os) const {
05749 DescribeToHelper(expect_eq_, os);
05750 }
05751
05752 void DescribeNegationTo(::std::ostream* os) const {
05753 DescribeToHelper(!expect_eq_, os);
05754 }
05755
05756 private:
05757 void DescribeToHelper(bool expect_eq, ::std::ostream* os) const {
05758 *os << (expect_eq ? "is " : "isn't ");
05759 *os << "equal to ";
05760 if (!case_sensitive_) {
05761 *os << "(ignoring case) ";
05762 }
05763 UniversalPrint(string_, os);
05764 }
05765
05766 const StringType string_;
05767 const bool expect_eq_;
05768 const bool case_sensitive_;
05769
05770 GTEST_DISALLOW_ASSIGN_(StrEqualityMatcher);
05771 };
05772
05773
05774
05775
05776 template <typename StringType>
05777 class HasSubstrMatcher {
05778 public:
05779 explicit HasSubstrMatcher(const StringType& substring)
05780 : substring_(substring) {}
05781
05782
05783
05784
05785
05786
05787 template <typename CharType>
05788 bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {
05789 return s != NULL && MatchAndExplain(StringType(s), listener);
05790 }
05791
05792
05793
05794
05795
05796 template <typename MatcheeStringType>
05797 bool MatchAndExplain(const MatcheeStringType& s,
05798 MatchResultListener* ) const {
05799 const StringType& s2(s);
05800 return s2.find(substring_) != StringType::npos;
05801 }
05802
05803
05804 void DescribeTo(::std::ostream* os) const {
05805 *os << "has substring ";
05806 UniversalPrint(substring_, os);
05807 }
05808
05809 void DescribeNegationTo(::std::ostream* os) const {
05810 *os << "has no substring ";
05811 UniversalPrint(substring_, os);
05812 }
05813
05814 private:
05815 const StringType substring_;
05816
05817 GTEST_DISALLOW_ASSIGN_(HasSubstrMatcher);
05818 };
05819
05820
05821
05822
05823 template <typename StringType>
05824 class StartsWithMatcher {
05825 public:
05826 explicit StartsWithMatcher(const StringType& prefix) : prefix_(prefix) {
05827 }
05828
05829
05830
05831
05832
05833
05834 template <typename CharType>
05835 bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {
05836 return s != NULL && MatchAndExplain(StringType(s), listener);
05837 }
05838
05839
05840
05841
05842
05843 template <typename MatcheeStringType>
05844 bool MatchAndExplain(const MatcheeStringType& s,
05845 MatchResultListener* ) const {
05846 const StringType& s2(s);
05847 return s2.length() >= prefix_.length() &&
05848 s2.substr(0, prefix_.length()) == prefix_;
05849 }
05850
05851 void DescribeTo(::std::ostream* os) const {
05852 *os << "starts with ";
05853 UniversalPrint(prefix_, os);
05854 }
05855
05856 void DescribeNegationTo(::std::ostream* os) const {
05857 *os << "doesn't start with ";
05858 UniversalPrint(prefix_, os);
05859 }
05860
05861 private:
05862 const StringType prefix_;
05863
05864 GTEST_DISALLOW_ASSIGN_(StartsWithMatcher);
05865 };
05866
05867
05868
05869
05870 template <typename StringType>
05871 class EndsWithMatcher {
05872 public:
05873 explicit EndsWithMatcher(const StringType& suffix) : suffix_(suffix) {}
05874
05875
05876
05877
05878
05879
05880 template <typename CharType>
05881 bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {
05882 return s != NULL && MatchAndExplain(StringType(s), listener);
05883 }
05884
05885
05886
05887
05888
05889 template <typename MatcheeStringType>
05890 bool MatchAndExplain(const MatcheeStringType& s,
05891 MatchResultListener* ) const {
05892 const StringType& s2(s);
05893 return s2.length() >= suffix_.length() &&
05894 s2.substr(s2.length() - suffix_.length()) == suffix_;
05895 }
05896
05897 void DescribeTo(::std::ostream* os) const {
05898 *os << "ends with ";
05899 UniversalPrint(suffix_, os);
05900 }
05901
05902 void DescribeNegationTo(::std::ostream* os) const {
05903 *os << "doesn't end with ";
05904 UniversalPrint(suffix_, os);
05905 }
05906
05907 private:
05908 const StringType suffix_;
05909
05910 GTEST_DISALLOW_ASSIGN_(EndsWithMatcher);
05911 };
05912
05913
05914
05915
05916 class MatchesRegexMatcher {
05917 public:
05918 MatchesRegexMatcher(const RE* regex, bool full_match)
05919 : regex_(regex), full_match_(full_match) {}
05920
05921
05922
05923
05924
05925
05926 template <typename CharType>
05927 bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {
05928 return s != NULL && MatchAndExplain(internal::string(s), listener);
05929 }
05930
05931
05932
05933
05934
05935 template <class MatcheeStringType>
05936 bool MatchAndExplain(const MatcheeStringType& s,
05937 MatchResultListener* ) const {
05938 const internal::string& s2(s);
05939 return full_match_ ? RE::FullMatch(s2, *regex_) :
05940 RE::PartialMatch(s2, *regex_);
05941 }
05942
05943 void DescribeTo(::std::ostream* os) const {
05944 *os << (full_match_ ? "matches" : "contains")
05945 << " regular expression ";
05946 UniversalPrinter<internal::string>::Print(regex_->pattern(), os);
05947 }
05948
05949 void DescribeNegationTo(::std::ostream* os) const {
05950 *os << "doesn't " << (full_match_ ? "match" : "contain")
05951 << " regular expression ";
05952 UniversalPrinter<internal::string>::Print(regex_->pattern(), os);
05953 }
05954
05955 private:
05956 const internal::linked_ptr<const RE> regex_;
05957 const bool full_match_;
05958
05959 GTEST_DISALLOW_ASSIGN_(MatchesRegexMatcher);
05960 };
05961
05962
05963
05964
05965
05966
05967
05968
05969
05970
05971
05972
05973 #define GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(name, op, relation) \
05974 class name##2Matcher { \
05975 public: \
05976 template <typename T1, typename T2> \
05977 operator Matcher< ::std::tr1::tuple<T1, T2> >() const { \
05978 return MakeMatcher(new Impl< ::std::tr1::tuple<T1, T2> >); \
05979 } \
05980 template <typename T1, typename T2> \
05981 operator Matcher<const ::std::tr1::tuple<T1, T2>&>() const { \
05982 return MakeMatcher(new Impl<const ::std::tr1::tuple<T1, T2>&>); \
05983 } \
05984 private: \
05985 template <typename Tuple> \
05986 class Impl : public MatcherInterface<Tuple> { \
05987 public: \
05988 virtual bool MatchAndExplain( \
05989 Tuple args, \
05990 MatchResultListener* ) const { \
05991 return ::std::tr1::get<0>(args) op ::std::tr1::get<1>(args); \
05992 } \
05993 virtual void DescribeTo(::std::ostream* os) const { \
05994 *os << "are " relation; \
05995 } \
05996 virtual void DescribeNegationTo(::std::ostream* os) const { \
05997 *os << "aren't " relation; \
05998 } \
05999 }; \
06000 }
06001
06002
06003 GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Eq, ==, "an equal pair");
06004 GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(
06005 Ge, >=, "a pair where the first >= the second");
06006 GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(
06007 Gt, >, "a pair where the first > the second");
06008 GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(
06009 Le, <=, "a pair where the first <= the second");
06010 GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(
06011 Lt, <, "a pair where the first < the second");
06012 GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Ne, !=, "an unequal pair");
06013
06014 #undef GMOCK_IMPLEMENT_COMPARISON2_MATCHER_
06015
06016
06017
06018
06019
06020 template <typename T>
06021 class NotMatcherImpl : public MatcherInterface<T> {
06022 public:
06023 explicit NotMatcherImpl(const Matcher<T>& matcher)
06024 : matcher_(matcher) {}
06025
06026 virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {
06027 return !matcher_.MatchAndExplain(x, listener);
06028 }
06029
06030 virtual void DescribeTo(::std::ostream* os) const {
06031 matcher_.DescribeNegationTo(os);
06032 }
06033
06034 virtual void DescribeNegationTo(::std::ostream* os) const {
06035 matcher_.DescribeTo(os);
06036 }
06037
06038 private:
06039 const Matcher<T> matcher_;
06040
06041 GTEST_DISALLOW_ASSIGN_(NotMatcherImpl);
06042 };
06043
06044
06045
06046 template <typename InnerMatcher>
06047 class NotMatcher {
06048 public:
06049 explicit NotMatcher(InnerMatcher matcher) : matcher_(matcher) {}
06050
06051
06052
06053 template <typename T>
06054 operator Matcher<T>() const {
06055 return Matcher<T>(new NotMatcherImpl<T>(SafeMatcherCast<T>(matcher_)));
06056 }
06057
06058 private:
06059 InnerMatcher matcher_;
06060
06061 GTEST_DISALLOW_ASSIGN_(NotMatcher);
06062 };
06063
06064
06065
06066
06067
06068 template <typename T>
06069 class BothOfMatcherImpl : public MatcherInterface<T> {
06070 public:
06071 BothOfMatcherImpl(const Matcher<T>& matcher1, const Matcher<T>& matcher2)
06072 : matcher1_(matcher1), matcher2_(matcher2) {}
06073
06074 virtual void DescribeTo(::std::ostream* os) const {
06075 *os << "(";
06076 matcher1_.DescribeTo(os);
06077 *os << ") and (";
06078 matcher2_.DescribeTo(os);
06079 *os << ")";
06080 }
06081
06082 virtual void DescribeNegationTo(::std::ostream* os) const {
06083 *os << "(";
06084 matcher1_.DescribeNegationTo(os);
06085 *os << ") or (";
06086 matcher2_.DescribeNegationTo(os);
06087 *os << ")";
06088 }
06089
06090 virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {
06091
06092
06093 StringMatchResultListener listener1;
06094 if (!matcher1_.MatchAndExplain(x, &listener1)) {
06095 *listener << listener1.str();
06096 return false;
06097 }
06098
06099 StringMatchResultListener listener2;
06100 if (!matcher2_.MatchAndExplain(x, &listener2)) {
06101 *listener << listener2.str();
06102 return false;
06103 }
06104
06105
06106 const internal::string s1 = listener1.str();
06107 const internal::string s2 = listener2.str();
06108
06109 if (s1 == "") {
06110 *listener << s2;
06111 } else {
06112 *listener << s1;
06113 if (s2 != "") {
06114 *listener << ", and " << s2;
06115 }
06116 }
06117 return true;
06118 }
06119
06120 private:
06121 const Matcher<T> matcher1_;
06122 const Matcher<T> matcher2_;
06123
06124 GTEST_DISALLOW_ASSIGN_(BothOfMatcherImpl);
06125 };
06126
06127 #if GTEST_LANG_CXX11
06128
06129
06130
06131
06132
06133
06134
06135 template <int kSize, typename Head, typename... Tail>
06136 struct MatcherList {
06137 typedef MatcherList<kSize - 1, Tail...> MatcherListTail;
06138 typedef ::std::pair<Head, typename MatcherListTail::ListType> ListType;
06139
06140
06141
06142
06143
06144 static ListType BuildList(const Head& matcher, const Tail&... tail) {
06145 return ListType(matcher, MatcherListTail::BuildList(tail...));
06146 }
06147
06148
06149
06150
06151
06152 template <typename T, template <typename > class CombiningMatcher>
06153 static Matcher<T> CreateMatcher(const ListType& matchers) {
06154 return Matcher<T>(new CombiningMatcher<T>(
06155 SafeMatcherCast<T>(matchers.first),
06156 MatcherListTail::template CreateMatcher<T, CombiningMatcher>(
06157 matchers.second)));
06158 }
06159 };
06160
06161
06162
06163 template <typename Matcher1, typename Matcher2>
06164 struct MatcherList<2, Matcher1, Matcher2> {
06165 typedef ::std::pair<Matcher1, Matcher2> ListType;
06166
06167 static ListType BuildList(const Matcher1& matcher1,
06168 const Matcher2& matcher2) {
06169 return ::std::pair<Matcher1, Matcher2>(matcher1, matcher2);
06170 }
06171
06172 template <typename T, template <typename > class CombiningMatcher>
06173 static Matcher<T> CreateMatcher(const ListType& matchers) {
06174 return Matcher<T>(new CombiningMatcher<T>(
06175 SafeMatcherCast<T>(matchers.first),
06176 SafeMatcherCast<T>(matchers.second)));
06177 }
06178 };
06179
06180
06181
06182
06183
06184 template <template <typename T> class CombiningMatcher, typename... Args>
06185 class VariadicMatcher {
06186 public:
06187 VariadicMatcher(const Args&... matchers)
06188 : matchers_(MatcherListType::BuildList(matchers...)) {}
06189
06190
06191
06192
06193 template <typename T>
06194 operator Matcher<T>() const {
06195 return MatcherListType::template CreateMatcher<T, CombiningMatcher>(
06196 matchers_);
06197 }
06198
06199 private:
06200 typedef MatcherList<sizeof...(Args), Args...> MatcherListType;
06201
06202 const typename MatcherListType::ListType matchers_;
06203
06204 GTEST_DISALLOW_ASSIGN_(VariadicMatcher);
06205 };
06206
06207 template <typename... Args>
06208 using AllOfMatcher = VariadicMatcher<BothOfMatcherImpl, Args...>;
06209
06210 #endif // GTEST_LANG_CXX11
06211
06212
06213
06214 template <typename Matcher1, typename Matcher2>
06215 class BothOfMatcher {
06216 public:
06217 BothOfMatcher(Matcher1 matcher1, Matcher2 matcher2)
06218 : matcher1_(matcher1), matcher2_(matcher2) {}
06219
06220
06221
06222
06223 template <typename T>
06224 operator Matcher<T>() const {
06225 return Matcher<T>(new BothOfMatcherImpl<T>(SafeMatcherCast<T>(matcher1_),
06226 SafeMatcherCast<T>(matcher2_)));
06227 }
06228
06229 private:
06230 Matcher1 matcher1_;
06231 Matcher2 matcher2_;
06232
06233 GTEST_DISALLOW_ASSIGN_(BothOfMatcher);
06234 };
06235
06236
06237
06238
06239
06240 template <typename T>
06241 class EitherOfMatcherImpl : public MatcherInterface<T> {
06242 public:
06243 EitherOfMatcherImpl(const Matcher<T>& matcher1, const Matcher<T>& matcher2)
06244 : matcher1_(matcher1), matcher2_(matcher2) {}
06245
06246 virtual void DescribeTo(::std::ostream* os) const {
06247 *os << "(";
06248 matcher1_.DescribeTo(os);
06249 *os << ") or (";
06250 matcher2_.DescribeTo(os);
06251 *os << ")";
06252 }
06253
06254 virtual void DescribeNegationTo(::std::ostream* os) const {
06255 *os << "(";
06256 matcher1_.DescribeNegationTo(os);
06257 *os << ") and (";
06258 matcher2_.DescribeNegationTo(os);
06259 *os << ")";
06260 }
06261
06262 virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {
06263
06264
06265 StringMatchResultListener listener1;
06266 if (matcher1_.MatchAndExplain(x, &listener1)) {
06267 *listener << listener1.str();
06268 return true;
06269 }
06270
06271 StringMatchResultListener listener2;
06272 if (matcher2_.MatchAndExplain(x, &listener2)) {
06273 *listener << listener2.str();
06274 return true;
06275 }
06276
06277
06278 const internal::string s1 = listener1.str();
06279 const internal::string s2 = listener2.str();
06280
06281 if (s1 == "") {
06282 *listener << s2;
06283 } else {
06284 *listener << s1;
06285 if (s2 != "") {
06286 *listener << ", and " << s2;
06287 }
06288 }
06289 return false;
06290 }
06291
06292 private:
06293 const Matcher<T> matcher1_;
06294 const Matcher<T> matcher2_;
06295
06296 GTEST_DISALLOW_ASSIGN_(EitherOfMatcherImpl);
06297 };
06298
06299 #if GTEST_LANG_CXX11
06300
06301 template <typename... Args>
06302 using AnyOfMatcher = VariadicMatcher<EitherOfMatcherImpl, Args...>;
06303
06304 #endif // GTEST_LANG_CXX11
06305
06306
06307
06308
06309 template <typename Matcher1, typename Matcher2>
06310 class EitherOfMatcher {
06311 public:
06312 EitherOfMatcher(Matcher1 matcher1, Matcher2 matcher2)
06313 : matcher1_(matcher1), matcher2_(matcher2) {}
06314
06315
06316
06317
06318 template <typename T>
06319 operator Matcher<T>() const {
06320 return Matcher<T>(new EitherOfMatcherImpl<T>(
06321 SafeMatcherCast<T>(matcher1_), SafeMatcherCast<T>(matcher2_)));
06322 }
06323
06324 private:
06325 Matcher1 matcher1_;
06326 Matcher2 matcher2_;
06327
06328 GTEST_DISALLOW_ASSIGN_(EitherOfMatcher);
06329 };
06330
06331
06332
06333 template <typename Predicate>
06334 class TrulyMatcher {
06335 public:
06336 explicit TrulyMatcher(Predicate pred) : predicate_(pred) {}
06337
06338
06339
06340
06341
06342 template <typename T>
06343 bool MatchAndExplain(T& x,
06344 MatchResultListener* ) const {
06345
06346
06347
06348
06349
06350
06351 if (predicate_(x))
06352 return true;
06353 return false;
06354 }
06355
06356 void DescribeTo(::std::ostream* os) const {
06357 *os << "satisfies the given predicate";
06358 }
06359
06360 void DescribeNegationTo(::std::ostream* os) const {
06361 *os << "doesn't satisfy the given predicate";
06362 }
06363
06364 private:
06365 Predicate predicate_;
06366
06367 GTEST_DISALLOW_ASSIGN_(TrulyMatcher);
06368 };
06369
06370
06371
06372 template <typename M>
06373 class MatcherAsPredicate {
06374 public:
06375 explicit MatcherAsPredicate(M matcher) : matcher_(matcher) {}
06376
06377
06378
06379
06380
06381
06382
06383 template <typename T>
06384 bool operator()(const T& x) const {
06385
06386
06387
06388
06389
06390
06391
06392
06393
06394
06395
06396
06397
06398
06399 return MatcherCast<const T&>(matcher_).Matches(x);
06400 }
06401
06402 private:
06403 M matcher_;
06404
06405 GTEST_DISALLOW_ASSIGN_(MatcherAsPredicate);
06406 };
06407
06408
06409
06410 template <typename M>
06411 class PredicateFormatterFromMatcher {
06412 public:
06413 explicit PredicateFormatterFromMatcher(const M& m) : matcher_(m) {}
06414
06415
06416
06417
06418 template <typename T>
06419 AssertionResult operator()(const char* value_text, const T& x) const {
06420
06421
06422
06423
06424
06425
06426
06427
06428
06429
06430
06431 const Matcher<const T&> matcher = SafeMatcherCast<const T&>(matcher_);
06432 StringMatchResultListener listener;
06433 if (MatchPrintAndExplain(x, matcher, &listener))
06434 return AssertionSuccess();
06435
06436 ::std::stringstream ss;
06437 ss << "Value of: " << value_text << "\n"
06438 << "Expected: ";
06439 matcher.DescribeTo(&ss);
06440 ss << "\n Actual: " << listener.str();
06441 return AssertionFailure() << ss.str();
06442 }
06443
06444 private:
06445 const M matcher_;
06446
06447 GTEST_DISALLOW_ASSIGN_(PredicateFormatterFromMatcher);
06448 };
06449
06450
06451
06452
06453 template <typename M>
06454 inline PredicateFormatterFromMatcher<M>
06455 MakePredicateFormatterFromMatcher(const M& matcher) {
06456 return PredicateFormatterFromMatcher<M>(matcher);
06457 }
06458
06459
06460
06461
06462
06463 template <typename FloatType>
06464 class FloatingEqMatcher {
06465 public:
06466
06467
06468
06469
06470
06471
06472 FloatingEqMatcher(FloatType rhs, bool nan_eq_nan) :
06473 rhs_(rhs), nan_eq_nan_(nan_eq_nan), max_abs_error_(-1) {
06474 }
06475
06476
06477
06478
06479 FloatingEqMatcher(FloatType rhs, bool nan_eq_nan, FloatType max_abs_error) :
06480 rhs_(rhs), nan_eq_nan_(nan_eq_nan), max_abs_error_(max_abs_error) {
06481 GTEST_CHECK_(max_abs_error >= 0)
06482 << ", where max_abs_error is" << max_abs_error;
06483 }
06484
06485
06486 template <typename T>
06487 class Impl : public MatcherInterface<T> {
06488 public:
06489 Impl(FloatType rhs, bool nan_eq_nan, FloatType max_abs_error) :
06490 rhs_(rhs), nan_eq_nan_(nan_eq_nan), max_abs_error_(max_abs_error) {}
06491
06492 virtual bool MatchAndExplain(T value,
06493 MatchResultListener* ) const {
06494 const FloatingPoint<FloatType> lhs(value), rhs(rhs_);
06495
06496
06497 if (lhs.is_nan() || rhs.is_nan()) {
06498 if (lhs.is_nan() && rhs.is_nan()) {
06499 return nan_eq_nan_;
06500 }
06501
06502 return false;
06503 }
06504 if (HasMaxAbsError()) {
06505
06506
06507
06508
06509 return value == rhs_ || fabs(value - rhs_) <= max_abs_error_;
06510 } else {
06511 return lhs.AlmostEquals(rhs);
06512 }
06513 }
06514
06515 virtual void DescribeTo(::std::ostream* os) const {
06516
06517
06518
06519 const ::std::streamsize old_precision = os->precision(
06520 ::std::numeric_limits<FloatType>::digits10 + 2);
06521 if (FloatingPoint<FloatType>(rhs_).is_nan()) {
06522 if (nan_eq_nan_) {
06523 *os << "is NaN";
06524 } else {
06525 *os << "never matches";
06526 }
06527 } else {
06528 *os << "is approximately " << rhs_;
06529 if (HasMaxAbsError()) {
06530 *os << " (absolute error <= " << max_abs_error_ << ")";
06531 }
06532 }
06533 os->precision(old_precision);
06534 }
06535
06536 virtual void DescribeNegationTo(::std::ostream* os) const {
06537
06538 const ::std::streamsize old_precision = os->precision(
06539 ::std::numeric_limits<FloatType>::digits10 + 2);
06540 if (FloatingPoint<FloatType>(rhs_).is_nan()) {
06541 if (nan_eq_nan_) {
06542 *os << "isn't NaN";
06543 } else {
06544 *os << "is anything";
06545 }
06546 } else {
06547 *os << "isn't approximately " << rhs_;
06548 if (HasMaxAbsError()) {
06549 *os << " (absolute error > " << max_abs_error_ << ")";
06550 }
06551 }
06552
06553 os->precision(old_precision);
06554 }
06555
06556 private:
06557 bool HasMaxAbsError() const {
06558 return max_abs_error_ >= 0;
06559 }
06560
06561 const FloatType rhs_;
06562 const bool nan_eq_nan_;
06563
06564 const FloatType max_abs_error_;
06565
06566 GTEST_DISALLOW_ASSIGN_(Impl);
06567 };
06568
06569
06570
06571
06572
06573
06574
06575 operator Matcher<FloatType>() const {
06576 return MakeMatcher(new Impl<FloatType>(rhs_, nan_eq_nan_, max_abs_error_));
06577 }
06578
06579 operator Matcher<const FloatType&>() const {
06580 return MakeMatcher(
06581 new Impl<const FloatType&>(rhs_, nan_eq_nan_, max_abs_error_));
06582 }
06583
06584 operator Matcher<FloatType&>() const {
06585 return MakeMatcher(new Impl<FloatType&>(rhs_, nan_eq_nan_, max_abs_error_));
06586 }
06587
06588 private:
06589 const FloatType rhs_;
06590 const bool nan_eq_nan_;
06591
06592 const FloatType max_abs_error_;
06593
06594 GTEST_DISALLOW_ASSIGN_(FloatingEqMatcher);
06595 };
06596
06597
06598
06599 template <typename InnerMatcher>
06600 class PointeeMatcher {
06601 public:
06602 explicit PointeeMatcher(const InnerMatcher& matcher) : matcher_(matcher) {}
06603
06604
06605
06606
06607
06608
06609
06610
06611
06612 template <typename Pointer>
06613 operator Matcher<Pointer>() const {
06614 return MakeMatcher(new Impl<Pointer>(matcher_));
06615 }
06616
06617 private:
06618
06619 template <typename Pointer>
06620 class Impl : public MatcherInterface<Pointer> {
06621 public:
06622 typedef typename PointeeOf<GTEST_REMOVE_CONST_(
06623 GTEST_REMOVE_REFERENCE_(Pointer))>::type Pointee;
06624
06625 explicit Impl(const InnerMatcher& matcher)
06626 : matcher_(MatcherCast<const Pointee&>(matcher)) {}
06627
06628 virtual void DescribeTo(::std::ostream* os) const {
06629 *os << "points to a value that ";
06630 matcher_.DescribeTo(os);
06631 }
06632
06633 virtual void DescribeNegationTo(::std::ostream* os) const {
06634 *os << "does not point to a value that ";
06635 matcher_.DescribeTo(os);
06636 }
06637
06638 virtual bool MatchAndExplain(Pointer pointer,
06639 MatchResultListener* listener) const {
06640 if (GetRawPointer(pointer) == NULL)
06641 return false;
06642
06643 *listener << "which points to ";
06644 return MatchPrintAndExplain(*pointer, matcher_, listener);
06645 }
06646
06647 private:
06648 const Matcher<const Pointee&> matcher_;
06649
06650 GTEST_DISALLOW_ASSIGN_(Impl);
06651 };
06652
06653 const InnerMatcher matcher_;
06654
06655 GTEST_DISALLOW_ASSIGN_(PointeeMatcher);
06656 };
06657
06658
06659
06660 template <typename Class, typename FieldType>
06661 class FieldMatcher {
06662 public:
06663 FieldMatcher(FieldType Class::*field,
06664 const Matcher<const FieldType&>& matcher)
06665 : field_(field), matcher_(matcher) {}
06666
06667 void DescribeTo(::std::ostream* os) const {
06668 *os << "is an object whose given field ";
06669 matcher_.DescribeTo(os);
06670 }
06671
06672 void DescribeNegationTo(::std::ostream* os) const {
06673 *os << "is an object whose given field ";
06674 matcher_.DescribeNegationTo(os);
06675 }
06676
06677 template <typename T>
06678 bool MatchAndExplain(const T& value, MatchResultListener* listener) const {
06679 return MatchAndExplainImpl(
06680 typename ::testing::internal::
06681 is_pointer<GTEST_REMOVE_CONST_(T)>::type(),
06682 value, listener);
06683 }
06684
06685 private:
06686
06687
06688
06689 bool MatchAndExplainImpl(false_type , const Class& obj,
06690 MatchResultListener* listener) const {
06691 *listener << "whose given field is ";
06692 return MatchPrintAndExplain(obj.*field_, matcher_, listener);
06693 }
06694
06695 bool MatchAndExplainImpl(true_type , const Class* p,
06696 MatchResultListener* listener) const {
06697 if (p == NULL)
06698 return false;
06699
06700 *listener << "which points to an object ";
06701
06702
06703
06704 return MatchAndExplainImpl(false_type(), *p, listener);
06705 }
06706
06707 const FieldType Class::*field_;
06708 const Matcher<const FieldType&> matcher_;
06709
06710 GTEST_DISALLOW_ASSIGN_(FieldMatcher);
06711 };
06712
06713
06714
06715 template <typename Class, typename PropertyType>
06716 class PropertyMatcher {
06717 public:
06718
06719
06720
06721
06722 typedef GTEST_REFERENCE_TO_CONST_(PropertyType) RefToConstProperty;
06723
06724 PropertyMatcher(PropertyType (Class::*property)() const,
06725 const Matcher<RefToConstProperty>& matcher)
06726 : property_(property), matcher_(matcher) {}
06727
06728 void DescribeTo(::std::ostream* os) const {
06729 *os << "is an object whose given property ";
06730 matcher_.DescribeTo(os);
06731 }
06732
06733 void DescribeNegationTo(::std::ostream* os) const {
06734 *os << "is an object whose given property ";
06735 matcher_.DescribeNegationTo(os);
06736 }
06737
06738 template <typename T>
06739 bool MatchAndExplain(const T&value, MatchResultListener* listener) const {
06740 return MatchAndExplainImpl(
06741 typename ::testing::internal::
06742 is_pointer<GTEST_REMOVE_CONST_(T)>::type(),
06743 value, listener);
06744 }
06745
06746 private:
06747
06748
06749
06750 bool MatchAndExplainImpl(false_type , const Class& obj,
06751 MatchResultListener* listener) const {
06752 *listener << "whose given property is ";
06753
06754
06755 RefToConstProperty result = (obj.*property_)();
06756 return MatchPrintAndExplain(result, matcher_, listener);
06757 }
06758
06759 bool MatchAndExplainImpl(true_type , const Class* p,
06760 MatchResultListener* listener) const {
06761 if (p == NULL)
06762 return false;
06763
06764 *listener << "which points to an object ";
06765
06766
06767
06768 return MatchAndExplainImpl(false_type(), *p, listener);
06769 }
06770
06771 PropertyType (Class::*property_)() const;
06772 const Matcher<RefToConstProperty> matcher_;
06773
06774 GTEST_DISALLOW_ASSIGN_(PropertyMatcher);
06775 };
06776
06777
06778
06779
06780
06781 template <typename Functor>
06782 struct CallableTraits {
06783 typedef typename Functor::result_type ResultType;
06784 typedef Functor StorageType;
06785
06786 static void CheckIsValid(Functor ) {}
06787 template <typename T>
06788 static ResultType Invoke(Functor f, T arg) { return f(arg); }
06789 };
06790
06791
06792 template <typename ArgType, typename ResType>
06793 struct CallableTraits<ResType(*)(ArgType)> {
06794 typedef ResType ResultType;
06795 typedef ResType(*StorageType)(ArgType);
06796
06797 static void CheckIsValid(ResType(*f)(ArgType)) {
06798 GTEST_CHECK_(f != NULL)
06799 << "NULL function pointer is passed into ResultOf().";
06800 }
06801 template <typename T>
06802 static ResType Invoke(ResType(*f)(ArgType), T arg) {
06803 return (*f)(arg);
06804 }
06805 };
06806
06807
06808
06809 template <typename Callable>
06810 class ResultOfMatcher {
06811 public:
06812 typedef typename CallableTraits<Callable>::ResultType ResultType;
06813
06814 ResultOfMatcher(Callable callable, const Matcher<ResultType>& matcher)
06815 : callable_(callable), matcher_(matcher) {
06816 CallableTraits<Callable>::CheckIsValid(callable_);
06817 }
06818
06819 template <typename T>
06820 operator Matcher<T>() const {
06821 return Matcher<T>(new Impl<T>(callable_, matcher_));
06822 }
06823
06824 private:
06825 typedef typename CallableTraits<Callable>::StorageType CallableStorageType;
06826
06827 template <typename T>
06828 class Impl : public MatcherInterface<T> {
06829 public:
06830 Impl(CallableStorageType callable, const Matcher<ResultType>& matcher)
06831 : callable_(callable), matcher_(matcher) {}
06832
06833 virtual void DescribeTo(::std::ostream* os) const {
06834 *os << "is mapped by the given callable to a value that ";
06835 matcher_.DescribeTo(os);
06836 }
06837
06838 virtual void DescribeNegationTo(::std::ostream* os) const {
06839 *os << "is mapped by the given callable to a value that ";
06840 matcher_.DescribeNegationTo(os);
06841 }
06842
06843 virtual bool MatchAndExplain(T obj, MatchResultListener* listener) const {
06844 *listener << "which is mapped by the given callable to ";
06845
06846
06847 ResultType result =
06848 CallableTraits<Callable>::template Invoke<T>(callable_, obj);
06849 return MatchPrintAndExplain(result, matcher_, listener);
06850 }
06851
06852 private:
06853
06854
06855
06856
06857
06858 mutable CallableStorageType callable_;
06859 const Matcher<ResultType> matcher_;
06860
06861 GTEST_DISALLOW_ASSIGN_(Impl);
06862 };
06863
06864 const CallableStorageType callable_;
06865 const Matcher<ResultType> matcher_;
06866
06867 GTEST_DISALLOW_ASSIGN_(ResultOfMatcher);
06868 };
06869
06870
06871 template <typename SizeMatcher>
06872 class SizeIsMatcher {
06873 public:
06874 explicit SizeIsMatcher(const SizeMatcher& size_matcher)
06875 : size_matcher_(size_matcher) {
06876 }
06877
06878 template <typename Container>
06879 operator Matcher<Container>() const {
06880 return MakeMatcher(new Impl<Container>(size_matcher_));
06881 }
06882
06883 template <typename Container>
06884 class Impl : public MatcherInterface<Container> {
06885 public:
06886 typedef internal::StlContainerView<
06887 GTEST_REMOVE_REFERENCE_AND_CONST_(Container)> ContainerView;
06888 typedef typename ContainerView::type::size_type SizeType;
06889 explicit Impl(const SizeMatcher& size_matcher)
06890 : size_matcher_(MatcherCast<SizeType>(size_matcher)) {}
06891
06892 virtual void DescribeTo(::std::ostream* os) const {
06893 *os << "size ";
06894 size_matcher_.DescribeTo(os);
06895 }
06896 virtual void DescribeNegationTo(::std::ostream* os) const {
06897 *os << "size ";
06898 size_matcher_.DescribeNegationTo(os);
06899 }
06900
06901 virtual bool MatchAndExplain(Container container,
06902 MatchResultListener* listener) const {
06903 SizeType size = container.size();
06904 StringMatchResultListener size_listener;
06905 const bool result = size_matcher_.MatchAndExplain(size, &size_listener);
06906 *listener
06907 << "whose size " << size << (result ? " matches" : " doesn't match");
06908 PrintIfNotEmpty(size_listener.str(), listener->stream());
06909 return result;
06910 }
06911
06912 private:
06913 const Matcher<SizeType> size_matcher_;
06914 GTEST_DISALLOW_ASSIGN_(Impl);
06915 };
06916
06917 private:
06918 const SizeMatcher size_matcher_;
06919 GTEST_DISALLOW_ASSIGN_(SizeIsMatcher);
06920 };
06921
06922
06923
06924
06925
06926
06927
06928
06929
06930
06931
06932 template <typename Container>
06933 class ContainerEqMatcher {
06934 public:
06935 typedef internal::StlContainerView<Container> View;
06936 typedef typename View::type StlContainer;
06937 typedef typename View::const_reference StlContainerReference;
06938
06939
06940
06941 explicit ContainerEqMatcher(const Container& rhs) : rhs_(View::Copy(rhs)) {
06942
06943
06944 (void)testing::StaticAssertTypeEq<Container,
06945 GTEST_REMOVE_REFERENCE_AND_CONST_(Container)>();
06946 }
06947
06948 void DescribeTo(::std::ostream* os) const {
06949 *os << "equals ";
06950 UniversalPrint(rhs_, os);
06951 }
06952 void DescribeNegationTo(::std::ostream* os) const {
06953 *os << "does not equal ";
06954 UniversalPrint(rhs_, os);
06955 }
06956
06957 template <typename LhsContainer>
06958 bool MatchAndExplain(const LhsContainer& lhs,
06959 MatchResultListener* listener) const {
06960
06961
06962 typedef internal::StlContainerView<GTEST_REMOVE_CONST_(LhsContainer)>
06963 LhsView;
06964 typedef typename LhsView::type LhsStlContainer;
06965 StlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);
06966 if (lhs_stl_container == rhs_)
06967 return true;
06968
06969 ::std::ostream* const os = listener->stream();
06970 if (os != NULL) {
06971
06972 bool printed_header = false;
06973 for (typename LhsStlContainer::const_iterator it =
06974 lhs_stl_container.begin();
06975 it != lhs_stl_container.end(); ++it) {
06976 if (internal::ArrayAwareFind(rhs_.begin(), rhs_.end(), *it) ==
06977 rhs_.end()) {
06978 if (printed_header) {
06979 *os << ", ";
06980 } else {
06981 *os << "which has these unexpected elements: ";
06982 printed_header = true;
06983 }
06984 UniversalPrint(*it, os);
06985 }
06986 }
06987
06988
06989 bool printed_header2 = false;
06990 for (typename StlContainer::const_iterator it = rhs_.begin();
06991 it != rhs_.end(); ++it) {
06992 if (internal::ArrayAwareFind(
06993 lhs_stl_container.begin(), lhs_stl_container.end(), *it) ==
06994 lhs_stl_container.end()) {
06995 if (printed_header2) {
06996 *os << ", ";
06997 } else {
06998 *os << (printed_header ? ",\nand" : "which")
06999 << " doesn't have these expected elements: ";
07000 printed_header2 = true;
07001 }
07002 UniversalPrint(*it, os);
07003 }
07004 }
07005 }
07006
07007 return false;
07008 }
07009
07010 private:
07011 const StlContainer rhs_;
07012
07013 GTEST_DISALLOW_ASSIGN_(ContainerEqMatcher);
07014 };
07015
07016
07017 struct LessComparator {
07018 template <typename T, typename U>
07019 bool operator()(const T& lhs, const U& rhs) const { return lhs < rhs; }
07020 };
07021
07022
07023 template <typename Comparator, typename ContainerMatcher>
07024 class WhenSortedByMatcher {
07025 public:
07026 WhenSortedByMatcher(const Comparator& comparator,
07027 const ContainerMatcher& matcher)
07028 : comparator_(comparator), matcher_(matcher) {}
07029
07030 template <typename LhsContainer>
07031 operator Matcher<LhsContainer>() const {
07032 return MakeMatcher(new Impl<LhsContainer>(comparator_, matcher_));
07033 }
07034
07035 template <typename LhsContainer>
07036 class Impl : public MatcherInterface<LhsContainer> {
07037 public:
07038 typedef internal::StlContainerView<
07039 GTEST_REMOVE_REFERENCE_AND_CONST_(LhsContainer)> LhsView;
07040 typedef typename LhsView::type LhsStlContainer;
07041 typedef typename LhsView::const_reference LhsStlContainerReference;
07042
07043
07044 typedef typename RemoveConstFromKey<
07045 typename LhsStlContainer::value_type>::type LhsValue;
07046
07047 Impl(const Comparator& comparator, const ContainerMatcher& matcher)
07048 : comparator_(comparator), matcher_(matcher) {}
07049
07050 virtual void DescribeTo(::std::ostream* os) const {
07051 *os << "(when sorted) ";
07052 matcher_.DescribeTo(os);
07053 }
07054
07055 virtual void DescribeNegationTo(::std::ostream* os) const {
07056 *os << "(when sorted) ";
07057 matcher_.DescribeNegationTo(os);
07058 }
07059
07060 virtual bool MatchAndExplain(LhsContainer lhs,
07061 MatchResultListener* listener) const {
07062 LhsStlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);
07063 ::std::vector<LhsValue> sorted_container(lhs_stl_container.begin(),
07064 lhs_stl_container.end());
07065 ::std::sort(
07066 sorted_container.begin(), sorted_container.end(), comparator_);
07067
07068 if (!listener->IsInterested()) {
07069
07070
07071 return matcher_.Matches(sorted_container);
07072 }
07073
07074 *listener << "which is ";
07075 UniversalPrint(sorted_container, listener->stream());
07076 *listener << " when sorted";
07077
07078 StringMatchResultListener inner_listener;
07079 const bool match = matcher_.MatchAndExplain(sorted_container,
07080 &inner_listener);
07081 PrintIfNotEmpty(inner_listener.str(), listener->stream());
07082 return match;
07083 }
07084
07085 private:
07086 const Comparator comparator_;
07087 const Matcher<const ::std::vector<LhsValue>&> matcher_;
07088
07089 GTEST_DISALLOW_COPY_AND_ASSIGN_(Impl);
07090 };
07091
07092 private:
07093 const Comparator comparator_;
07094 const ContainerMatcher matcher_;
07095
07096 GTEST_DISALLOW_ASSIGN_(WhenSortedByMatcher);
07097 };
07098
07099
07100
07101
07102
07103 template <typename TupleMatcher, typename RhsContainer>
07104 class PointwiseMatcher {
07105 public:
07106 typedef internal::StlContainerView<RhsContainer> RhsView;
07107 typedef typename RhsView::type RhsStlContainer;
07108 typedef typename RhsStlContainer::value_type RhsValue;
07109
07110
07111
07112 PointwiseMatcher(const TupleMatcher& tuple_matcher, const RhsContainer& rhs)
07113 : tuple_matcher_(tuple_matcher), rhs_(RhsView::Copy(rhs)) {
07114
07115
07116 (void)testing::StaticAssertTypeEq<RhsContainer,
07117 GTEST_REMOVE_REFERENCE_AND_CONST_(RhsContainer)>();
07118 }
07119
07120 template <typename LhsContainer>
07121 operator Matcher<LhsContainer>() const {
07122 return MakeMatcher(new Impl<LhsContainer>(tuple_matcher_, rhs_));
07123 }
07124
07125 template <typename LhsContainer>
07126 class Impl : public MatcherInterface<LhsContainer> {
07127 public:
07128 typedef internal::StlContainerView<
07129 GTEST_REMOVE_REFERENCE_AND_CONST_(LhsContainer)> LhsView;
07130 typedef typename LhsView::type LhsStlContainer;
07131 typedef typename LhsView::const_reference LhsStlContainerReference;
07132 typedef typename LhsStlContainer::value_type LhsValue;
07133
07134
07135
07136
07137 typedef ::std::tr1::tuple<const LhsValue&, const RhsValue&> InnerMatcherArg;
07138
07139 Impl(const TupleMatcher& tuple_matcher, const RhsStlContainer& rhs)
07140
07141 : mono_tuple_matcher_(SafeMatcherCast<InnerMatcherArg>(tuple_matcher)),
07142 rhs_(rhs) {}
07143
07144 virtual void DescribeTo(::std::ostream* os) const {
07145 *os << "contains " << rhs_.size()
07146 << " values, where each value and its corresponding value in ";
07147 UniversalPrinter<RhsStlContainer>::Print(rhs_, os);
07148 *os << " ";
07149 mono_tuple_matcher_.DescribeTo(os);
07150 }
07151 virtual void DescribeNegationTo(::std::ostream* os) const {
07152 *os << "doesn't contain exactly " << rhs_.size()
07153 << " values, or contains a value x at some index i"
07154 << " where x and the i-th value of ";
07155 UniversalPrint(rhs_, os);
07156 *os << " ";
07157 mono_tuple_matcher_.DescribeNegationTo(os);
07158 }
07159
07160 virtual bool MatchAndExplain(LhsContainer lhs,
07161 MatchResultListener* listener) const {
07162 LhsStlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);
07163 const size_t actual_size = lhs_stl_container.size();
07164 if (actual_size != rhs_.size()) {
07165 *listener << "which contains " << actual_size << " values";
07166 return false;
07167 }
07168
07169 typename LhsStlContainer::const_iterator left = lhs_stl_container.begin();
07170 typename RhsStlContainer::const_iterator right = rhs_.begin();
07171 for (size_t i = 0; i != actual_size; ++i, ++left, ++right) {
07172 const InnerMatcherArg value_pair(*left, *right);
07173
07174 if (listener->IsInterested()) {
07175 StringMatchResultListener inner_listener;
07176 if (!mono_tuple_matcher_.MatchAndExplain(
07177 value_pair, &inner_listener)) {
07178 *listener << "where the value pair (";
07179 UniversalPrint(*left, listener->stream());
07180 *listener << ", ";
07181 UniversalPrint(*right, listener->stream());
07182 *listener << ") at index #" << i << " don't match";
07183 PrintIfNotEmpty(inner_listener.str(), listener->stream());
07184 return false;
07185 }
07186 } else {
07187 if (!mono_tuple_matcher_.Matches(value_pair))
07188 return false;
07189 }
07190 }
07191
07192 return true;
07193 }
07194
07195 private:
07196 const Matcher<InnerMatcherArg> mono_tuple_matcher_;
07197 const RhsStlContainer rhs_;
07198
07199 GTEST_DISALLOW_ASSIGN_(Impl);
07200 };
07201
07202 private:
07203 const TupleMatcher tuple_matcher_;
07204 const RhsStlContainer rhs_;
07205
07206 GTEST_DISALLOW_ASSIGN_(PointwiseMatcher);
07207 };
07208
07209
07210 template <typename Container>
07211 class QuantifierMatcherImpl : public MatcherInterface<Container> {
07212 public:
07213 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
07214 typedef StlContainerView<RawContainer> View;
07215 typedef typename View::type StlContainer;
07216 typedef typename View::const_reference StlContainerReference;
07217 typedef typename StlContainer::value_type Element;
07218
07219 template <typename InnerMatcher>
07220 explicit QuantifierMatcherImpl(InnerMatcher inner_matcher)
07221 : inner_matcher_(
07222 testing::SafeMatcherCast<const Element&>(inner_matcher)) {}
07223
07224
07225
07226
07227 bool MatchAndExplainImpl(bool all_elements_should_match,
07228 Container container,
07229 MatchResultListener* listener) const {
07230 StlContainerReference stl_container = View::ConstReference(container);
07231 size_t i = 0;
07232 for (typename StlContainer::const_iterator it = stl_container.begin();
07233 it != stl_container.end(); ++it, ++i) {
07234 StringMatchResultListener inner_listener;
07235 const bool matches = inner_matcher_.MatchAndExplain(*it, &inner_listener);
07236
07237 if (matches != all_elements_should_match) {
07238 *listener << "whose element #" << i
07239 << (matches ? " matches" : " doesn't match");
07240 PrintIfNotEmpty(inner_listener.str(), listener->stream());
07241 return !all_elements_should_match;
07242 }
07243 }
07244 return all_elements_should_match;
07245 }
07246
07247 protected:
07248 const Matcher<const Element&> inner_matcher_;
07249
07250 GTEST_DISALLOW_ASSIGN_(QuantifierMatcherImpl);
07251 };
07252
07253
07254
07255 template <typename Container>
07256 class ContainsMatcherImpl : public QuantifierMatcherImpl<Container> {
07257 public:
07258 template <typename InnerMatcher>
07259 explicit ContainsMatcherImpl(InnerMatcher inner_matcher)
07260 : QuantifierMatcherImpl<Container>(inner_matcher) {}
07261
07262
07263 virtual void DescribeTo(::std::ostream* os) const {
07264 *os << "contains at least one element that ";
07265 this->inner_matcher_.DescribeTo(os);
07266 }
07267
07268 virtual void DescribeNegationTo(::std::ostream* os) const {
07269 *os << "doesn't contain any element that ";
07270 this->inner_matcher_.DescribeTo(os);
07271 }
07272
07273 virtual bool MatchAndExplain(Container container,
07274 MatchResultListener* listener) const {
07275 return this->MatchAndExplainImpl(false, container, listener);
07276 }
07277
07278 private:
07279 GTEST_DISALLOW_ASSIGN_(ContainsMatcherImpl);
07280 };
07281
07282
07283
07284 template <typename Container>
07285 class EachMatcherImpl : public QuantifierMatcherImpl<Container> {
07286 public:
07287 template <typename InnerMatcher>
07288 explicit EachMatcherImpl(InnerMatcher inner_matcher)
07289 : QuantifierMatcherImpl<Container>(inner_matcher) {}
07290
07291
07292 virtual void DescribeTo(::std::ostream* os) const {
07293 *os << "only contains elements that ";
07294 this->inner_matcher_.DescribeTo(os);
07295 }
07296
07297 virtual void DescribeNegationTo(::std::ostream* os) const {
07298 *os << "contains some element that ";
07299 this->inner_matcher_.DescribeNegationTo(os);
07300 }
07301
07302 virtual bool MatchAndExplain(Container container,
07303 MatchResultListener* listener) const {
07304 return this->MatchAndExplainImpl(true, container, listener);
07305 }
07306
07307 private:
07308 GTEST_DISALLOW_ASSIGN_(EachMatcherImpl);
07309 };
07310
07311
07312 template <typename M>
07313 class ContainsMatcher {
07314 public:
07315 explicit ContainsMatcher(M m) : inner_matcher_(m) {}
07316
07317 template <typename Container>
07318 operator Matcher<Container>() const {
07319 return MakeMatcher(new ContainsMatcherImpl<Container>(inner_matcher_));
07320 }
07321
07322 private:
07323 const M inner_matcher_;
07324
07325 GTEST_DISALLOW_ASSIGN_(ContainsMatcher);
07326 };
07327
07328
07329 template <typename M>
07330 class EachMatcher {
07331 public:
07332 explicit EachMatcher(M m) : inner_matcher_(m) {}
07333
07334 template <typename Container>
07335 operator Matcher<Container>() const {
07336 return MakeMatcher(new EachMatcherImpl<Container>(inner_matcher_));
07337 }
07338
07339 private:
07340 const M inner_matcher_;
07341
07342 GTEST_DISALLOW_ASSIGN_(EachMatcher);
07343 };
07344
07345
07346
07347
07348
07349 template <typename PairType>
07350 class KeyMatcherImpl : public MatcherInterface<PairType> {
07351 public:
07352 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(PairType) RawPairType;
07353 typedef typename RawPairType::first_type KeyType;
07354
07355 template <typename InnerMatcher>
07356 explicit KeyMatcherImpl(InnerMatcher inner_matcher)
07357 : inner_matcher_(
07358 testing::SafeMatcherCast<const KeyType&>(inner_matcher)) {
07359 }
07360
07361
07362 virtual bool MatchAndExplain(PairType key_value,
07363 MatchResultListener* listener) const {
07364 StringMatchResultListener inner_listener;
07365 const bool match = inner_matcher_.MatchAndExplain(key_value.first,
07366 &inner_listener);
07367 const internal::string explanation = inner_listener.str();
07368 if (explanation != "") {
07369 *listener << "whose first field is a value " << explanation;
07370 }
07371 return match;
07372 }
07373
07374
07375 virtual void DescribeTo(::std::ostream* os) const {
07376 *os << "has a key that ";
07377 inner_matcher_.DescribeTo(os);
07378 }
07379
07380
07381 virtual void DescribeNegationTo(::std::ostream* os) const {
07382 *os << "doesn't have a key that ";
07383 inner_matcher_.DescribeTo(os);
07384 }
07385
07386 private:
07387 const Matcher<const KeyType&> inner_matcher_;
07388
07389 GTEST_DISALLOW_ASSIGN_(KeyMatcherImpl);
07390 };
07391
07392
07393 template <typename M>
07394 class KeyMatcher {
07395 public:
07396 explicit KeyMatcher(M m) : matcher_for_key_(m) {}
07397
07398 template <typename PairType>
07399 operator Matcher<PairType>() const {
07400 return MakeMatcher(new KeyMatcherImpl<PairType>(matcher_for_key_));
07401 }
07402
07403 private:
07404 const M matcher_for_key_;
07405
07406 GTEST_DISALLOW_ASSIGN_(KeyMatcher);
07407 };
07408
07409
07410
07411 template <typename PairType>
07412 class PairMatcherImpl : public MatcherInterface<PairType> {
07413 public:
07414 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(PairType) RawPairType;
07415 typedef typename RawPairType::first_type FirstType;
07416 typedef typename RawPairType::second_type SecondType;
07417
07418 template <typename FirstMatcher, typename SecondMatcher>
07419 PairMatcherImpl(FirstMatcher first_matcher, SecondMatcher second_matcher)
07420 : first_matcher_(
07421 testing::SafeMatcherCast<const FirstType&>(first_matcher)),
07422 second_matcher_(
07423 testing::SafeMatcherCast<const SecondType&>(second_matcher)) {
07424 }
07425
07426
07427 virtual void DescribeTo(::std::ostream* os) const {
07428 *os << "has a first field that ";
07429 first_matcher_.DescribeTo(os);
07430 *os << ", and has a second field that ";
07431 second_matcher_.DescribeTo(os);
07432 }
07433
07434
07435 virtual void DescribeNegationTo(::std::ostream* os) const {
07436 *os << "has a first field that ";
07437 first_matcher_.DescribeNegationTo(os);
07438 *os << ", or has a second field that ";
07439 second_matcher_.DescribeNegationTo(os);
07440 }
07441
07442
07443
07444 virtual bool MatchAndExplain(PairType a_pair,
07445 MatchResultListener* listener) const {
07446 if (!listener->IsInterested()) {
07447
07448
07449 return first_matcher_.Matches(a_pair.first) &&
07450 second_matcher_.Matches(a_pair.second);
07451 }
07452 StringMatchResultListener first_inner_listener;
07453 if (!first_matcher_.MatchAndExplain(a_pair.first,
07454 &first_inner_listener)) {
07455 *listener << "whose first field does not match";
07456 PrintIfNotEmpty(first_inner_listener.str(), listener->stream());
07457 return false;
07458 }
07459 StringMatchResultListener second_inner_listener;
07460 if (!second_matcher_.MatchAndExplain(a_pair.second,
07461 &second_inner_listener)) {
07462 *listener << "whose second field does not match";
07463 PrintIfNotEmpty(second_inner_listener.str(), listener->stream());
07464 return false;
07465 }
07466 ExplainSuccess(first_inner_listener.str(), second_inner_listener.str(),
07467 listener);
07468 return true;
07469 }
07470
07471 private:
07472 void ExplainSuccess(const internal::string& first_explanation,
07473 const internal::string& second_explanation,
07474 MatchResultListener* listener) const {
07475 *listener << "whose both fields match";
07476 if (first_explanation != "") {
07477 *listener << ", where the first field is a value " << first_explanation;
07478 }
07479 if (second_explanation != "") {
07480 *listener << ", ";
07481 if (first_explanation != "") {
07482 *listener << "and ";
07483 } else {
07484 *listener << "where ";
07485 }
07486 *listener << "the second field is a value " << second_explanation;
07487 }
07488 }
07489
07490 const Matcher<const FirstType&> first_matcher_;
07491 const Matcher<const SecondType&> second_matcher_;
07492
07493 GTEST_DISALLOW_ASSIGN_(PairMatcherImpl);
07494 };
07495
07496
07497 template <typename FirstMatcher, typename SecondMatcher>
07498 class PairMatcher {
07499 public:
07500 PairMatcher(FirstMatcher first_matcher, SecondMatcher second_matcher)
07501 : first_matcher_(first_matcher), second_matcher_(second_matcher) {}
07502
07503 template <typename PairType>
07504 operator Matcher<PairType> () const {
07505 return MakeMatcher(
07506 new PairMatcherImpl<PairType>(
07507 first_matcher_, second_matcher_));
07508 }
07509
07510 private:
07511 const FirstMatcher first_matcher_;
07512 const SecondMatcher second_matcher_;
07513
07514 GTEST_DISALLOW_ASSIGN_(PairMatcher);
07515 };
07516
07517
07518 template <typename Container>
07519 class ElementsAreMatcherImpl : public MatcherInterface<Container> {
07520 public:
07521 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
07522 typedef internal::StlContainerView<RawContainer> View;
07523 typedef typename View::type StlContainer;
07524 typedef typename View::const_reference StlContainerReference;
07525 typedef typename StlContainer::value_type Element;
07526
07527
07528
07529 template <typename InputIter>
07530 ElementsAreMatcherImpl(InputIter first, InputIter last) {
07531 while (first != last) {
07532 matchers_.push_back(MatcherCast<const Element&>(*first++));
07533 }
07534 }
07535
07536
07537 virtual void DescribeTo(::std::ostream* os) const {
07538 if (count() == 0) {
07539 *os << "is empty";
07540 } else if (count() == 1) {
07541 *os << "has 1 element that ";
07542 matchers_[0].DescribeTo(os);
07543 } else {
07544 *os << "has " << Elements(count()) << " where\n";
07545 for (size_t i = 0; i != count(); ++i) {
07546 *os << "element #" << i << " ";
07547 matchers_[i].DescribeTo(os);
07548 if (i + 1 < count()) {
07549 *os << ",\n";
07550 }
07551 }
07552 }
07553 }
07554
07555
07556 virtual void DescribeNegationTo(::std::ostream* os) const {
07557 if (count() == 0) {
07558 *os << "isn't empty";
07559 return;
07560 }
07561
07562 *os << "doesn't have " << Elements(count()) << ", or\n";
07563 for (size_t i = 0; i != count(); ++i) {
07564 *os << "element #" << i << " ";
07565 matchers_[i].DescribeNegationTo(os);
07566 if (i + 1 < count()) {
07567 *os << ", or\n";
07568 }
07569 }
07570 }
07571
07572 virtual bool MatchAndExplain(Container container,
07573 MatchResultListener* listener) const {
07574
07575
07576
07577 const bool listener_interested = listener->IsInterested();
07578
07579
07580 ::std::vector<internal::string> explanations(count());
07581 StlContainerReference stl_container = View::ConstReference(container);
07582 typename StlContainer::const_iterator it = stl_container.begin();
07583 size_t exam_pos = 0;
07584 bool mismatch_found = false;
07585
07586
07587
07588
07589 for (; it != stl_container.end() && exam_pos != count(); ++it, ++exam_pos) {
07590 bool match;
07591 if (listener_interested) {
07592 StringMatchResultListener s;
07593 match = matchers_[exam_pos].MatchAndExplain(*it, &s);
07594 explanations[exam_pos] = s.str();
07595 } else {
07596 match = matchers_[exam_pos].Matches(*it);
07597 }
07598
07599 if (!match) {
07600 mismatch_found = true;
07601 break;
07602 }
07603 }
07604
07605
07606
07607
07608
07609 size_t actual_count = exam_pos;
07610 for (; it != stl_container.end(); ++it) {
07611 ++actual_count;
07612 }
07613
07614 if (actual_count != count()) {
07615
07616
07617
07618
07619 if (listener_interested && (actual_count != 0)) {
07620 *listener << "which has " << Elements(actual_count);
07621 }
07622 return false;
07623 }
07624
07625 if (mismatch_found) {
07626
07627 if (listener_interested) {
07628 *listener << "whose element #" << exam_pos << " doesn't match";
07629 PrintIfNotEmpty(explanations[exam_pos], listener->stream());
07630 }
07631 return false;
07632 }
07633
07634
07635
07636 if (listener_interested) {
07637 bool reason_printed = false;
07638 for (size_t i = 0; i != count(); ++i) {
07639 const internal::string& s = explanations[i];
07640 if (!s.empty()) {
07641 if (reason_printed) {
07642 *listener << ",\nand ";
07643 }
07644 *listener << "whose element #" << i << " matches, " << s;
07645 reason_printed = true;
07646 }
07647 }
07648 }
07649 return true;
07650 }
07651
07652 private:
07653 static Message Elements(size_t count) {
07654 return Message() << count << (count == 1 ? " element" : " elements");
07655 }
07656
07657 size_t count() const { return matchers_.size(); }
07658
07659 ::std::vector<Matcher<const Element&> > matchers_;
07660
07661 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcherImpl);
07662 };
07663
07664
07665
07666
07667
07668 class GTEST_API_ MatchMatrix {
07669 public:
07670 MatchMatrix(size_t num_elements, size_t num_matchers)
07671 : num_elements_(num_elements),
07672 num_matchers_(num_matchers),
07673 matched_(num_elements_* num_matchers_, 0) {
07674 }
07675
07676 size_t LhsSize() const { return num_elements_; }
07677 size_t RhsSize() const { return num_matchers_; }
07678 bool HasEdge(size_t ilhs, size_t irhs) const {
07679 return matched_[SpaceIndex(ilhs, irhs)] == 1;
07680 }
07681 void SetEdge(size_t ilhs, size_t irhs, bool b) {
07682 matched_[SpaceIndex(ilhs, irhs)] = b ? 1 : 0;
07683 }
07684
07685
07686
07687
07688 bool NextGraph();
07689
07690 void Randomize();
07691
07692 string DebugString() const;
07693
07694 private:
07695 size_t SpaceIndex(size_t ilhs, size_t irhs) const {
07696 return ilhs * num_matchers_ + irhs;
07697 }
07698
07699 size_t num_elements_;
07700 size_t num_matchers_;
07701
07702
07703
07704
07705 ::std::vector<char> matched_;
07706 };
07707
07708 typedef ::std::pair<size_t, size_t> ElementMatcherPair;
07709 typedef ::std::vector<ElementMatcherPair> ElementMatcherPairs;
07710
07711
07712
07713 GTEST_API_ ElementMatcherPairs
07714 FindMaxBipartiteMatching(const MatchMatrix& g);
07715
07716 GTEST_API_ bool FindPairing(const MatchMatrix& matrix,
07717 MatchResultListener* listener);
07718
07719
07720
07721
07722 class GTEST_API_ UnorderedElementsAreMatcherImplBase {
07723 protected:
07724
07725
07726
07727 typedef ::std::vector<const MatcherDescriberInterface*> MatcherDescriberVec;
07728
07729
07730 void DescribeToImpl(::std::ostream* os) const;
07731
07732
07733 void DescribeNegationToImpl(::std::ostream* os) const;
07734
07735 bool VerifyAllElementsAndMatchersAreMatched(
07736 const ::std::vector<string>& element_printouts,
07737 const MatchMatrix& matrix,
07738 MatchResultListener* listener) const;
07739
07740 MatcherDescriberVec& matcher_describers() {
07741 return matcher_describers_;
07742 }
07743
07744 static Message Elements(size_t n) {
07745 return Message() << n << " element" << (n == 1 ? "" : "s");
07746 }
07747
07748 private:
07749 MatcherDescriberVec matcher_describers_;
07750
07751 GTEST_DISALLOW_ASSIGN_(UnorderedElementsAreMatcherImplBase);
07752 };
07753
07754
07755 template <typename Container>
07756 class UnorderedElementsAreMatcherImpl
07757 : public MatcherInterface<Container>,
07758 public UnorderedElementsAreMatcherImplBase {
07759 public:
07760 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
07761 typedef internal::StlContainerView<RawContainer> View;
07762 typedef typename View::type StlContainer;
07763 typedef typename View::const_reference StlContainerReference;
07764 typedef typename StlContainer::const_iterator StlContainerConstIterator;
07765 typedef typename StlContainer::value_type Element;
07766
07767
07768
07769 template <typename InputIter>
07770 UnorderedElementsAreMatcherImpl(InputIter first, InputIter last) {
07771 for (; first != last; ++first) {
07772 matchers_.push_back(MatcherCast<const Element&>(*first));
07773 matcher_describers().push_back(matchers_.back().GetDescriber());
07774 }
07775 }
07776
07777
07778 virtual void DescribeTo(::std::ostream* os) const {
07779 return UnorderedElementsAreMatcherImplBase::DescribeToImpl(os);
07780 }
07781
07782
07783 virtual void DescribeNegationTo(::std::ostream* os) const {
07784 return UnorderedElementsAreMatcherImplBase::DescribeNegationToImpl(os);
07785 }
07786
07787 virtual bool MatchAndExplain(Container container,
07788 MatchResultListener* listener) const {
07789 StlContainerReference stl_container = View::ConstReference(container);
07790 ::std::vector<string> element_printouts;
07791 MatchMatrix matrix = AnalyzeElements(stl_container.begin(),
07792 stl_container.end(),
07793 &element_printouts,
07794 listener);
07795
07796 const size_t actual_count = matrix.LhsSize();
07797 if (actual_count == 0 && matchers_.empty()) {
07798 return true;
07799 }
07800 if (actual_count != matchers_.size()) {
07801
07802
07803
07804
07805 if (actual_count != 0 && listener->IsInterested()) {
07806 *listener << "which has " << Elements(actual_count);
07807 }
07808 return false;
07809 }
07810
07811 return VerifyAllElementsAndMatchersAreMatched(element_printouts,
07812 matrix, listener) &&
07813 FindPairing(matrix, listener);
07814 }
07815
07816 private:
07817 typedef ::std::vector<Matcher<const Element&> > MatcherVec;
07818
07819 template <typename ElementIter>
07820 MatchMatrix AnalyzeElements(ElementIter elem_first, ElementIter elem_last,
07821 ::std::vector<string>* element_printouts,
07822 MatchResultListener* listener) const {
07823 element_printouts->clear();
07824 ::std::vector<char> did_match;
07825 size_t num_elements = 0;
07826 for (; elem_first != elem_last; ++num_elements, ++elem_first) {
07827 if (listener->IsInterested()) {
07828 element_printouts->push_back(PrintToString(*elem_first));
07829 }
07830 for (size_t irhs = 0; irhs != matchers_.size(); ++irhs) {
07831 did_match.push_back(Matches(matchers_[irhs])(*elem_first));
07832 }
07833 }
07834
07835 MatchMatrix matrix(num_elements, matchers_.size());
07836 ::std::vector<char>::const_iterator did_match_iter = did_match.begin();
07837 for (size_t ilhs = 0; ilhs != num_elements; ++ilhs) {
07838 for (size_t irhs = 0; irhs != matchers_.size(); ++irhs) {
07839 matrix.SetEdge(ilhs, irhs, *did_match_iter++ != 0);
07840 }
07841 }
07842 return matrix;
07843 }
07844
07845 MatcherVec matchers_;
07846
07847 GTEST_DISALLOW_ASSIGN_(UnorderedElementsAreMatcherImpl);
07848 };
07849
07850
07851
07852 template <typename Target>
07853 struct CastAndAppendTransform {
07854 template <typename Arg>
07855 Matcher<Target> operator()(const Arg& a) const {
07856 return MatcherCast<Target>(a);
07857 }
07858 };
07859
07860
07861 template <typename MatcherTuple>
07862 class UnorderedElementsAreMatcher {
07863 public:
07864 explicit UnorderedElementsAreMatcher(const MatcherTuple& args)
07865 : matchers_(args) {}
07866
07867 template <typename Container>
07868 operator Matcher<Container>() const {
07869 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
07870 typedef typename internal::StlContainerView<RawContainer>::type View;
07871 typedef typename View::value_type Element;
07872 typedef ::std::vector<Matcher<const Element&> > MatcherVec;
07873 MatcherVec matchers;
07874 matchers.reserve(::std::tr1::tuple_size<MatcherTuple>::value);
07875 TransformTupleValues(CastAndAppendTransform<const Element&>(), matchers_,
07876 ::std::back_inserter(matchers));
07877 return MakeMatcher(new UnorderedElementsAreMatcherImpl<Container>(
07878 matchers.begin(), matchers.end()));
07879 }
07880
07881 private:
07882 const MatcherTuple matchers_;
07883 GTEST_DISALLOW_ASSIGN_(UnorderedElementsAreMatcher);
07884 };
07885
07886
07887 template <typename MatcherTuple>
07888 class ElementsAreMatcher {
07889 public:
07890 explicit ElementsAreMatcher(const MatcherTuple& args) : matchers_(args) {}
07891
07892 template <typename Container>
07893 operator Matcher<Container>() const {
07894 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
07895 typedef typename internal::StlContainerView<RawContainer>::type View;
07896 typedef typename View::value_type Element;
07897 typedef ::std::vector<Matcher<const Element&> > MatcherVec;
07898 MatcherVec matchers;
07899 matchers.reserve(::std::tr1::tuple_size<MatcherTuple>::value);
07900 TransformTupleValues(CastAndAppendTransform<const Element&>(), matchers_,
07901 ::std::back_inserter(matchers));
07902 return MakeMatcher(new ElementsAreMatcherImpl<Container>(
07903 matchers.begin(), matchers.end()));
07904 }
07905
07906 private:
07907 const MatcherTuple matchers_;
07908 GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher);
07909 };
07910
07911
07912 template <typename T>
07913 class UnorderedElementsAreArrayMatcher {
07914 public:
07915 UnorderedElementsAreArrayMatcher() {}
07916
07917 template <typename Iter>
07918 UnorderedElementsAreArrayMatcher(Iter first, Iter last)
07919 : matchers_(first, last) {}
07920
07921 template <typename Container>
07922 operator Matcher<Container>() const {
07923 return MakeMatcher(
07924 new UnorderedElementsAreMatcherImpl<Container>(matchers_.begin(),
07925 matchers_.end()));
07926 }
07927
07928 private:
07929 ::std::vector<T> matchers_;
07930
07931 GTEST_DISALLOW_ASSIGN_(UnorderedElementsAreArrayMatcher);
07932 };
07933
07934
07935 template <typename T>
07936 class ElementsAreArrayMatcher {
07937 public:
07938 template <typename Iter>
07939 ElementsAreArrayMatcher(Iter first, Iter last) : matchers_(first, last) {}
07940
07941 template <typename Container>
07942 operator Matcher<Container>() const {
07943 return MakeMatcher(new ElementsAreMatcherImpl<Container>(
07944 matchers_.begin(), matchers_.end()));
07945 }
07946
07947 private:
07948 const ::std::vector<T> matchers_;
07949
07950 GTEST_DISALLOW_ASSIGN_(ElementsAreArrayMatcher);
07951 };
07952
07953
07954
07955
07956
07957
07958 GTEST_API_ string FormatMatcherDescription(bool negation,
07959 const char* matcher_name,
07960 const Strings& param_values);
07961
07962 }
07963
07964
07965
07966
07967
07968
07969
07970
07971
07972
07973
07974
07975
07976
07977
07978
07979 template <typename Iter>
07980 inline internal::ElementsAreArrayMatcher<
07981 typename ::std::iterator_traits<Iter>::value_type>
07982 ElementsAreArray(Iter first, Iter last) {
07983 typedef typename ::std::iterator_traits<Iter>::value_type T;
07984 return internal::ElementsAreArrayMatcher<T>(first, last);
07985 }
07986
07987 template <typename T>
07988 inline internal::ElementsAreArrayMatcher<T> ElementsAreArray(
07989 const T* pointer, size_t count) {
07990 return ElementsAreArray(pointer, pointer + count);
07991 }
07992
07993 template <typename T, size_t N>
07994 inline internal::ElementsAreArrayMatcher<T> ElementsAreArray(
07995 const T (&array)[N]) {
07996 return ElementsAreArray(array, N);
07997 }
07998
07999 template <typename T, typename A>
08000 inline internal::ElementsAreArrayMatcher<T> ElementsAreArray(
08001 const ::std::vector<T, A>& vec) {
08002 return ElementsAreArray(vec.begin(), vec.end());
08003 }
08004
08005 #if GTEST_LANG_CXX11
08006 template <typename T>
08007 inline internal::ElementsAreArrayMatcher<T>
08008 ElementsAreArray(::std::initializer_list<T> xs) {
08009 return ElementsAreArray(xs.begin(), xs.end());
08010 }
08011 #endif
08012
08013
08014
08015
08016
08017
08018
08019
08020
08021 template <typename Iter>
08022 inline internal::UnorderedElementsAreArrayMatcher<
08023 typename ::std::iterator_traits<Iter>::value_type>
08024 UnorderedElementsAreArray(Iter first, Iter last) {
08025 typedef typename ::std::iterator_traits<Iter>::value_type T;
08026 return internal::UnorderedElementsAreArrayMatcher<T>(first, last);
08027 }
08028
08029 template <typename T>
08030 inline internal::UnorderedElementsAreArrayMatcher<T>
08031 UnorderedElementsAreArray(const T* pointer, size_t count) {
08032 return UnorderedElementsAreArray(pointer, pointer + count);
08033 }
08034
08035 template <typename T, size_t N>
08036 inline internal::UnorderedElementsAreArrayMatcher<T>
08037 UnorderedElementsAreArray(const T (&array)[N]) {
08038 return UnorderedElementsAreArray(array, N);
08039 }
08040
08041 template <typename T, typename A>
08042 inline internal::UnorderedElementsAreArrayMatcher<T>
08043 UnorderedElementsAreArray(const ::std::vector<T, A>& vec) {
08044 return UnorderedElementsAreArray(vec.begin(), vec.end());
08045 }
08046
08047 #if GTEST_LANG_CXX11
08048 template <typename T>
08049 inline internal::UnorderedElementsAreArrayMatcher<T>
08050 UnorderedElementsAreArray(::std::initializer_list<T> xs) {
08051 return UnorderedElementsAreArray(xs.begin(), xs.end());
08052 }
08053 #endif
08054
08055
08056
08057
08058
08059
08060
08061
08062
08063
08064 const internal::AnythingMatcher _ = {};
08065
08066 template <typename T>
08067 inline Matcher<T> A() { return MakeMatcher(new internal::AnyMatcherImpl<T>()); }
08068
08069
08070 template <typename T>
08071 inline Matcher<T> An() { return A<T>(); }
08072
08073
08074
08075
08076 template <typename T>
08077 inline internal::EqMatcher<T> Eq(T x) { return internal::EqMatcher<T>(x); }
08078
08079
08080
08081 template <typename T>
08082 Matcher<T>::Matcher(T value) { *this = Eq(value); }
08083
08084
08085
08086
08087
08088
08089
08090
08091
08092
08093
08094
08095
08096 template <typename Lhs, typename Rhs>
08097 inline Matcher<Lhs> TypedEq(const Rhs& rhs) { return Eq(rhs); }
08098
08099
08100 template <typename Rhs>
08101 inline internal::GeMatcher<Rhs> Ge(Rhs x) {
08102 return internal::GeMatcher<Rhs>(x);
08103 }
08104
08105
08106 template <typename Rhs>
08107 inline internal::GtMatcher<Rhs> Gt(Rhs x) {
08108 return internal::GtMatcher<Rhs>(x);
08109 }
08110
08111
08112 template <typename Rhs>
08113 inline internal::LeMatcher<Rhs> Le(Rhs x) {
08114 return internal::LeMatcher<Rhs>(x);
08115 }
08116
08117
08118 template <typename Rhs>
08119 inline internal::LtMatcher<Rhs> Lt(Rhs x) {
08120 return internal::LtMatcher<Rhs>(x);
08121 }
08122
08123
08124 template <typename Rhs>
08125 inline internal::NeMatcher<Rhs> Ne(Rhs x) {
08126 return internal::NeMatcher<Rhs>(x);
08127 }
08128
08129
08130 inline PolymorphicMatcher<internal::IsNullMatcher > IsNull() {
08131 return MakePolymorphicMatcher(internal::IsNullMatcher());
08132 }
08133
08134
08135
08136
08137 inline PolymorphicMatcher<internal::NotNullMatcher > NotNull() {
08138 return MakePolymorphicMatcher(internal::NotNullMatcher());
08139 }
08140
08141
08142
08143 template <typename T>
08144 inline internal::RefMatcher<T&> Ref(T& x) {
08145 return internal::RefMatcher<T&>(x);
08146 }
08147
08148
08149
08150 inline internal::FloatingEqMatcher<double> DoubleEq(double rhs) {
08151 return internal::FloatingEqMatcher<double>(rhs, false);
08152 }
08153
08154
08155
08156 inline internal::FloatingEqMatcher<double> NanSensitiveDoubleEq(double rhs) {
08157 return internal::FloatingEqMatcher<double>(rhs, true);
08158 }
08159
08160
08161
08162
08163 inline internal::FloatingEqMatcher<double> DoubleNear(
08164 double rhs, double max_abs_error) {
08165 return internal::FloatingEqMatcher<double>(rhs, false, max_abs_error);
08166 }
08167
08168
08169
08170
08171 inline internal::FloatingEqMatcher<double> NanSensitiveDoubleNear(
08172 double rhs, double max_abs_error) {
08173 return internal::FloatingEqMatcher<double>(rhs, true, max_abs_error);
08174 }
08175
08176
08177
08178 inline internal::FloatingEqMatcher<float> FloatEq(float rhs) {
08179 return internal::FloatingEqMatcher<float>(rhs, false);
08180 }
08181
08182
08183
08184 inline internal::FloatingEqMatcher<float> NanSensitiveFloatEq(float rhs) {
08185 return internal::FloatingEqMatcher<float>(rhs, true);
08186 }
08187
08188
08189
08190
08191 inline internal::FloatingEqMatcher<float> FloatNear(
08192 float rhs, float max_abs_error) {
08193 return internal::FloatingEqMatcher<float>(rhs, false, max_abs_error);
08194 }
08195
08196
08197
08198
08199 inline internal::FloatingEqMatcher<float> NanSensitiveFloatNear(
08200 float rhs, float max_abs_error) {
08201 return internal::FloatingEqMatcher<float>(rhs, true, max_abs_error);
08202 }
08203
08204
08205
08206 template <typename InnerMatcher>
08207 inline internal::PointeeMatcher<InnerMatcher> Pointee(
08208 const InnerMatcher& inner_matcher) {
08209 return internal::PointeeMatcher<InnerMatcher>(inner_matcher);
08210 }
08211
08212
08213
08214
08215
08216 template <typename Class, typename FieldType, typename FieldMatcher>
08217 inline PolymorphicMatcher<
08218 internal::FieldMatcher<Class, FieldType> > Field(
08219 FieldType Class::*field, const FieldMatcher& matcher) {
08220 return MakePolymorphicMatcher(
08221 internal::FieldMatcher<Class, FieldType>(
08222 field, MatcherCast<const FieldType&>(matcher)));
08223
08224
08225
08226
08227 }
08228
08229
08230
08231
08232
08233 template <typename Class, typename PropertyType, typename PropertyMatcher>
08234 inline PolymorphicMatcher<
08235 internal::PropertyMatcher<Class, PropertyType> > Property(
08236 PropertyType (Class::*property)() const, const PropertyMatcher& matcher) {
08237 return MakePolymorphicMatcher(
08238 internal::PropertyMatcher<Class, PropertyType>(
08239 property,
08240 MatcherCast<GTEST_REFERENCE_TO_CONST_(PropertyType)>(matcher)));
08241
08242
08243
08244
08245 }
08246
08247
08248
08249
08250
08251
08252
08253
08254
08255
08256
08257
08258
08259
08260 template <typename Callable, typename ResultOfMatcher>
08261 internal::ResultOfMatcher<Callable> ResultOf(
08262 Callable callable, const ResultOfMatcher& matcher) {
08263 return internal::ResultOfMatcher<Callable>(
08264 callable,
08265 MatcherCast<typename internal::CallableTraits<Callable>::ResultType>(
08266 matcher));
08267
08268
08269
08270
08271 }
08272
08273
08274
08275
08276 inline PolymorphicMatcher<internal::StrEqualityMatcher<internal::string> >
08277 StrEq(const internal::string& str) {
08278 return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::string>(
08279 str, true, true));
08280 }
08281
08282
08283 inline PolymorphicMatcher<internal::StrEqualityMatcher<internal::string> >
08284 StrNe(const internal::string& str) {
08285 return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::string>(
08286 str, false, true));
08287 }
08288
08289
08290 inline PolymorphicMatcher<internal::StrEqualityMatcher<internal::string> >
08291 StrCaseEq(const internal::string& str) {
08292 return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::string>(
08293 str, true, false));
08294 }
08295
08296
08297 inline PolymorphicMatcher<internal::StrEqualityMatcher<internal::string> >
08298 StrCaseNe(const internal::string& str) {
08299 return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::string>(
08300 str, false, false));
08301 }
08302
08303
08304
08305 inline PolymorphicMatcher<internal::HasSubstrMatcher<internal::string> >
08306 HasSubstr(const internal::string& substring) {
08307 return MakePolymorphicMatcher(internal::HasSubstrMatcher<internal::string>(
08308 substring));
08309 }
08310
08311
08312 inline PolymorphicMatcher<internal::StartsWithMatcher<internal::string> >
08313 StartsWith(const internal::string& prefix) {
08314 return MakePolymorphicMatcher(internal::StartsWithMatcher<internal::string>(
08315 prefix));
08316 }
08317
08318
08319 inline PolymorphicMatcher<internal::EndsWithMatcher<internal::string> >
08320 EndsWith(const internal::string& suffix) {
08321 return MakePolymorphicMatcher(internal::EndsWithMatcher<internal::string>(
08322 suffix));
08323 }
08324
08325
08326
08327 inline PolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex(
08328 const internal::RE* regex) {
08329 return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, true));
08330 }
08331 inline PolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex(
08332 const internal::string& regex) {
08333 return MatchesRegex(new internal::RE(regex));
08334 }
08335
08336
08337
08338 inline PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex(
08339 const internal::RE* regex) {
08340 return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, false));
08341 }
08342 inline PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex(
08343 const internal::string& regex) {
08344 return ContainsRegex(new internal::RE(regex));
08345 }
08346
08347 #if GTEST_HAS_GLOBAL_WSTRING || GTEST_HAS_STD_WSTRING
08348
08349
08350
08351 inline PolymorphicMatcher<internal::StrEqualityMatcher<internal::wstring> >
08352 StrEq(const internal::wstring& str) {
08353 return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::wstring>(
08354 str, true, true));
08355 }
08356
08357
08358 inline PolymorphicMatcher<internal::StrEqualityMatcher<internal::wstring> >
08359 StrNe(const internal::wstring& str) {
08360 return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::wstring>(
08361 str, false, true));
08362 }
08363
08364
08365 inline PolymorphicMatcher<internal::StrEqualityMatcher<internal::wstring> >
08366 StrCaseEq(const internal::wstring& str) {
08367 return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::wstring>(
08368 str, true, false));
08369 }
08370
08371
08372 inline PolymorphicMatcher<internal::StrEqualityMatcher<internal::wstring> >
08373 StrCaseNe(const internal::wstring& str) {
08374 return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::wstring>(
08375 str, false, false));
08376 }
08377
08378
08379
08380 inline PolymorphicMatcher<internal::HasSubstrMatcher<internal::wstring> >
08381 HasSubstr(const internal::wstring& substring) {
08382 return MakePolymorphicMatcher(internal::HasSubstrMatcher<internal::wstring>(
08383 substring));
08384 }
08385
08386
08387 inline PolymorphicMatcher<internal::StartsWithMatcher<internal::wstring> >
08388 StartsWith(const internal::wstring& prefix) {
08389 return MakePolymorphicMatcher(internal::StartsWithMatcher<internal::wstring>(
08390 prefix));
08391 }
08392
08393
08394 inline PolymorphicMatcher<internal::EndsWithMatcher<internal::wstring> >
08395 EndsWith(const internal::wstring& suffix) {
08396 return MakePolymorphicMatcher(internal::EndsWithMatcher<internal::wstring>(
08397 suffix));
08398 }
08399
08400 #endif // GTEST_HAS_GLOBAL_WSTRING || GTEST_HAS_STD_WSTRING
08401
08402
08403
08404 inline internal::Eq2Matcher Eq() { return internal::Eq2Matcher(); }
08405
08406
08407
08408 inline internal::Ge2Matcher Ge() { return internal::Ge2Matcher(); }
08409
08410
08411
08412 inline internal::Gt2Matcher Gt() { return internal::Gt2Matcher(); }
08413
08414
08415
08416 inline internal::Le2Matcher Le() { return internal::Le2Matcher(); }
08417
08418
08419
08420 inline internal::Lt2Matcher Lt() { return internal::Lt2Matcher(); }
08421
08422
08423
08424 inline internal::Ne2Matcher Ne() { return internal::Ne2Matcher(); }
08425
08426
08427
08428 template <typename InnerMatcher>
08429 inline internal::NotMatcher<InnerMatcher> Not(InnerMatcher m) {
08430 return internal::NotMatcher<InnerMatcher>(m);
08431 }
08432
08433
08434
08435
08436 template <typename Predicate>
08437 inline PolymorphicMatcher<internal::TrulyMatcher<Predicate> >
08438 Truly(Predicate pred) {
08439 return MakePolymorphicMatcher(internal::TrulyMatcher<Predicate>(pred));
08440 }
08441
08442
08443
08444
08445
08446
08447
08448 template <typename SizeMatcher>
08449 inline internal::SizeIsMatcher<SizeMatcher>
08450 SizeIs(const SizeMatcher& size_matcher) {
08451 return internal::SizeIsMatcher<SizeMatcher>(size_matcher);
08452 }
08453
08454
08455
08456
08457
08458 template <typename Container>
08459 inline PolymorphicMatcher<internal::ContainerEqMatcher<
08460 GTEST_REMOVE_CONST_(Container)> >
08461 ContainerEq(const Container& rhs) {
08462
08463
08464 typedef GTEST_REMOVE_CONST_(Container) RawContainer;
08465 return MakePolymorphicMatcher(
08466 internal::ContainerEqMatcher<RawContainer>(rhs));
08467 }
08468
08469
08470
08471 template <typename Comparator, typename ContainerMatcher>
08472 inline internal::WhenSortedByMatcher<Comparator, ContainerMatcher>
08473 WhenSortedBy(const Comparator& comparator,
08474 const ContainerMatcher& container_matcher) {
08475 return internal::WhenSortedByMatcher<Comparator, ContainerMatcher>(
08476 comparator, container_matcher);
08477 }
08478
08479
08480
08481 template <typename ContainerMatcher>
08482 inline internal::WhenSortedByMatcher<internal::LessComparator, ContainerMatcher>
08483 WhenSorted(const ContainerMatcher& container_matcher) {
08484 return
08485 internal::WhenSortedByMatcher<internal::LessComparator, ContainerMatcher>(
08486 internal::LessComparator(), container_matcher);
08487 }
08488
08489
08490
08491
08492
08493
08494
08495 template <typename TupleMatcher, typename Container>
08496 inline internal::PointwiseMatcher<TupleMatcher,
08497 GTEST_REMOVE_CONST_(Container)>
08498 Pointwise(const TupleMatcher& tuple_matcher, const Container& rhs) {
08499
08500
08501 typedef GTEST_REMOVE_CONST_(Container) RawContainer;
08502 return internal::PointwiseMatcher<TupleMatcher, RawContainer>(
08503 tuple_matcher, rhs);
08504 }
08505
08506
08507
08508
08509
08510
08511
08512
08513
08514
08515
08516
08517
08518
08519
08520
08521
08522
08523
08524 template <typename M>
08525 inline internal::ContainsMatcher<M> Contains(M matcher) {
08526 return internal::ContainsMatcher<M>(matcher);
08527 }
08528
08529
08530
08531
08532
08533
08534
08535
08536
08537
08538
08539
08540
08541
08542
08543
08544
08545
08546
08547
08548
08549
08550
08551
08552
08553
08554
08555
08556 template <typename M>
08557 inline internal::EachMatcher<M> Each(M matcher) {
08558 return internal::EachMatcher<M>(matcher);
08559 }
08560
08561
08562
08563
08564 template <typename M>
08565 inline internal::KeyMatcher<M> Key(M inner_matcher) {
08566 return internal::KeyMatcher<M>(inner_matcher);
08567 }
08568
08569
08570
08571
08572
08573
08574 template <typename FirstMatcher, typename SecondMatcher>
08575 inline internal::PairMatcher<FirstMatcher, SecondMatcher>
08576 Pair(FirstMatcher first_matcher, SecondMatcher second_matcher) {
08577 return internal::PairMatcher<FirstMatcher, SecondMatcher>(
08578 first_matcher, second_matcher);
08579 }
08580
08581
08582
08583 template <typename M>
08584 inline internal::MatcherAsPredicate<M> Matches(M matcher) {
08585 return internal::MatcherAsPredicate<M>(matcher);
08586 }
08587
08588
08589 template <typename T, typename M>
08590 inline bool Value(const T& value, M matcher) {
08591 return testing::Matches(matcher)(value);
08592 }
08593
08594
08595
08596 template <typename T, typename M>
08597 inline bool ExplainMatchResult(
08598 M matcher, const T& value, MatchResultListener* listener) {
08599 return SafeMatcherCast<const T&>(matcher).MatchAndExplain(value, listener);
08600 }
08601
08602 #if GTEST_LANG_CXX11
08603
08604
08605 template <typename... Args>
08606 inline internal::AllOfMatcher<Args...> AllOf(const Args&... matchers) {
08607 return internal::AllOfMatcher<Args...>(matchers...);
08608 }
08609
08610 template <typename... Args>
08611 inline internal::AnyOfMatcher<Args...> AnyOf(const Args&... matchers) {
08612 return internal::AnyOfMatcher<Args...>(matchers...);
08613 }
08614
08615 #endif // GTEST_LANG_CXX11
08616
08617
08618
08619
08620
08621
08622
08623
08624 template <typename InnerMatcher>
08625 inline InnerMatcher AllArgs(const InnerMatcher& matcher) { return matcher; }
08626
08627
08628
08629
08630
08631 #define ASSERT_THAT(value, matcher) ASSERT_PRED_FORMAT1(\
08632 ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)
08633 #define EXPECT_THAT(value, matcher) EXPECT_PRED_FORMAT1(\
08634 ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)
08635
08636 }
08637
08638 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
08639
08640 namespace testing {
08641
08642
08643 class Expectation;
08644
08645
08646 class ExpectationSet;
08647
08648
08649
08650 namespace internal {
08651
08652
08653 template <typename F> class FunctionMocker;
08654
08655
08656 class ExpectationBase;
08657
08658
08659 template <typename F> class TypedExpectation;
08660
08661
08662 class ExpectationTester;
08663
08664
08665 template <typename F> class FunctionMockerBase;
08666
08667
08668
08669
08670
08671
08672
08673
08674
08675
08676
08677
08678 GTEST_API_ GTEST_DECLARE_STATIC_MUTEX_(g_gmock_mutex);
08679
08680
08681 class UntypedActionResultHolderBase;
08682
08683
08684
08685
08686 class GTEST_API_ UntypedFunctionMockerBase {
08687 public:
08688 UntypedFunctionMockerBase();
08689 virtual ~UntypedFunctionMockerBase();
08690
08691
08692
08693
08694 bool VerifyAndClearExpectationsLocked()
08695 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);
08696
08697
08698 virtual void ClearDefaultActionsLocked()
08699 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) = 0;
08700
08701
08702
08703
08704
08705
08706
08707
08708
08709
08710 virtual UntypedActionResultHolderBase* UntypedPerformDefaultAction(
08711 const void* untyped_args,
08712 const string& call_description) const = 0;
08713
08714
08715
08716
08717 virtual UntypedActionResultHolderBase* UntypedPerformAction(
08718 const void* untyped_action,
08719 const void* untyped_args) const = 0;
08720
08721
08722
08723
08724 virtual void UntypedDescribeUninterestingCall(
08725 const void* untyped_args,
08726 ::std::ostream* os) const
08727 GTEST_LOCK_EXCLUDED_(g_gmock_mutex) = 0;
08728
08729
08730
08731
08732
08733
08734
08735 virtual const ExpectationBase* UntypedFindMatchingExpectation(
08736 const void* untyped_args,
08737 const void** untyped_action, bool* is_excessive,
08738 ::std::ostream* what, ::std::ostream* why)
08739 GTEST_LOCK_EXCLUDED_(g_gmock_mutex) = 0;
08740
08741
08742 virtual void UntypedPrintArgs(const void* untyped_args,
08743 ::std::ostream* os) const = 0;
08744
08745
08746
08747
08748
08749
08750 void RegisterOwner(const void* mock_obj)
08751 GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
08752
08753
08754
08755
08756 void SetOwnerAndName(const void* mock_obj, const char* name)
08757 GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
08758
08759
08760
08761
08762 const void* MockObject() const
08763 GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
08764
08765
08766
08767 const char* Name() const
08768 GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
08769
08770
08771
08772
08773
08774 const UntypedActionResultHolderBase* UntypedInvokeWith(
08775 const void* untyped_args)
08776 GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
08777
08778 protected:
08779 typedef std::vector<const void*> UntypedOnCallSpecs;
08780
08781 typedef std::vector<internal::linked_ptr<ExpectationBase> >
08782 UntypedExpectations;
08783
08784
08785
08786 Expectation GetHandleOf(ExpectationBase* exp);
08787
08788
08789
08790
08791 const void* mock_obj_;
08792
08793
08794
08795 const char* name_;
08796
08797
08798 UntypedOnCallSpecs untyped_on_call_specs_;
08799
08800
08801 UntypedExpectations untyped_expectations_;
08802 };
08803
08804
08805 class UntypedOnCallSpecBase {
08806 public:
08807
08808 UntypedOnCallSpecBase(const char* a_file, int a_line)
08809 : file_(a_file), line_(a_line), last_clause_(kNone) {}
08810
08811
08812 const char* file() const { return file_; }
08813 int line() const { return line_; }
08814
08815 protected:
08816
08817 enum Clause {
08818
08819
08820 kNone,
08821 kWith,
08822 kWillByDefault
08823 };
08824
08825
08826 void AssertSpecProperty(bool property, const string& failure_message) const {
08827 Assert(property, file_, line_, failure_message);
08828 }
08829
08830
08831 void ExpectSpecProperty(bool property, const string& failure_message) const {
08832 Expect(property, file_, line_, failure_message);
08833 }
08834
08835 const char* file_;
08836 int line_;
08837
08838
08839
08840 Clause last_clause_;
08841 };
08842
08843
08844 template <typename F>
08845 class OnCallSpec : public UntypedOnCallSpecBase {
08846 public:
08847 typedef typename Function<F>::ArgumentTuple ArgumentTuple;
08848 typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;
08849
08850
08851
08852 OnCallSpec(const char* a_file, int a_line,
08853 const ArgumentMatcherTuple& matchers)
08854 : UntypedOnCallSpecBase(a_file, a_line),
08855 matchers_(matchers),
08856
08857
08858
08859
08860 extra_matcher_(A<const ArgumentTuple&>()) {
08861 }
08862
08863
08864 OnCallSpec& With(const Matcher<const ArgumentTuple&>& m) {
08865
08866 ExpectSpecProperty(last_clause_ < kWith,
08867 ".With() cannot appear "
08868 "more than once in an ON_CALL().");
08869 last_clause_ = kWith;
08870
08871 extra_matcher_ = m;
08872 return *this;
08873 }
08874
08875
08876 OnCallSpec& WillByDefault(const Action<F>& action) {
08877 ExpectSpecProperty(last_clause_ < kWillByDefault,
08878 ".WillByDefault() must appear "
08879 "exactly once in an ON_CALL().");
08880 last_clause_ = kWillByDefault;
08881
08882 ExpectSpecProperty(!action.IsDoDefault(),
08883 "DoDefault() cannot be used in ON_CALL().");
08884 action_ = action;
08885 return *this;
08886 }
08887
08888
08889 bool Matches(const ArgumentTuple& args) const {
08890 return TupleMatches(matchers_, args) && extra_matcher_.Matches(args);
08891 }
08892
08893
08894 const Action<F>& GetAction() const {
08895 AssertSpecProperty(last_clause_ == kWillByDefault,
08896 ".WillByDefault() must appear exactly "
08897 "once in an ON_CALL().");
08898 return action_;
08899 }
08900
08901 private:
08902
08903
08904
08905
08906
08907
08908
08909
08910
08911
08912
08913
08914
08915 ArgumentMatcherTuple matchers_;
08916 Matcher<const ArgumentTuple&> extra_matcher_;
08917 Action<F> action_;
08918 };
08919
08920
08921 enum CallReaction {
08922 kAllow,
08923 kWarn,
08924 kFail,
08925 kDefault = kWarn
08926 };
08927
08928 }
08929
08930
08931 class GTEST_API_ Mock {
08932 public:
08933
08934
08935
08936
08937 static void AllowLeak(const void* mock_obj)
08938 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
08939
08940
08941
08942
08943 static bool VerifyAndClearExpectations(void* mock_obj)
08944 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
08945
08946
08947
08948
08949 static bool VerifyAndClear(void* mock_obj)
08950 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
08951
08952 private:
08953 friend class internal::UntypedFunctionMockerBase;
08954
08955
08956
08957 template <typename F>
08958 friend class internal::FunctionMockerBase;
08959
08960 template <typename M>
08961 friend class NiceMock;
08962
08963 template <typename M>
08964 friend class NaggyMock;
08965
08966 template <typename M>
08967 friend class StrictMock;
08968
08969
08970
08971 static void AllowUninterestingCalls(const void* mock_obj)
08972 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
08973
08974
08975
08976 static void WarnUninterestingCalls(const void* mock_obj)
08977 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
08978
08979
08980
08981 static void FailUninterestingCalls(const void* mock_obj)
08982 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
08983
08984
08985
08986 static void UnregisterCallReaction(const void* mock_obj)
08987 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
08988
08989
08990
08991 static internal::CallReaction GetReactionOnUninterestingCalls(
08992 const void* mock_obj)
08993 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
08994
08995
08996
08997
08998 static bool VerifyAndClearExpectationsLocked(void* mock_obj)
08999 GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex);
09000
09001
09002 static void ClearDefaultActionsLocked(void* mock_obj)
09003 GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex);
09004
09005
09006 static void Register(
09007 const void* mock_obj,
09008 internal::UntypedFunctionMockerBase* mocker)
09009 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
09010
09011
09012
09013
09014 static void RegisterUseByOnCallOrExpectCall(
09015 const void* mock_obj, const char* file, int line)
09016 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
09017
09018
09019
09020
09021
09022 static void UnregisterLocked(internal::UntypedFunctionMockerBase* mocker)
09023 GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex);
09024 };
09025
09026
09027
09028
09029
09030
09031
09032
09033
09034
09035
09036
09037
09038
09039
09040
09041
09042
09043
09044
09045
09046
09047 class GTEST_API_ Expectation {
09048 public:
09049
09050 Expectation();
09051
09052 ~Expectation();
09053
09054
09055
09056
09057
09058
09059
09060
09061
09062
09063 Expectation(internal::ExpectationBase& exp);
09064
09065
09066
09067
09068
09069 bool operator==(const Expectation& rhs) const {
09070 return expectation_base_ == rhs.expectation_base_;
09071 }
09072
09073 bool operator!=(const Expectation& rhs) const { return !(*this == rhs); }
09074
09075 private:
09076 friend class ExpectationSet;
09077 friend class Sequence;
09078 friend class ::testing::internal::ExpectationBase;
09079 friend class ::testing::internal::UntypedFunctionMockerBase;
09080
09081 template <typename F>
09082 friend class ::testing::internal::FunctionMockerBase;
09083
09084 template <typename F>
09085 friend class ::testing::internal::TypedExpectation;
09086
09087
09088 class Less {
09089 public:
09090 bool operator()(const Expectation& lhs, const Expectation& rhs) const {
09091 return lhs.expectation_base_.get() < rhs.expectation_base_.get();
09092 }
09093 };
09094
09095 typedef ::std::set<Expectation, Less> Set;
09096
09097 Expectation(
09098 const internal::linked_ptr<internal::ExpectationBase>& expectation_base);
09099
09100
09101 const internal::linked_ptr<internal::ExpectationBase>&
09102 expectation_base() const {
09103 return expectation_base_;
09104 }
09105
09106
09107 internal::linked_ptr<internal::ExpectationBase> expectation_base_;
09108 };
09109
09110
09111
09112
09113
09114
09115
09116
09117
09118
09119
09120
09121
09122
09123 class ExpectationSet {
09124 public:
09125
09126 typedef Expectation::Set::const_iterator const_iterator;
09127
09128
09129 typedef Expectation::Set::value_type value_type;
09130
09131
09132 ExpectationSet() {}
09133
09134
09135
09136
09137 ExpectationSet(internal::ExpectationBase& exp) {
09138 *this += Expectation(exp);
09139 }
09140
09141
09142
09143
09144 ExpectationSet(const Expectation& e) {
09145 *this += e;
09146 }
09147
09148
09149
09150
09151
09152
09153 bool operator==(const ExpectationSet& rhs) const {
09154 return expectations_ == rhs.expectations_;
09155 }
09156
09157 bool operator!=(const ExpectationSet& rhs) const { return !(*this == rhs); }
09158
09159
09160
09161 ExpectationSet& operator+=(const Expectation& e) {
09162 expectations_.insert(e);
09163 return *this;
09164 }
09165
09166 int size() const { return static_cast<int>(expectations_.size()); }
09167
09168 const_iterator begin() const { return expectations_.begin(); }
09169 const_iterator end() const { return expectations_.end(); }
09170
09171 private:
09172 Expectation::Set expectations_;
09173 };
09174
09175
09176
09177
09178
09179 class GTEST_API_ Sequence {
09180 public:
09181
09182 Sequence() : last_expectation_(new Expectation) {}
09183
09184
09185
09186 void AddExpectation(const Expectation& expectation) const;
09187
09188 private:
09189
09190
09191
09192
09193 internal::linked_ptr<Expectation> last_expectation_;
09194 };
09195
09196
09197
09198
09199
09200
09201
09202
09203
09204
09205
09206
09207
09208
09209
09210
09211
09212
09213
09214
09215
09216
09217
09218
09219
09220 class GTEST_API_ InSequence {
09221 public:
09222 InSequence();
09223 ~InSequence();
09224 private:
09225 bool sequence_created_;
09226
09227 GTEST_DISALLOW_COPY_AND_ASSIGN_(InSequence);
09228 } GTEST_ATTRIBUTE_UNUSED_;
09229
09230 namespace internal {
09231
09232
09233
09234 GTEST_API_ extern ThreadLocal<Sequence*> g_gmock_implicit_sequence;
09235
09236
09237
09238
09239
09240
09241
09242
09243
09244
09245
09246
09247
09248
09249
09250 class GTEST_API_ ExpectationBase {
09251 public:
09252
09253 ExpectationBase(const char* file, int line, const string& source_text);
09254
09255 virtual ~ExpectationBase();
09256
09257
09258 const char* file() const { return file_; }
09259 int line() const { return line_; }
09260 const char* source_text() const { return source_text_.c_str(); }
09261
09262 const Cardinality& cardinality() const { return cardinality_; }
09263
09264
09265 void DescribeLocationTo(::std::ostream* os) const {
09266 *os << FormatFileLocation(file(), line()) << " ";
09267 }
09268
09269
09270
09271 void DescribeCallCountTo(::std::ostream* os) const
09272 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);
09273
09274
09275
09276 virtual void MaybeDescribeExtraMatcherTo(::std::ostream* os) = 0;
09277
09278 protected:
09279 friend class ::testing::Expectation;
09280 friend class UntypedFunctionMockerBase;
09281
09282 enum Clause {
09283
09284 kNone,
09285 kWith,
09286 kTimes,
09287 kInSequence,
09288 kAfter,
09289 kWillOnce,
09290 kWillRepeatedly,
09291 kRetiresOnSaturation
09292 };
09293
09294 typedef std::vector<const void*> UntypedActions;
09295
09296
09297
09298 virtual Expectation GetHandle() = 0;
09299
09300
09301 void AssertSpecProperty(bool property, const string& failure_message) const {
09302 Assert(property, file_, line_, failure_message);
09303 }
09304
09305
09306 void ExpectSpecProperty(bool property, const string& failure_message) const {
09307 Expect(property, file_, line_, failure_message);
09308 }
09309
09310
09311
09312 void SpecifyCardinality(const Cardinality& cardinality);
09313
09314
09315
09316 bool cardinality_specified() const { return cardinality_specified_; }
09317
09318
09319 void set_cardinality(const Cardinality& a_cardinality) {
09320 cardinality_ = a_cardinality;
09321 }
09322
09323
09324
09325
09326
09327
09328 void RetireAllPreRequisites()
09329 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);
09330
09331
09332 bool is_retired() const
09333 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
09334 g_gmock_mutex.AssertHeld();
09335 return retired_;
09336 }
09337
09338
09339 void Retire()
09340 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
09341 g_gmock_mutex.AssertHeld();
09342 retired_ = true;
09343 }
09344
09345
09346 bool IsSatisfied() const
09347 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
09348 g_gmock_mutex.AssertHeld();
09349 return cardinality().IsSatisfiedByCallCount(call_count_);
09350 }
09351
09352
09353 bool IsSaturated() const
09354 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
09355 g_gmock_mutex.AssertHeld();
09356 return cardinality().IsSaturatedByCallCount(call_count_);
09357 }
09358
09359
09360 bool IsOverSaturated() const
09361 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
09362 g_gmock_mutex.AssertHeld();
09363 return cardinality().IsOverSaturatedByCallCount(call_count_);
09364 }
09365
09366
09367 bool AllPrerequisitesAreSatisfied() const
09368 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);
09369
09370
09371 void FindUnsatisfiedPrerequisites(ExpectationSet* result) const
09372 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);
09373
09374
09375 int call_count() const
09376 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
09377 g_gmock_mutex.AssertHeld();
09378 return call_count_;
09379 }
09380
09381
09382 void IncrementCallCount()
09383 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
09384 g_gmock_mutex.AssertHeld();
09385 call_count_++;
09386 }
09387
09388
09389
09390
09391
09392 void CheckActionCountIfNotDone() const
09393 GTEST_LOCK_EXCLUDED_(mutex_);
09394
09395 friend class ::testing::Sequence;
09396 friend class ::testing::internal::ExpectationTester;
09397
09398 template <typename Function>
09399 friend class TypedExpectation;
09400
09401
09402 void UntypedTimes(const Cardinality& a_cardinality);
09403
09404
09405
09406 const char* file_;
09407 int line_;
09408 const string source_text_;
09409
09410 bool cardinality_specified_;
09411 Cardinality cardinality_;
09412
09413
09414
09415
09416
09417
09418 ExpectationSet immediate_prerequisites_;
09419
09420
09421
09422 int call_count_;
09423 bool retired_;
09424 UntypedActions untyped_actions_;
09425 bool extra_matcher_specified_;
09426 bool repeated_action_specified_;
09427 bool retires_on_saturation_;
09428 Clause last_clause_;
09429 mutable bool action_count_checked_;
09430 mutable Mutex mutex_;
09431
09432 GTEST_DISALLOW_ASSIGN_(ExpectationBase);
09433 };
09434
09435
09436 template <typename F>
09437 class TypedExpectation : public ExpectationBase {
09438 public:
09439 typedef typename Function<F>::ArgumentTuple ArgumentTuple;
09440 typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;
09441 typedef typename Function<F>::Result Result;
09442
09443 TypedExpectation(FunctionMockerBase<F>* owner,
09444 const char* a_file, int a_line, const string& a_source_text,
09445 const ArgumentMatcherTuple& m)
09446 : ExpectationBase(a_file, a_line, a_source_text),
09447 owner_(owner),
09448 matchers_(m),
09449
09450
09451
09452
09453 extra_matcher_(A<const ArgumentTuple&>()),
09454 repeated_action_(DoDefault()) {}
09455
09456 virtual ~TypedExpectation() {
09457
09458
09459 CheckActionCountIfNotDone();
09460 for (UntypedActions::const_iterator it = untyped_actions_.begin();
09461 it != untyped_actions_.end(); ++it) {
09462 delete static_cast<const Action<F>*>(*it);
09463 }
09464 }
09465
09466
09467 TypedExpectation& With(const Matcher<const ArgumentTuple&>& m) {
09468 if (last_clause_ == kWith) {
09469 ExpectSpecProperty(false,
09470 ".With() cannot appear "
09471 "more than once in an EXPECT_CALL().");
09472 } else {
09473 ExpectSpecProperty(last_clause_ < kWith,
09474 ".With() must be the first "
09475 "clause in an EXPECT_CALL().");
09476 }
09477 last_clause_ = kWith;
09478
09479 extra_matcher_ = m;
09480 extra_matcher_specified_ = true;
09481 return *this;
09482 }
09483
09484
09485 TypedExpectation& Times(const Cardinality& a_cardinality) {
09486 ExpectationBase::UntypedTimes(a_cardinality);
09487 return *this;
09488 }
09489
09490
09491 TypedExpectation& Times(int n) {
09492 return Times(Exactly(n));
09493 }
09494
09495
09496 TypedExpectation& InSequence(const Sequence& s) {
09497 ExpectSpecProperty(last_clause_ <= kInSequence,
09498 ".InSequence() cannot appear after .After(),"
09499 " .WillOnce(), .WillRepeatedly(), or "
09500 ".RetiresOnSaturation().");
09501 last_clause_ = kInSequence;
09502
09503 s.AddExpectation(GetHandle());
09504 return *this;
09505 }
09506 TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2) {
09507 return InSequence(s1).InSequence(s2);
09508 }
09509 TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2,
09510 const Sequence& s3) {
09511 return InSequence(s1, s2).InSequence(s3);
09512 }
09513 TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2,
09514 const Sequence& s3, const Sequence& s4) {
09515 return InSequence(s1, s2, s3).InSequence(s4);
09516 }
09517 TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2,
09518 const Sequence& s3, const Sequence& s4,
09519 const Sequence& s5) {
09520 return InSequence(s1, s2, s3, s4).InSequence(s5);
09521 }
09522
09523
09524 TypedExpectation& After(const ExpectationSet& s) {
09525 ExpectSpecProperty(last_clause_ <= kAfter,
09526 ".After() cannot appear after .WillOnce(),"
09527 " .WillRepeatedly(), or "
09528 ".RetiresOnSaturation().");
09529 last_clause_ = kAfter;
09530
09531 for (ExpectationSet::const_iterator it = s.begin(); it != s.end(); ++it) {
09532 immediate_prerequisites_ += *it;
09533 }
09534 return *this;
09535 }
09536 TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2) {
09537 return After(s1).After(s2);
09538 }
09539 TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2,
09540 const ExpectationSet& s3) {
09541 return After(s1, s2).After(s3);
09542 }
09543 TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2,
09544 const ExpectationSet& s3, const ExpectationSet& s4) {
09545 return After(s1, s2, s3).After(s4);
09546 }
09547 TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2,
09548 const ExpectationSet& s3, const ExpectationSet& s4,
09549 const ExpectationSet& s5) {
09550 return After(s1, s2, s3, s4).After(s5);
09551 }
09552
09553
09554 TypedExpectation& WillOnce(const Action<F>& action) {
09555 ExpectSpecProperty(last_clause_ <= kWillOnce,
09556 ".WillOnce() cannot appear after "
09557 ".WillRepeatedly() or .RetiresOnSaturation().");
09558 last_clause_ = kWillOnce;
09559
09560 untyped_actions_.push_back(new Action<F>(action));
09561 if (!cardinality_specified()) {
09562 set_cardinality(Exactly(static_cast<int>(untyped_actions_.size())));
09563 }
09564 return *this;
09565 }
09566
09567
09568 TypedExpectation& WillRepeatedly(const Action<F>& action) {
09569 if (last_clause_ == kWillRepeatedly) {
09570 ExpectSpecProperty(false,
09571 ".WillRepeatedly() cannot appear "
09572 "more than once in an EXPECT_CALL().");
09573 } else {
09574 ExpectSpecProperty(last_clause_ < kWillRepeatedly,
09575 ".WillRepeatedly() cannot appear "
09576 "after .RetiresOnSaturation().");
09577 }
09578 last_clause_ = kWillRepeatedly;
09579 repeated_action_specified_ = true;
09580
09581 repeated_action_ = action;
09582 if (!cardinality_specified()) {
09583 set_cardinality(AtLeast(static_cast<int>(untyped_actions_.size())));
09584 }
09585
09586
09587
09588 CheckActionCountIfNotDone();
09589 return *this;
09590 }
09591
09592
09593 TypedExpectation& RetiresOnSaturation() {
09594 ExpectSpecProperty(last_clause_ < kRetiresOnSaturation,
09595 ".RetiresOnSaturation() cannot appear "
09596 "more than once.");
09597 last_clause_ = kRetiresOnSaturation;
09598 retires_on_saturation_ = true;
09599
09600
09601
09602 CheckActionCountIfNotDone();
09603 return *this;
09604 }
09605
09606
09607
09608 const ArgumentMatcherTuple& matchers() const {
09609 return matchers_;
09610 }
09611
09612
09613 const Matcher<const ArgumentTuple&>& extra_matcher() const {
09614 return extra_matcher_;
09615 }
09616
09617
09618 const Action<F>& repeated_action() const { return repeated_action_; }
09619
09620
09621
09622 virtual void MaybeDescribeExtraMatcherTo(::std::ostream* os) {
09623 if (extra_matcher_specified_) {
09624 *os << " Expected args: ";
09625 extra_matcher_.DescribeTo(os);
09626 *os << "\n";
09627 }
09628 }
09629
09630 private:
09631 template <typename Function>
09632 friend class FunctionMockerBase;
09633
09634
09635
09636 virtual Expectation GetHandle() {
09637 return owner_->GetHandleOf(this);
09638 }
09639
09640
09641
09642
09643
09644
09645 bool Matches(const ArgumentTuple& args) const
09646 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
09647 g_gmock_mutex.AssertHeld();
09648 return TupleMatches(matchers_, args) && extra_matcher_.Matches(args);
09649 }
09650
09651
09652 bool ShouldHandleArguments(const ArgumentTuple& args) const
09653 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
09654 g_gmock_mutex.AssertHeld();
09655
09656
09657
09658
09659
09660 CheckActionCountIfNotDone();
09661 return !is_retired() && AllPrerequisitesAreSatisfied() && Matches(args);
09662 }
09663
09664
09665
09666 void ExplainMatchResultTo(
09667 const ArgumentTuple& args,
09668 ::std::ostream* os) const
09669 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
09670 g_gmock_mutex.AssertHeld();
09671
09672 if (is_retired()) {
09673 *os << " Expected: the expectation is active\n"
09674 << " Actual: it is retired\n";
09675 } else if (!Matches(args)) {
09676 if (!TupleMatches(matchers_, args)) {
09677 ExplainMatchFailureTupleTo(matchers_, args, os);
09678 }
09679 StringMatchResultListener listener;
09680 if (!extra_matcher_.MatchAndExplain(args, &listener)) {
09681 *os << " Expected args: ";
09682 extra_matcher_.DescribeTo(os);
09683 *os << "\n Actual: don't match";
09684
09685 internal::PrintIfNotEmpty(listener.str(), os);
09686 *os << "\n";
09687 }
09688 } else if (!AllPrerequisitesAreSatisfied()) {
09689 *os << " Expected: all pre-requisites are satisfied\n"
09690 << " Actual: the following immediate pre-requisites "
09691 << "are not satisfied:\n";
09692 ExpectationSet unsatisfied_prereqs;
09693 FindUnsatisfiedPrerequisites(&unsatisfied_prereqs);
09694 int i = 0;
09695 for (ExpectationSet::const_iterator it = unsatisfied_prereqs.begin();
09696 it != unsatisfied_prereqs.end(); ++it) {
09697 it->expectation_base()->DescribeLocationTo(os);
09698 *os << "pre-requisite #" << i++ << "\n";
09699 }
09700 *os << " (end of pre-requisites)\n";
09701 } else {
09702
09703
09704
09705
09706 *os << "The call matches the expectation.\n";
09707 }
09708 }
09709
09710
09711 const Action<F>& GetCurrentAction(
09712 const FunctionMockerBase<F>* mocker,
09713 const ArgumentTuple& args) const
09714 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
09715 g_gmock_mutex.AssertHeld();
09716 const int count = call_count();
09717 Assert(count >= 1, __FILE__, __LINE__,
09718 "call_count() is <= 0 when GetCurrentAction() is "
09719 "called - this should never happen.");
09720
09721 const int action_count = static_cast<int>(untyped_actions_.size());
09722 if (action_count > 0 && !repeated_action_specified_ &&
09723 count > action_count) {
09724
09725
09726 ::std::stringstream ss;
09727 DescribeLocationTo(&ss);
09728 ss << "Actions ran out in " << source_text() << "...\n"
09729 << "Called " << count << " times, but only "
09730 << action_count << " WillOnce()"
09731 << (action_count == 1 ? " is" : "s are") << " specified - ";
09732 mocker->DescribeDefaultActionTo(args, &ss);
09733 Log(kWarning, ss.str(), 1);
09734 }
09735
09736 return count <= action_count ?
09737 *static_cast<const Action<F>*>(untyped_actions_[count - 1]) :
09738 repeated_action();
09739 }
09740
09741
09742
09743
09744
09745
09746
09747
09748 const Action<F>* GetActionForArguments(
09749 const FunctionMockerBase<F>* mocker,
09750 const ArgumentTuple& args,
09751 ::std::ostream* what,
09752 ::std::ostream* why)
09753 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
09754 g_gmock_mutex.AssertHeld();
09755 if (IsSaturated()) {
09756
09757 IncrementCallCount();
09758 *what << "Mock function called more times than expected - ";
09759 mocker->DescribeDefaultActionTo(args, what);
09760 DescribeCallCountTo(why);
09761
09762
09763
09764
09765 return NULL;
09766 }
09767
09768 IncrementCallCount();
09769 RetireAllPreRequisites();
09770
09771 if (retires_on_saturation_ && IsSaturated()) {
09772 Retire();
09773 }
09774
09775
09776 *what << "Mock function call matches " << source_text() <<"...\n";
09777 return &(GetCurrentAction(mocker, args));
09778 }
09779
09780
09781
09782 FunctionMockerBase<F>* const owner_;
09783 ArgumentMatcherTuple matchers_;
09784 Matcher<const ArgumentTuple&> extra_matcher_;
09785 Action<F> repeated_action_;
09786
09787 GTEST_DISALLOW_COPY_AND_ASSIGN_(TypedExpectation);
09788 };
09789
09790
09791
09792
09793
09794
09795
09796
09797
09798
09799
09800
09801 GTEST_API_ void LogWithLocation(testing::internal::LogSeverity severity,
09802 const char* file, int line,
09803 const string& message);
09804
09805 template <typename F>
09806 class MockSpec {
09807 public:
09808 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
09809 typedef typename internal::Function<F>::ArgumentMatcherTuple
09810 ArgumentMatcherTuple;
09811
09812
09813
09814 explicit MockSpec(internal::FunctionMockerBase<F>* function_mocker)
09815 : function_mocker_(function_mocker) {}
09816
09817
09818
09819 internal::OnCallSpec<F>& InternalDefaultActionSetAt(
09820 const char* file, int line, const char* obj, const char* call) {
09821 LogWithLocation(internal::kInfo, file, line,
09822 string("ON_CALL(") + obj + ", " + call + ") invoked");
09823 return function_mocker_->AddNewOnCallSpec(file, line, matchers_);
09824 }
09825
09826
09827
09828 internal::TypedExpectation<F>& InternalExpectedAt(
09829 const char* file, int line, const char* obj, const char* call) {
09830 const string source_text(string("EXPECT_CALL(") + obj + ", " + call + ")");
09831 LogWithLocation(internal::kInfo, file, line, source_text + " invoked");
09832 return function_mocker_->AddNewExpectation(
09833 file, line, source_text, matchers_);
09834 }
09835
09836 private:
09837 template <typename Function>
09838 friend class internal::FunctionMocker;
09839
09840 void SetMatchers(const ArgumentMatcherTuple& matchers) {
09841 matchers_ = matchers;
09842 }
09843
09844
09845 internal::FunctionMockerBase<F>* const function_mocker_;
09846
09847 ArgumentMatcherTuple matchers_;
09848
09849 GTEST_DISALLOW_ASSIGN_(MockSpec);
09850 };
09851
09852
09853
09854
09855
09856
09857 #ifdef _MSC_VER
09858 # pragma warning(push) // Saves the current warning state.
09859 # pragma warning(disable:4355) // Temporarily disables warning 4355.
09860 #endif // _MSV_VER
09861
09862
09863
09864
09865
09866
09867
09868
09869
09870
09871 class UntypedActionResultHolderBase {
09872 public:
09873 virtual ~UntypedActionResultHolderBase() {}
09874
09875
09876 virtual void PrintAsActionResult(::std::ostream* os) const = 0;
09877 };
09878
09879
09880 template <typename T>
09881 class ActionResultHolder : public UntypedActionResultHolderBase {
09882 public:
09883 explicit ActionResultHolder(T a_value) : value_(a_value) {}
09884
09885
09886
09887
09888
09889 T GetValueAndDelete() const {
09890 T retval(value_);
09891 delete this;
09892 return retval;
09893 }
09894
09895
09896 virtual void PrintAsActionResult(::std::ostream* os) const {
09897 *os << "\n Returns: ";
09898
09899 UniversalPrinter<T>::Print(value_, os);
09900 }
09901
09902
09903
09904 template <typename F>
09905 static ActionResultHolder* PerformDefaultAction(
09906 const FunctionMockerBase<F>* func_mocker,
09907 const typename Function<F>::ArgumentTuple& args,
09908 const string& call_description) {
09909 return new ActionResultHolder(
09910 func_mocker->PerformDefaultAction(args, call_description));
09911 }
09912
09913
09914
09915 template <typename F>
09916 static ActionResultHolder*
09917 PerformAction(const Action<F>& action,
09918 const typename Function<F>::ArgumentTuple& args) {
09919 return new ActionResultHolder(action.Perform(args));
09920 }
09921
09922 private:
09923 T value_;
09924
09925
09926 GTEST_DISALLOW_ASSIGN_(ActionResultHolder);
09927 };
09928
09929
09930 template <>
09931 class ActionResultHolder<void> : public UntypedActionResultHolderBase {
09932 public:
09933 void GetValueAndDelete() const { delete this; }
09934
09935 virtual void PrintAsActionResult(::std::ostream* ) const {}
09936
09937
09938 template <typename F>
09939 static ActionResultHolder* PerformDefaultAction(
09940 const FunctionMockerBase<F>* func_mocker,
09941 const typename Function<F>::ArgumentTuple& args,
09942 const string& call_description) {
09943 func_mocker->PerformDefaultAction(args, call_description);
09944 return NULL;
09945 }
09946
09947
09948 template <typename F>
09949 static ActionResultHolder* PerformAction(
09950 const Action<F>& action,
09951 const typename Function<F>::ArgumentTuple& args) {
09952 action.Perform(args);
09953 return NULL;
09954 }
09955 };
09956
09957
09958
09959
09960 template <typename F>
09961 class FunctionMockerBase : public UntypedFunctionMockerBase {
09962 public:
09963 typedef typename Function<F>::Result Result;
09964 typedef typename Function<F>::ArgumentTuple ArgumentTuple;
09965 typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;
09966
09967 FunctionMockerBase() : current_spec_(this) {}
09968
09969
09970
09971
09972 virtual ~FunctionMockerBase()
09973 GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
09974 MutexLock l(&g_gmock_mutex);
09975 VerifyAndClearExpectationsLocked();
09976 Mock::UnregisterLocked(this);
09977 ClearDefaultActionsLocked();
09978 }
09979
09980
09981
09982
09983 const OnCallSpec<F>* FindOnCallSpec(
09984 const ArgumentTuple& args) const {
09985 for (UntypedOnCallSpecs::const_reverse_iterator it
09986 = untyped_on_call_specs_.rbegin();
09987 it != untyped_on_call_specs_.rend(); ++it) {
09988 const OnCallSpec<F>* spec = static_cast<const OnCallSpec<F>*>(*it);
09989 if (spec->Matches(args))
09990 return spec;
09991 }
09992
09993 return NULL;
09994 }
09995
09996
09997
09998
09999
10000
10001
10002
10003 Result PerformDefaultAction(const ArgumentTuple& args,
10004 const string& call_description) const {
10005 const OnCallSpec<F>* const spec =
10006 this->FindOnCallSpec(args);
10007 if (spec != NULL) {
10008 return spec->GetAction().Perform(args);
10009 }
10010 const string message = call_description +
10011 "\n The mock function has no default action "
10012 "set, and its return type has no default value set.";
10013 #if GTEST_HAS_EXCEPTIONS
10014 if (!DefaultValue<Result>::Exists()) {
10015 throw std::runtime_error(message);
10016 }
10017 #else
10018 Assert(DefaultValue<Result>::Exists(), "", -1, message);
10019 #endif
10020 return DefaultValue<Result>::Get();
10021 }
10022
10023
10024
10025
10026
10027
10028 virtual UntypedActionResultHolderBase* UntypedPerformDefaultAction(
10029 const void* untyped_args,
10030 const string& call_description) const {
10031 const ArgumentTuple& args =
10032 *static_cast<const ArgumentTuple*>(untyped_args);
10033 return ResultHolder::PerformDefaultAction(this, args, call_description);
10034 }
10035
10036
10037
10038
10039
10040 virtual UntypedActionResultHolderBase* UntypedPerformAction(
10041 const void* untyped_action, const void* untyped_args) const {
10042
10043
10044 const Action<F> action = *static_cast<const Action<F>*>(untyped_action);
10045 const ArgumentTuple& args =
10046 *static_cast<const ArgumentTuple*>(untyped_args);
10047 return ResultHolder::PerformAction(action, args);
10048 }
10049
10050
10051
10052 virtual void ClearDefaultActionsLocked()
10053 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
10054 g_gmock_mutex.AssertHeld();
10055
10056
10057
10058
10059
10060
10061
10062
10063 UntypedOnCallSpecs specs_to_delete;
10064 untyped_on_call_specs_.swap(specs_to_delete);
10065
10066 g_gmock_mutex.Unlock();
10067 for (UntypedOnCallSpecs::const_iterator it =
10068 specs_to_delete.begin();
10069 it != specs_to_delete.end(); ++it) {
10070 delete static_cast<const OnCallSpec<F>*>(*it);
10071 }
10072
10073
10074
10075 g_gmock_mutex.Lock();
10076 }
10077
10078 protected:
10079 template <typename Function>
10080 friend class MockSpec;
10081
10082 typedef ActionResultHolder<Result> ResultHolder;
10083
10084
10085
10086
10087 Result InvokeWith(const ArgumentTuple& args)
10088 GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
10089 return static_cast<const ResultHolder*>(
10090 this->UntypedInvokeWith(&args))->GetValueAndDelete();
10091 }
10092
10093
10094 OnCallSpec<F>& AddNewOnCallSpec(
10095 const char* file, int line,
10096 const ArgumentMatcherTuple& m)
10097 GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
10098 Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);
10099 OnCallSpec<F>* const on_call_spec = new OnCallSpec<F>(file, line, m);
10100 untyped_on_call_specs_.push_back(on_call_spec);
10101 return *on_call_spec;
10102 }
10103
10104
10105 TypedExpectation<F>& AddNewExpectation(
10106 const char* file,
10107 int line,
10108 const string& source_text,
10109 const ArgumentMatcherTuple& m)
10110 GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
10111 Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);
10112 TypedExpectation<F>* const expectation =
10113 new TypedExpectation<F>(this, file, line, source_text, m);
10114 const linked_ptr<ExpectationBase> untyped_expectation(expectation);
10115 untyped_expectations_.push_back(untyped_expectation);
10116
10117
10118 Sequence* const implicit_sequence = g_gmock_implicit_sequence.get();
10119 if (implicit_sequence != NULL) {
10120 implicit_sequence->AddExpectation(Expectation(untyped_expectation));
10121 }
10122
10123 return *expectation;
10124 }
10125
10126
10127
10128 MockSpec<F>& current_spec() { return current_spec_; }
10129
10130 private:
10131 template <typename Func> friend class TypedExpectation;
10132
10133
10134
10135
10136
10137
10138 void DescribeDefaultActionTo(const ArgumentTuple& args,
10139 ::std::ostream* os) const {
10140 const OnCallSpec<F>* const spec = FindOnCallSpec(args);
10141
10142 if (spec == NULL) {
10143 *os << (internal::type_equals<Result, void>::value ?
10144 "returning directly.\n" :
10145 "returning default value.\n");
10146 } else {
10147 *os << "taking default action specified at:\n"
10148 << FormatFileLocation(spec->file(), spec->line()) << "\n";
10149 }
10150 }
10151
10152
10153
10154
10155 virtual void UntypedDescribeUninterestingCall(
10156 const void* untyped_args,
10157 ::std::ostream* os) const
10158 GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
10159 const ArgumentTuple& args =
10160 *static_cast<const ArgumentTuple*>(untyped_args);
10161 *os << "Uninteresting mock function call - ";
10162 DescribeDefaultActionTo(args, os);
10163 *os << " Function call: " << Name();
10164 UniversalPrint(args, os);
10165 }
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183 virtual const ExpectationBase* UntypedFindMatchingExpectation(
10184 const void* untyped_args,
10185 const void** untyped_action, bool* is_excessive,
10186 ::std::ostream* what, ::std::ostream* why)
10187 GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
10188 const ArgumentTuple& args =
10189 *static_cast<const ArgumentTuple*>(untyped_args);
10190 MutexLock l(&g_gmock_mutex);
10191 TypedExpectation<F>* exp = this->FindMatchingExpectationLocked(args);
10192 if (exp == NULL) {
10193 this->FormatUnexpectedCallMessageLocked(args, what, why);
10194 return NULL;
10195 }
10196
10197
10198
10199
10200 *is_excessive = exp->IsSaturated();
10201 const Action<F>* action = exp->GetActionForArguments(this, args, what, why);
10202 if (action != NULL && action->IsDoDefault())
10203 action = NULL;
10204 *untyped_action = action;
10205 return exp;
10206 }
10207
10208
10209 virtual void UntypedPrintArgs(const void* untyped_args,
10210 ::std::ostream* os) const {
10211 const ArgumentTuple& args =
10212 *static_cast<const ArgumentTuple*>(untyped_args);
10213 UniversalPrint(args, os);
10214 }
10215
10216
10217
10218 TypedExpectation<F>* FindMatchingExpectationLocked(
10219 const ArgumentTuple& args) const
10220 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
10221 g_gmock_mutex.AssertHeld();
10222 for (typename UntypedExpectations::const_reverse_iterator it =
10223 untyped_expectations_.rbegin();
10224 it != untyped_expectations_.rend(); ++it) {
10225 TypedExpectation<F>* const exp =
10226 static_cast<TypedExpectation<F>*>(it->get());
10227 if (exp->ShouldHandleArguments(args)) {
10228 return exp;
10229 }
10230 }
10231 return NULL;
10232 }
10233
10234
10235 void FormatUnexpectedCallMessageLocked(
10236 const ArgumentTuple& args,
10237 ::std::ostream* os,
10238 ::std::ostream* why) const
10239 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
10240 g_gmock_mutex.AssertHeld();
10241 *os << "\nUnexpected mock function call - ";
10242 DescribeDefaultActionTo(args, os);
10243 PrintTriedExpectationsLocked(args, why);
10244 }
10245
10246
10247
10248 void PrintTriedExpectationsLocked(
10249 const ArgumentTuple& args,
10250 ::std::ostream* why) const
10251 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
10252 g_gmock_mutex.AssertHeld();
10253 const int count = static_cast<int>(untyped_expectations_.size());
10254 *why << "Google Mock tried the following " << count << " "
10255 << (count == 1 ? "expectation, but it didn't match" :
10256 "expectations, but none matched")
10257 << ":\n";
10258 for (int i = 0; i < count; i++) {
10259 TypedExpectation<F>* const expectation =
10260 static_cast<TypedExpectation<F>*>(untyped_expectations_[i].get());
10261 *why << "\n";
10262 expectation->DescribeLocationTo(why);
10263 if (count > 1) {
10264 *why << "tried expectation #" << i << ": ";
10265 }
10266 *why << expectation->source_text() << "...\n";
10267 expectation->ExplainMatchResultTo(args, why);
10268 expectation->DescribeCallCountTo(why);
10269 }
10270 }
10271
10272
10273
10274 MockSpec<F> current_spec_;
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288 GTEST_DISALLOW_COPY_AND_ASSIGN_(FunctionMockerBase);
10289 };
10290
10291 #ifdef _MSC_VER
10292 # pragma warning(pop) // Restores the warning state.
10293 #endif // _MSV_VER
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303 void ReportUninterestingCall(CallReaction reaction, const string& msg);
10304
10305 }
10306
10307
10308
10309
10310
10311
10312 using internal::MockSpec;
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329 template <typename T>
10330 inline const T& Const(const T& x) { return x; }
10331
10332
10333 inline Expectation::Expectation(internal::ExpectationBase& exp)
10334 : expectation_base_(exp.GetHandle().expectation_base()) {}
10335
10336 }
10337
10338
10339
10340
10341
10342 #define GMOCK_ON_CALL_IMPL_(obj, call) \
10343 ((obj).gmock_##call).InternalDefaultActionSetAt(__FILE__, __LINE__, \
10344 #obj, #call)
10345 #define ON_CALL(obj, call) GMOCK_ON_CALL_IMPL_(obj, call)
10346
10347 #define GMOCK_EXPECT_CALL_IMPL_(obj, call) \
10348 ((obj).gmock_##call).InternalExpectedAt(__FILE__, __LINE__, #obj, #call)
10349 #define EXPECT_CALL(obj, call) GMOCK_EXPECT_CALL_IMPL_(obj, call)
10350
10351 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
10352
10353 namespace testing {
10354 namespace internal {
10355
10356 template <typename F>
10357 class FunctionMockerBase;
10358
10359
10360
10361
10362
10363
10364 template <typename F>
10365 class FunctionMocker;
10366
10367 template <typename R>
10368 class FunctionMocker<R()> : public
10369 internal::FunctionMockerBase<R()> {
10370 public:
10371 typedef R F();
10372 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
10373
10374 MockSpec<F>& With() {
10375 return this->current_spec();
10376 }
10377
10378 R Invoke() {
10379
10380
10381
10382
10383 return this->InvokeWith(ArgumentTuple());
10384 }
10385 };
10386
10387 template <typename R, typename A1>
10388 class FunctionMocker<R(A1)> : public
10389 internal::FunctionMockerBase<R(A1)> {
10390 public:
10391 typedef R F(A1);
10392 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
10393
10394 MockSpec<F>& With(const Matcher<A1>& m1) {
10395 this->current_spec().SetMatchers(::std::tr1::make_tuple(m1));
10396 return this->current_spec();
10397 }
10398
10399 R Invoke(A1 a1) {
10400
10401
10402
10403
10404 return this->InvokeWith(ArgumentTuple(a1));
10405 }
10406 };
10407
10408 template <typename R, typename A1, typename A2>
10409 class FunctionMocker<R(A1, A2)> : public
10410 internal::FunctionMockerBase<R(A1, A2)> {
10411 public:
10412 typedef R F(A1, A2);
10413 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
10414
10415 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2) {
10416 this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2));
10417 return this->current_spec();
10418 }
10419
10420 R Invoke(A1 a1, A2 a2) {
10421
10422
10423
10424
10425 return this->InvokeWith(ArgumentTuple(a1, a2));
10426 }
10427 };
10428
10429 template <typename R, typename A1, typename A2, typename A3>
10430 class FunctionMocker<R(A1, A2, A3)> : public
10431 internal::FunctionMockerBase<R(A1, A2, A3)> {
10432 public:
10433 typedef R F(A1, A2, A3);
10434 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
10435
10436 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
10437 const Matcher<A3>& m3) {
10438 this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3));
10439 return this->current_spec();
10440 }
10441
10442 R Invoke(A1 a1, A2 a2, A3 a3) {
10443
10444
10445
10446
10447 return this->InvokeWith(ArgumentTuple(a1, a2, a3));
10448 }
10449 };
10450
10451 template <typename R, typename A1, typename A2, typename A3, typename A4>
10452 class FunctionMocker<R(A1, A2, A3, A4)> : public
10453 internal::FunctionMockerBase<R(A1, A2, A3, A4)> {
10454 public:
10455 typedef R F(A1, A2, A3, A4);
10456 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
10457
10458 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
10459 const Matcher<A3>& m3, const Matcher<A4>& m4) {
10460 this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4));
10461 return this->current_spec();
10462 }
10463
10464 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4) {
10465
10466
10467
10468
10469 return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4));
10470 }
10471 };
10472
10473 template <typename R, typename A1, typename A2, typename A3, typename A4,
10474 typename A5>
10475 class FunctionMocker<R(A1, A2, A3, A4, A5)> : public
10476 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5)> {
10477 public:
10478 typedef R F(A1, A2, A3, A4, A5);
10479 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
10480
10481 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
10482 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5) {
10483 this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4,
10484 m5));
10485 return this->current_spec();
10486 }
10487
10488 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {
10489
10490
10491
10492
10493 return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5));
10494 }
10495 };
10496
10497 template <typename R, typename A1, typename A2, typename A3, typename A4,
10498 typename A5, typename A6>
10499 class FunctionMocker<R(A1, A2, A3, A4, A5, A6)> : public
10500 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6)> {
10501 public:
10502 typedef R F(A1, A2, A3, A4, A5, A6);
10503 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
10504
10505 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
10506 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
10507 const Matcher<A6>& m6) {
10508 this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
10509 m6));
10510 return this->current_spec();
10511 }
10512
10513 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) {
10514
10515
10516
10517
10518 return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6));
10519 }
10520 };
10521
10522 template <typename R, typename A1, typename A2, typename A3, typename A4,
10523 typename A5, typename A6, typename A7>
10524 class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7)> : public
10525 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7)> {
10526 public:
10527 typedef R F(A1, A2, A3, A4, A5, A6, A7);
10528 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
10529
10530 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
10531 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
10532 const Matcher<A6>& m6, const Matcher<A7>& m7) {
10533 this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
10534 m6, m7));
10535 return this->current_spec();
10536 }
10537
10538 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) {
10539
10540
10541
10542
10543 return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7));
10544 }
10545 };
10546
10547 template <typename R, typename A1, typename A2, typename A3, typename A4,
10548 typename A5, typename A6, typename A7, typename A8>
10549 class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8)> : public
10550 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8)> {
10551 public:
10552 typedef R F(A1, A2, A3, A4, A5, A6, A7, A8);
10553 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
10554
10555 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
10556 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
10557 const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8) {
10558 this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
10559 m6, m7, m8));
10560 return this->current_spec();
10561 }
10562
10563 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) {
10564
10565
10566
10567
10568 return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8));
10569 }
10570 };
10571
10572 template <typename R, typename A1, typename A2, typename A3, typename A4,
10573 typename A5, typename A6, typename A7, typename A8, typename A9>
10574 class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> : public
10575 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
10576 public:
10577 typedef R F(A1, A2, A3, A4, A5, A6, A7, A8, A9);
10578 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
10579
10580 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
10581 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
10582 const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8,
10583 const Matcher<A9>& m9) {
10584 this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
10585 m6, m7, m8, m9));
10586 return this->current_spec();
10587 }
10588
10589 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) {
10590
10591
10592
10593
10594 return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8, a9));
10595 }
10596 };
10597
10598 template <typename R, typename A1, typename A2, typename A3, typename A4,
10599 typename A5, typename A6, typename A7, typename A8, typename A9,
10600 typename A10>
10601 class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> : public
10602 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> {
10603 public:
10604 typedef R F(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
10605 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
10606
10607 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
10608 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
10609 const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8,
10610 const Matcher<A9>& m9, const Matcher<A10>& m10) {
10611 this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
10612 m6, m7, m8, m9, m10));
10613 return this->current_spec();
10614 }
10615
10616 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9,
10617 A10 a10) {
10618
10619
10620
10621
10622 return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8, a9,
10623 a10));
10624 }
10625 };
10626
10627 }
10628
10629
10630
10631
10632
10633
10634 using internal::FunctionMocker;
10635
10636
10637
10638
10639
10640
10641 #define GMOCK_RESULT_(tn, ...) \
10642 tn ::testing::internal::Function<__VA_ARGS__>::Result
10643
10644
10645
10646 #define GMOCK_ARG_(tn, N, ...) \
10647 tn ::testing::internal::Function<__VA_ARGS__>::Argument##N
10648
10649
10650
10651 #define GMOCK_MATCHER_(tn, N, ...) \
10652 const ::testing::Matcher<GMOCK_ARG_(tn, N, __VA_ARGS__)>&
10653
10654
10655
10656 #define GMOCK_MOCKER_(arity, constness, Method) \
10657 GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__)
10658
10659
10660 #define GMOCK_METHOD0_(tn, constness, ct, Method, ...) \
10661 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
10662 ) constness { \
10663 GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
10664 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
10665 == 0), \
10666 this_method_does_not_take_0_arguments); \
10667 GMOCK_MOCKER_(0, constness, Method).SetOwnerAndName(this, #Method); \
10668 return GMOCK_MOCKER_(0, constness, Method).Invoke(); \
10669 } \
10670 ::testing::MockSpec<__VA_ARGS__>& \
10671 gmock_##Method() constness { \
10672 GMOCK_MOCKER_(0, constness, Method).RegisterOwner(this); \
10673 return GMOCK_MOCKER_(0, constness, Method).With(); \
10674 } \
10675 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(0, constness, \
10676 Method)
10677
10678
10679 #define GMOCK_METHOD1_(tn, constness, ct, Method, ...) \
10680 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
10681 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1) constness { \
10682 GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
10683 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
10684 == 1), \
10685 this_method_does_not_take_1_argument); \
10686 GMOCK_MOCKER_(1, constness, Method).SetOwnerAndName(this, #Method); \
10687 return GMOCK_MOCKER_(1, constness, Method).Invoke(gmock_a1); \
10688 } \
10689 ::testing::MockSpec<__VA_ARGS__>& \
10690 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1) constness { \
10691 GMOCK_MOCKER_(1, constness, Method).RegisterOwner(this); \
10692 return GMOCK_MOCKER_(1, constness, Method).With(gmock_a1); \
10693 } \
10694 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(1, constness, \
10695 Method)
10696
10697
10698 #define GMOCK_METHOD2_(tn, constness, ct, Method, ...) \
10699 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
10700 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
10701 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2) constness { \
10702 GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
10703 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
10704 == 2), \
10705 this_method_does_not_take_2_arguments); \
10706 GMOCK_MOCKER_(2, constness, Method).SetOwnerAndName(this, #Method); \
10707 return GMOCK_MOCKER_(2, constness, Method).Invoke(gmock_a1, gmock_a2); \
10708 } \
10709 ::testing::MockSpec<__VA_ARGS__>& \
10710 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
10711 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2) constness { \
10712 GMOCK_MOCKER_(2, constness, Method).RegisterOwner(this); \
10713 return GMOCK_MOCKER_(2, constness, Method).With(gmock_a1, gmock_a2); \
10714 } \
10715 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(2, constness, \
10716 Method)
10717
10718
10719 #define GMOCK_METHOD3_(tn, constness, ct, Method, ...) \
10720 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
10721 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
10722 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
10723 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3) constness { \
10724 GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
10725 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
10726 == 3), \
10727 this_method_does_not_take_3_arguments); \
10728 GMOCK_MOCKER_(3, constness, Method).SetOwnerAndName(this, #Method); \
10729 return GMOCK_MOCKER_(3, constness, Method).Invoke(gmock_a1, gmock_a2, \
10730 gmock_a3); \
10731 } \
10732 ::testing::MockSpec<__VA_ARGS__>& \
10733 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
10734 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
10735 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3) constness { \
10736 GMOCK_MOCKER_(3, constness, Method).RegisterOwner(this); \
10737 return GMOCK_MOCKER_(3, constness, Method).With(gmock_a1, gmock_a2, \
10738 gmock_a3); \
10739 } \
10740 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(3, constness, \
10741 Method)
10742
10743
10744 #define GMOCK_METHOD4_(tn, constness, ct, Method, ...) \
10745 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
10746 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
10747 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
10748 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
10749 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4) constness { \
10750 GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
10751 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
10752 == 4), \
10753 this_method_does_not_take_4_arguments); \
10754 GMOCK_MOCKER_(4, constness, Method).SetOwnerAndName(this, #Method); \
10755 return GMOCK_MOCKER_(4, constness, Method).Invoke(gmock_a1, gmock_a2, \
10756 gmock_a3, gmock_a4); \
10757 } \
10758 ::testing::MockSpec<__VA_ARGS__>& \
10759 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
10760 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
10761 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
10762 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4) constness { \
10763 GMOCK_MOCKER_(4, constness, Method).RegisterOwner(this); \
10764 return GMOCK_MOCKER_(4, constness, Method).With(gmock_a1, gmock_a2, \
10765 gmock_a3, gmock_a4); \
10766 } \
10767 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(4, constness, \
10768 Method)
10769
10770
10771 #define GMOCK_METHOD5_(tn, constness, ct, Method, ...) \
10772 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
10773 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
10774 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
10775 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
10776 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
10777 GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5) constness { \
10778 GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
10779 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
10780 == 5), \
10781 this_method_does_not_take_5_arguments); \
10782 GMOCK_MOCKER_(5, constness, Method).SetOwnerAndName(this, #Method); \
10783 return GMOCK_MOCKER_(5, constness, Method).Invoke(gmock_a1, gmock_a2, \
10784 gmock_a3, gmock_a4, gmock_a5); \
10785 } \
10786 ::testing::MockSpec<__VA_ARGS__>& \
10787 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
10788 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
10789 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
10790 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
10791 GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5) constness { \
10792 GMOCK_MOCKER_(5, constness, Method).RegisterOwner(this); \
10793 return GMOCK_MOCKER_(5, constness, Method).With(gmock_a1, gmock_a2, \
10794 gmock_a3, gmock_a4, gmock_a5); \
10795 } \
10796 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(5, constness, \
10797 Method)
10798
10799
10800 #define GMOCK_METHOD6_(tn, constness, ct, Method, ...) \
10801 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
10802 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
10803 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
10804 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
10805 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
10806 GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
10807 GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6) constness { \
10808 GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
10809 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
10810 == 6), \
10811 this_method_does_not_take_6_arguments); \
10812 GMOCK_MOCKER_(6, constness, Method).SetOwnerAndName(this, #Method); \
10813 return GMOCK_MOCKER_(6, constness, Method).Invoke(gmock_a1, gmock_a2, \
10814 gmock_a3, gmock_a4, gmock_a5, gmock_a6); \
10815 } \
10816 ::testing::MockSpec<__VA_ARGS__>& \
10817 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
10818 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
10819 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
10820 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
10821 GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
10822 GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6) constness { \
10823 GMOCK_MOCKER_(6, constness, Method).RegisterOwner(this); \
10824 return GMOCK_MOCKER_(6, constness, Method).With(gmock_a1, gmock_a2, \
10825 gmock_a3, gmock_a4, gmock_a5, gmock_a6); \
10826 } \
10827 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(6, constness, \
10828 Method)
10829
10830
10831 #define GMOCK_METHOD7_(tn, constness, ct, Method, ...) \
10832 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
10833 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
10834 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
10835 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
10836 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
10837 GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
10838 GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
10839 GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7) constness { \
10840 GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
10841 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
10842 == 7), \
10843 this_method_does_not_take_7_arguments); \
10844 GMOCK_MOCKER_(7, constness, Method).SetOwnerAndName(this, #Method); \
10845 return GMOCK_MOCKER_(7, constness, Method).Invoke(gmock_a1, gmock_a2, \
10846 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7); \
10847 } \
10848 ::testing::MockSpec<__VA_ARGS__>& \
10849 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
10850 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
10851 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
10852 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
10853 GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
10854 GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
10855 GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7) constness { \
10856 GMOCK_MOCKER_(7, constness, Method).RegisterOwner(this); \
10857 return GMOCK_MOCKER_(7, constness, Method).With(gmock_a1, gmock_a2, \
10858 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7); \
10859 } \
10860 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(7, constness, \
10861 Method)
10862
10863
10864 #define GMOCK_METHOD8_(tn, constness, ct, Method, ...) \
10865 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
10866 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
10867 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
10868 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
10869 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
10870 GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
10871 GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
10872 GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \
10873 GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8) constness { \
10874 GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
10875 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
10876 == 8), \
10877 this_method_does_not_take_8_arguments); \
10878 GMOCK_MOCKER_(8, constness, Method).SetOwnerAndName(this, #Method); \
10879 return GMOCK_MOCKER_(8, constness, Method).Invoke(gmock_a1, gmock_a2, \
10880 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \
10881 } \
10882 ::testing::MockSpec<__VA_ARGS__>& \
10883 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
10884 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
10885 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
10886 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
10887 GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
10888 GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
10889 GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \
10890 GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8) constness { \
10891 GMOCK_MOCKER_(8, constness, Method).RegisterOwner(this); \
10892 return GMOCK_MOCKER_(8, constness, Method).With(gmock_a1, gmock_a2, \
10893 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \
10894 } \
10895 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(8, constness, \
10896 Method)
10897
10898
10899 #define GMOCK_METHOD9_(tn, constness, ct, Method, ...) \
10900 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
10901 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
10902 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
10903 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
10904 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
10905 GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
10906 GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
10907 GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \
10908 GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8, \
10909 GMOCK_ARG_(tn, 9, __VA_ARGS__) gmock_a9) constness { \
10910 GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
10911 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
10912 == 9), \
10913 this_method_does_not_take_9_arguments); \
10914 GMOCK_MOCKER_(9, constness, Method).SetOwnerAndName(this, #Method); \
10915 return GMOCK_MOCKER_(9, constness, Method).Invoke(gmock_a1, gmock_a2, \
10916 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, \
10917 gmock_a9); \
10918 } \
10919 ::testing::MockSpec<__VA_ARGS__>& \
10920 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
10921 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
10922 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
10923 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
10924 GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
10925 GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
10926 GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \
10927 GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8, \
10928 GMOCK_MATCHER_(tn, 9, __VA_ARGS__) gmock_a9) constness { \
10929 GMOCK_MOCKER_(9, constness, Method).RegisterOwner(this); \
10930 return GMOCK_MOCKER_(9, constness, Method).With(gmock_a1, gmock_a2, \
10931 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, \
10932 gmock_a9); \
10933 } \
10934 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(9, constness, \
10935 Method)
10936
10937
10938 #define GMOCK_METHOD10_(tn, constness, ct, Method, ...) \
10939 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
10940 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
10941 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
10942 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
10943 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
10944 GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
10945 GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
10946 GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \
10947 GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8, \
10948 GMOCK_ARG_(tn, 9, __VA_ARGS__) gmock_a9, \
10949 GMOCK_ARG_(tn, 10, __VA_ARGS__) gmock_a10) constness { \
10950 GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
10951 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
10952 == 10), \
10953 this_method_does_not_take_10_arguments); \
10954 GMOCK_MOCKER_(10, constness, Method).SetOwnerAndName(this, #Method); \
10955 return GMOCK_MOCKER_(10, constness, Method).Invoke(gmock_a1, gmock_a2, \
10956 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9, \
10957 gmock_a10); \
10958 } \
10959 ::testing::MockSpec<__VA_ARGS__>& \
10960 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
10961 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
10962 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
10963 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
10964 GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
10965 GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
10966 GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \
10967 GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8, \
10968 GMOCK_MATCHER_(tn, 9, __VA_ARGS__) gmock_a9, \
10969 GMOCK_MATCHER_(tn, 10, \
10970 __VA_ARGS__) gmock_a10) constness { \
10971 GMOCK_MOCKER_(10, constness, Method).RegisterOwner(this); \
10972 return GMOCK_MOCKER_(10, constness, Method).With(gmock_a1, gmock_a2, \
10973 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9, \
10974 gmock_a10); \
10975 } \
10976 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(10, constness, \
10977 Method)
10978
10979 #define MOCK_METHOD0(m, ...) GMOCK_METHOD0_(, , , m, __VA_ARGS__)
10980 #define MOCK_METHOD1(m, ...) GMOCK_METHOD1_(, , , m, __VA_ARGS__)
10981 #define MOCK_METHOD2(m, ...) GMOCK_METHOD2_(, , , m, __VA_ARGS__)
10982 #define MOCK_METHOD3(m, ...) GMOCK_METHOD3_(, , , m, __VA_ARGS__)
10983 #define MOCK_METHOD4(m, ...) GMOCK_METHOD4_(, , , m, __VA_ARGS__)
10984 #define MOCK_METHOD5(m, ...) GMOCK_METHOD5_(, , , m, __VA_ARGS__)
10985 #define MOCK_METHOD6(m, ...) GMOCK_METHOD6_(, , , m, __VA_ARGS__)
10986 #define MOCK_METHOD7(m, ...) GMOCK_METHOD7_(, , , m, __VA_ARGS__)
10987 #define MOCK_METHOD8(m, ...) GMOCK_METHOD8_(, , , m, __VA_ARGS__)
10988 #define MOCK_METHOD9(m, ...) GMOCK_METHOD9_(, , , m, __VA_ARGS__)
10989 #define MOCK_METHOD10(m, ...) GMOCK_METHOD10_(, , , m, __VA_ARGS__)
10990
10991 #define MOCK_CONST_METHOD0(m, ...) GMOCK_METHOD0_(, const, , m, __VA_ARGS__)
10992 #define MOCK_CONST_METHOD1(m, ...) GMOCK_METHOD1_(, const, , m, __VA_ARGS__)
10993 #define MOCK_CONST_METHOD2(m, ...) GMOCK_METHOD2_(, const, , m, __VA_ARGS__)
10994 #define MOCK_CONST_METHOD3(m, ...) GMOCK_METHOD3_(, const, , m, __VA_ARGS__)
10995 #define MOCK_CONST_METHOD4(m, ...) GMOCK_METHOD4_(, const, , m, __VA_ARGS__)
10996 #define MOCK_CONST_METHOD5(m, ...) GMOCK_METHOD5_(, const, , m, __VA_ARGS__)
10997 #define MOCK_CONST_METHOD6(m, ...) GMOCK_METHOD6_(, const, , m, __VA_ARGS__)
10998 #define MOCK_CONST_METHOD7(m, ...) GMOCK_METHOD7_(, const, , m, __VA_ARGS__)
10999 #define MOCK_CONST_METHOD8(m, ...) GMOCK_METHOD8_(, const, , m, __VA_ARGS__)
11000 #define MOCK_CONST_METHOD9(m, ...) GMOCK_METHOD9_(, const, , m, __VA_ARGS__)
11001 #define MOCK_CONST_METHOD10(m, ...) GMOCK_METHOD10_(, const, , m, __VA_ARGS__)
11002
11003 #define MOCK_METHOD0_T(m, ...) GMOCK_METHOD0_(typename, , , m, __VA_ARGS__)
11004 #define MOCK_METHOD1_T(m, ...) GMOCK_METHOD1_(typename, , , m, __VA_ARGS__)
11005 #define MOCK_METHOD2_T(m, ...) GMOCK_METHOD2_(typename, , , m, __VA_ARGS__)
11006 #define MOCK_METHOD3_T(m, ...) GMOCK_METHOD3_(typename, , , m, __VA_ARGS__)
11007 #define MOCK_METHOD4_T(m, ...) GMOCK_METHOD4_(typename, , , m, __VA_ARGS__)
11008 #define MOCK_METHOD5_T(m, ...) GMOCK_METHOD5_(typename, , , m, __VA_ARGS__)
11009 #define MOCK_METHOD6_T(m, ...) GMOCK_METHOD6_(typename, , , m, __VA_ARGS__)
11010 #define MOCK_METHOD7_T(m, ...) GMOCK_METHOD7_(typename, , , m, __VA_ARGS__)
11011 #define MOCK_METHOD8_T(m, ...) GMOCK_METHOD8_(typename, , , m, __VA_ARGS__)
11012 #define MOCK_METHOD9_T(m, ...) GMOCK_METHOD9_(typename, , , m, __VA_ARGS__)
11013 #define MOCK_METHOD10_T(m, ...) GMOCK_METHOD10_(typename, , , m, __VA_ARGS__)
11014
11015 #define MOCK_CONST_METHOD0_T(m, ...) \
11016 GMOCK_METHOD0_(typename, const, , m, __VA_ARGS__)
11017 #define MOCK_CONST_METHOD1_T(m, ...) \
11018 GMOCK_METHOD1_(typename, const, , m, __VA_ARGS__)
11019 #define MOCK_CONST_METHOD2_T(m, ...) \
11020 GMOCK_METHOD2_(typename, const, , m, __VA_ARGS__)
11021 #define MOCK_CONST_METHOD3_T(m, ...) \
11022 GMOCK_METHOD3_(typename, const, , m, __VA_ARGS__)
11023 #define MOCK_CONST_METHOD4_T(m, ...) \
11024 GMOCK_METHOD4_(typename, const, , m, __VA_ARGS__)
11025 #define MOCK_CONST_METHOD5_T(m, ...) \
11026 GMOCK_METHOD5_(typename, const, , m, __VA_ARGS__)
11027 #define MOCK_CONST_METHOD6_T(m, ...) \
11028 GMOCK_METHOD6_(typename, const, , m, __VA_ARGS__)
11029 #define MOCK_CONST_METHOD7_T(m, ...) \
11030 GMOCK_METHOD7_(typename, const, , m, __VA_ARGS__)
11031 #define MOCK_CONST_METHOD8_T(m, ...) \
11032 GMOCK_METHOD8_(typename, const, , m, __VA_ARGS__)
11033 #define MOCK_CONST_METHOD9_T(m, ...) \
11034 GMOCK_METHOD9_(typename, const, , m, __VA_ARGS__)
11035 #define MOCK_CONST_METHOD10_T(m, ...) \
11036 GMOCK_METHOD10_(typename, const, , m, __VA_ARGS__)
11037
11038 #define MOCK_METHOD0_WITH_CALLTYPE(ct, m, ...) \
11039 GMOCK_METHOD0_(, , ct, m, __VA_ARGS__)
11040 #define MOCK_METHOD1_WITH_CALLTYPE(ct, m, ...) \
11041 GMOCK_METHOD1_(, , ct, m, __VA_ARGS__)
11042 #define MOCK_METHOD2_WITH_CALLTYPE(ct, m, ...) \
11043 GMOCK_METHOD2_(, , ct, m, __VA_ARGS__)
11044 #define MOCK_METHOD3_WITH_CALLTYPE(ct, m, ...) \
11045 GMOCK_METHOD3_(, , ct, m, __VA_ARGS__)
11046 #define MOCK_METHOD4_WITH_CALLTYPE(ct, m, ...) \
11047 GMOCK_METHOD4_(, , ct, m, __VA_ARGS__)
11048 #define MOCK_METHOD5_WITH_CALLTYPE(ct, m, ...) \
11049 GMOCK_METHOD5_(, , ct, m, __VA_ARGS__)
11050 #define MOCK_METHOD6_WITH_CALLTYPE(ct, m, ...) \
11051 GMOCK_METHOD6_(, , ct, m, __VA_ARGS__)
11052 #define MOCK_METHOD7_WITH_CALLTYPE(ct, m, ...) \
11053 GMOCK_METHOD7_(, , ct, m, __VA_ARGS__)
11054 #define MOCK_METHOD8_WITH_CALLTYPE(ct, m, ...) \
11055 GMOCK_METHOD8_(, , ct, m, __VA_ARGS__)
11056 #define MOCK_METHOD9_WITH_CALLTYPE(ct, m, ...) \
11057 GMOCK_METHOD9_(, , ct, m, __VA_ARGS__)
11058 #define MOCK_METHOD10_WITH_CALLTYPE(ct, m, ...) \
11059 GMOCK_METHOD10_(, , ct, m, __VA_ARGS__)
11060
11061 #define MOCK_CONST_METHOD0_WITH_CALLTYPE(ct, m, ...) \
11062 GMOCK_METHOD0_(, const, ct, m, __VA_ARGS__)
11063 #define MOCK_CONST_METHOD1_WITH_CALLTYPE(ct, m, ...) \
11064 GMOCK_METHOD1_(, const, ct, m, __VA_ARGS__)
11065 #define MOCK_CONST_METHOD2_WITH_CALLTYPE(ct, m, ...) \
11066 GMOCK_METHOD2_(, const, ct, m, __VA_ARGS__)
11067 #define MOCK_CONST_METHOD3_WITH_CALLTYPE(ct, m, ...) \
11068 GMOCK_METHOD3_(, const, ct, m, __VA_ARGS__)
11069 #define MOCK_CONST_METHOD4_WITH_CALLTYPE(ct, m, ...) \
11070 GMOCK_METHOD4_(, const, ct, m, __VA_ARGS__)
11071 #define MOCK_CONST_METHOD5_WITH_CALLTYPE(ct, m, ...) \
11072 GMOCK_METHOD5_(, const, ct, m, __VA_ARGS__)
11073 #define MOCK_CONST_METHOD6_WITH_CALLTYPE(ct, m, ...) \
11074 GMOCK_METHOD6_(, const, ct, m, __VA_ARGS__)
11075 #define MOCK_CONST_METHOD7_WITH_CALLTYPE(ct, m, ...) \
11076 GMOCK_METHOD7_(, const, ct, m, __VA_ARGS__)
11077 #define MOCK_CONST_METHOD8_WITH_CALLTYPE(ct, m, ...) \
11078 GMOCK_METHOD8_(, const, ct, m, __VA_ARGS__)
11079 #define MOCK_CONST_METHOD9_WITH_CALLTYPE(ct, m, ...) \
11080 GMOCK_METHOD9_(, const, ct, m, __VA_ARGS__)
11081 #define MOCK_CONST_METHOD10_WITH_CALLTYPE(ct, m, ...) \
11082 GMOCK_METHOD10_(, const, ct, m, __VA_ARGS__)
11083
11084 #define MOCK_METHOD0_T_WITH_CALLTYPE(ct, m, ...) \
11085 GMOCK_METHOD0_(typename, , ct, m, __VA_ARGS__)
11086 #define MOCK_METHOD1_T_WITH_CALLTYPE(ct, m, ...) \
11087 GMOCK_METHOD1_(typename, , ct, m, __VA_ARGS__)
11088 #define MOCK_METHOD2_T_WITH_CALLTYPE(ct, m, ...) \
11089 GMOCK_METHOD2_(typename, , ct, m, __VA_ARGS__)
11090 #define MOCK_METHOD3_T_WITH_CALLTYPE(ct, m, ...) \
11091 GMOCK_METHOD3_(typename, , ct, m, __VA_ARGS__)
11092 #define MOCK_METHOD4_T_WITH_CALLTYPE(ct, m, ...) \
11093 GMOCK_METHOD4_(typename, , ct, m, __VA_ARGS__)
11094 #define MOCK_METHOD5_T_WITH_CALLTYPE(ct, m, ...) \
11095 GMOCK_METHOD5_(typename, , ct, m, __VA_ARGS__)
11096 #define MOCK_METHOD6_T_WITH_CALLTYPE(ct, m, ...) \
11097 GMOCK_METHOD6_(typename, , ct, m, __VA_ARGS__)
11098 #define MOCK_METHOD7_T_WITH_CALLTYPE(ct, m, ...) \
11099 GMOCK_METHOD7_(typename, , ct, m, __VA_ARGS__)
11100 #define MOCK_METHOD8_T_WITH_CALLTYPE(ct, m, ...) \
11101 GMOCK_METHOD8_(typename, , ct, m, __VA_ARGS__)
11102 #define MOCK_METHOD9_T_WITH_CALLTYPE(ct, m, ...) \
11103 GMOCK_METHOD9_(typename, , ct, m, __VA_ARGS__)
11104 #define MOCK_METHOD10_T_WITH_CALLTYPE(ct, m, ...) \
11105 GMOCK_METHOD10_(typename, , ct, m, __VA_ARGS__)
11106
11107 #define MOCK_CONST_METHOD0_T_WITH_CALLTYPE(ct, m, ...) \
11108 GMOCK_METHOD0_(typename, const, ct, m, __VA_ARGS__)
11109 #define MOCK_CONST_METHOD1_T_WITH_CALLTYPE(ct, m, ...) \
11110 GMOCK_METHOD1_(typename, const, ct, m, __VA_ARGS__)
11111 #define MOCK_CONST_METHOD2_T_WITH_CALLTYPE(ct, m, ...) \
11112 GMOCK_METHOD2_(typename, const, ct, m, __VA_ARGS__)
11113 #define MOCK_CONST_METHOD3_T_WITH_CALLTYPE(ct, m, ...) \
11114 GMOCK_METHOD3_(typename, const, ct, m, __VA_ARGS__)
11115 #define MOCK_CONST_METHOD4_T_WITH_CALLTYPE(ct, m, ...) \
11116 GMOCK_METHOD4_(typename, const, ct, m, __VA_ARGS__)
11117 #define MOCK_CONST_METHOD5_T_WITH_CALLTYPE(ct, m, ...) \
11118 GMOCK_METHOD5_(typename, const, ct, m, __VA_ARGS__)
11119 #define MOCK_CONST_METHOD6_T_WITH_CALLTYPE(ct, m, ...) \
11120 GMOCK_METHOD6_(typename, const, ct, m, __VA_ARGS__)
11121 #define MOCK_CONST_METHOD7_T_WITH_CALLTYPE(ct, m, ...) \
11122 GMOCK_METHOD7_(typename, const, ct, m, __VA_ARGS__)
11123 #define MOCK_CONST_METHOD8_T_WITH_CALLTYPE(ct, m, ...) \
11124 GMOCK_METHOD8_(typename, const, ct, m, __VA_ARGS__)
11125 #define MOCK_CONST_METHOD9_T_WITH_CALLTYPE(ct, m, ...) \
11126 GMOCK_METHOD9_(typename, const, ct, m, __VA_ARGS__)
11127 #define MOCK_CONST_METHOD10_T_WITH_CALLTYPE(ct, m, ...) \
11128 GMOCK_METHOD10_(typename, const, ct, m, __VA_ARGS__)
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165 template <typename F>
11166 class MockFunction;
11167
11168 template <typename R>
11169 class MockFunction<R()> {
11170 public:
11171 MockFunction() {}
11172
11173 MOCK_METHOD0_T(Call, R());
11174
11175 private:
11176 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
11177 };
11178
11179 template <typename R, typename A0>
11180 class MockFunction<R(A0)> {
11181 public:
11182 MockFunction() {}
11183
11184 MOCK_METHOD1_T(Call, R(A0));
11185
11186 private:
11187 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
11188 };
11189
11190 template <typename R, typename A0, typename A1>
11191 class MockFunction<R(A0, A1)> {
11192 public:
11193 MockFunction() {}
11194
11195 MOCK_METHOD2_T(Call, R(A0, A1));
11196
11197 private:
11198 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
11199 };
11200
11201 template <typename R, typename A0, typename A1, typename A2>
11202 class MockFunction<R(A0, A1, A2)> {
11203 public:
11204 MockFunction() {}
11205
11206 MOCK_METHOD3_T(Call, R(A0, A1, A2));
11207
11208 private:
11209 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
11210 };
11211
11212 template <typename R, typename A0, typename A1, typename A2, typename A3>
11213 class MockFunction<R(A0, A1, A2, A3)> {
11214 public:
11215 MockFunction() {}
11216
11217 MOCK_METHOD4_T(Call, R(A0, A1, A2, A3));
11218
11219 private:
11220 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
11221 };
11222
11223 template <typename R, typename A0, typename A1, typename A2, typename A3,
11224 typename A4>
11225 class MockFunction<R(A0, A1, A2, A3, A4)> {
11226 public:
11227 MockFunction() {}
11228
11229 MOCK_METHOD5_T(Call, R(A0, A1, A2, A3, A4));
11230
11231 private:
11232 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
11233 };
11234
11235 template <typename R, typename A0, typename A1, typename A2, typename A3,
11236 typename A4, typename A5>
11237 class MockFunction<R(A0, A1, A2, A3, A4, A5)> {
11238 public:
11239 MockFunction() {}
11240
11241 MOCK_METHOD6_T(Call, R(A0, A1, A2, A3, A4, A5));
11242
11243 private:
11244 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
11245 };
11246
11247 template <typename R, typename A0, typename A1, typename A2, typename A3,
11248 typename A4, typename A5, typename A6>
11249 class MockFunction<R(A0, A1, A2, A3, A4, A5, A6)> {
11250 public:
11251 MockFunction() {}
11252
11253 MOCK_METHOD7_T(Call, R(A0, A1, A2, A3, A4, A5, A6));
11254
11255 private:
11256 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
11257 };
11258
11259 template <typename R, typename A0, typename A1, typename A2, typename A3,
11260 typename A4, typename A5, typename A6, typename A7>
11261 class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7)> {
11262 public:
11263 MockFunction() {}
11264
11265 MOCK_METHOD8_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7));
11266
11267 private:
11268 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
11269 };
11270
11271 template <typename R, typename A0, typename A1, typename A2, typename A3,
11272 typename A4, typename A5, typename A6, typename A7, typename A8>
11273 class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8)> {
11274 public:
11275 MockFunction() {}
11276
11277 MOCK_METHOD9_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8));
11278
11279 private:
11280 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
11281 };
11282
11283 template <typename R, typename A0, typename A1, typename A2, typename A3,
11284 typename A4, typename A5, typename A6, typename A7, typename A8,
11285 typename A9>
11286 class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
11287 public:
11288 MockFunction() {}
11289
11290 MOCK_METHOD10_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9));
11291
11292 private:
11293 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
11294 };
11295
11296 }
11297
11298 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
11370 #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
11371
11372
11373 namespace testing {
11374
11375 template <class MockClass>
11376 class NiceMock : public MockClass {
11377 public:
11378
11379
11380 NiceMock() {
11381 ::testing::Mock::AllowUninterestingCalls(
11382 internal::ImplicitCast_<MockClass*>(this));
11383 }
11384
11385
11386
11387 template <typename A1>
11388 explicit NiceMock(const A1& a1) : MockClass(a1) {
11389 ::testing::Mock::AllowUninterestingCalls(
11390 internal::ImplicitCast_<MockClass*>(this));
11391 }
11392 template <typename A1, typename A2>
11393 NiceMock(const A1& a1, const A2& a2) : MockClass(a1, a2) {
11394 ::testing::Mock::AllowUninterestingCalls(
11395 internal::ImplicitCast_<MockClass*>(this));
11396 }
11397
11398 template <typename A1, typename A2, typename A3>
11399 NiceMock(const A1& a1, const A2& a2, const A3& a3) : MockClass(a1, a2, a3) {
11400 ::testing::Mock::AllowUninterestingCalls(
11401 internal::ImplicitCast_<MockClass*>(this));
11402 }
11403
11404 template <typename A1, typename A2, typename A3, typename A4>
11405 NiceMock(const A1& a1, const A2& a2, const A3& a3,
11406 const A4& a4) : MockClass(a1, a2, a3, a4) {
11407 ::testing::Mock::AllowUninterestingCalls(
11408 internal::ImplicitCast_<MockClass*>(this));
11409 }
11410
11411 template <typename A1, typename A2, typename A3, typename A4, typename A5>
11412 NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
11413 const A5& a5) : MockClass(a1, a2, a3, a4, a5) {
11414 ::testing::Mock::AllowUninterestingCalls(
11415 internal::ImplicitCast_<MockClass*>(this));
11416 }
11417
11418 template <typename A1, typename A2, typename A3, typename A4, typename A5,
11419 typename A6>
11420 NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
11421 const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) {
11422 ::testing::Mock::AllowUninterestingCalls(
11423 internal::ImplicitCast_<MockClass*>(this));
11424 }
11425
11426 template <typename A1, typename A2, typename A3, typename A4, typename A5,
11427 typename A6, typename A7>
11428 NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
11429 const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5,
11430 a6, a7) {
11431 ::testing::Mock::AllowUninterestingCalls(
11432 internal::ImplicitCast_<MockClass*>(this));
11433 }
11434
11435 template <typename A1, typename A2, typename A3, typename A4, typename A5,
11436 typename A6, typename A7, typename A8>
11437 NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
11438 const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a1,
11439 a2, a3, a4, a5, a6, a7, a8) {
11440 ::testing::Mock::AllowUninterestingCalls(
11441 internal::ImplicitCast_<MockClass*>(this));
11442 }
11443
11444 template <typename A1, typename A2, typename A3, typename A4, typename A5,
11445 typename A6, typename A7, typename A8, typename A9>
11446 NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
11447 const A5& a5, const A6& a6, const A7& a7, const A8& a8,
11448 const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
11449 ::testing::Mock::AllowUninterestingCalls(
11450 internal::ImplicitCast_<MockClass*>(this));
11451 }
11452
11453 template <typename A1, typename A2, typename A3, typename A4, typename A5,
11454 typename A6, typename A7, typename A8, typename A9, typename A10>
11455 NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
11456 const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9,
11457 const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
11458 ::testing::Mock::AllowUninterestingCalls(
11459 internal::ImplicitCast_<MockClass*>(this));
11460 }
11461
11462 virtual ~NiceMock() {
11463 ::testing::Mock::UnregisterCallReaction(
11464 internal::ImplicitCast_<MockClass*>(this));
11465 }
11466
11467 private:
11468 GTEST_DISALLOW_COPY_AND_ASSIGN_(NiceMock);
11469 };
11470
11471 template <class MockClass>
11472 class NaggyMock : public MockClass {
11473 public:
11474
11475
11476 NaggyMock() {
11477 ::testing::Mock::WarnUninterestingCalls(
11478 internal::ImplicitCast_<MockClass*>(this));
11479 }
11480
11481
11482
11483 template <typename A1>
11484 explicit NaggyMock(const A1& a1) : MockClass(a1) {
11485 ::testing::Mock::WarnUninterestingCalls(
11486 internal::ImplicitCast_<MockClass*>(this));
11487 }
11488 template <typename A1, typename A2>
11489 NaggyMock(const A1& a1, const A2& a2) : MockClass(a1, a2) {
11490 ::testing::Mock::WarnUninterestingCalls(
11491 internal::ImplicitCast_<MockClass*>(this));
11492 }
11493
11494 template <typename A1, typename A2, typename A3>
11495 NaggyMock(const A1& a1, const A2& a2, const A3& a3) : MockClass(a1, a2, a3) {
11496 ::testing::Mock::WarnUninterestingCalls(
11497 internal::ImplicitCast_<MockClass*>(this));
11498 }
11499
11500 template <typename A1, typename A2, typename A3, typename A4>
11501 NaggyMock(const A1& a1, const A2& a2, const A3& a3,
11502 const A4& a4) : MockClass(a1, a2, a3, a4) {
11503 ::testing::Mock::WarnUninterestingCalls(
11504 internal::ImplicitCast_<MockClass*>(this));
11505 }
11506
11507 template <typename A1, typename A2, typename A3, typename A4, typename A5>
11508 NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
11509 const A5& a5) : MockClass(a1, a2, a3, a4, a5) {
11510 ::testing::Mock::WarnUninterestingCalls(
11511 internal::ImplicitCast_<MockClass*>(this));
11512 }
11513
11514 template <typename A1, typename A2, typename A3, typename A4, typename A5,
11515 typename A6>
11516 NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
11517 const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) {
11518 ::testing::Mock::WarnUninterestingCalls(
11519 internal::ImplicitCast_<MockClass*>(this));
11520 }
11521
11522 template <typename A1, typename A2, typename A3, typename A4, typename A5,
11523 typename A6, typename A7>
11524 NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
11525 const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5,
11526 a6, a7) {
11527 ::testing::Mock::WarnUninterestingCalls(
11528 internal::ImplicitCast_<MockClass*>(this));
11529 }
11530
11531 template <typename A1, typename A2, typename A3, typename A4, typename A5,
11532 typename A6, typename A7, typename A8>
11533 NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
11534 const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a1,
11535 a2, a3, a4, a5, a6, a7, a8) {
11536 ::testing::Mock::WarnUninterestingCalls(
11537 internal::ImplicitCast_<MockClass*>(this));
11538 }
11539
11540 template <typename A1, typename A2, typename A3, typename A4, typename A5,
11541 typename A6, typename A7, typename A8, typename A9>
11542 NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
11543 const A5& a5, const A6& a6, const A7& a7, const A8& a8,
11544 const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
11545 ::testing::Mock::WarnUninterestingCalls(
11546 internal::ImplicitCast_<MockClass*>(this));
11547 }
11548
11549 template <typename A1, typename A2, typename A3, typename A4, typename A5,
11550 typename A6, typename A7, typename A8, typename A9, typename A10>
11551 NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
11552 const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9,
11553 const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
11554 ::testing::Mock::WarnUninterestingCalls(
11555 internal::ImplicitCast_<MockClass*>(this));
11556 }
11557
11558 virtual ~NaggyMock() {
11559 ::testing::Mock::UnregisterCallReaction(
11560 internal::ImplicitCast_<MockClass*>(this));
11561 }
11562
11563 private:
11564 GTEST_DISALLOW_COPY_AND_ASSIGN_(NaggyMock);
11565 };
11566
11567 template <class MockClass>
11568 class StrictMock : public MockClass {
11569 public:
11570
11571
11572 StrictMock() {
11573 ::testing::Mock::FailUninterestingCalls(
11574 internal::ImplicitCast_<MockClass*>(this));
11575 }
11576
11577
11578
11579 template <typename A1>
11580 explicit StrictMock(const A1& a1) : MockClass(a1) {
11581 ::testing::Mock::FailUninterestingCalls(
11582 internal::ImplicitCast_<MockClass*>(this));
11583 }
11584 template <typename A1, typename A2>
11585 StrictMock(const A1& a1, const A2& a2) : MockClass(a1, a2) {
11586 ::testing::Mock::FailUninterestingCalls(
11587 internal::ImplicitCast_<MockClass*>(this));
11588 }
11589
11590 template <typename A1, typename A2, typename A3>
11591 StrictMock(const A1& a1, const A2& a2, const A3& a3) : MockClass(a1, a2, a3) {
11592 ::testing::Mock::FailUninterestingCalls(
11593 internal::ImplicitCast_<MockClass*>(this));
11594 }
11595
11596 template <typename A1, typename A2, typename A3, typename A4>
11597 StrictMock(const A1& a1, const A2& a2, const A3& a3,
11598 const A4& a4) : MockClass(a1, a2, a3, a4) {
11599 ::testing::Mock::FailUninterestingCalls(
11600 internal::ImplicitCast_<MockClass*>(this));
11601 }
11602
11603 template <typename A1, typename A2, typename A3, typename A4, typename A5>
11604 StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
11605 const A5& a5) : MockClass(a1, a2, a3, a4, a5) {
11606 ::testing::Mock::FailUninterestingCalls(
11607 internal::ImplicitCast_<MockClass*>(this));
11608 }
11609
11610 template <typename A1, typename A2, typename A3, typename A4, typename A5,
11611 typename A6>
11612 StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
11613 const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) {
11614 ::testing::Mock::FailUninterestingCalls(
11615 internal::ImplicitCast_<MockClass*>(this));
11616 }
11617
11618 template <typename A1, typename A2, typename A3, typename A4, typename A5,
11619 typename A6, typename A7>
11620 StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
11621 const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5,
11622 a6, a7) {
11623 ::testing::Mock::FailUninterestingCalls(
11624 internal::ImplicitCast_<MockClass*>(this));
11625 }
11626
11627 template <typename A1, typename A2, typename A3, typename A4, typename A5,
11628 typename A6, typename A7, typename A8>
11629 StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
11630 const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a1,
11631 a2, a3, a4, a5, a6, a7, a8) {
11632 ::testing::Mock::FailUninterestingCalls(
11633 internal::ImplicitCast_<MockClass*>(this));
11634 }
11635
11636 template <typename A1, typename A2, typename A3, typename A4, typename A5,
11637 typename A6, typename A7, typename A8, typename A9>
11638 StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
11639 const A5& a5, const A6& a6, const A7& a7, const A8& a8,
11640 const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
11641 ::testing::Mock::FailUninterestingCalls(
11642 internal::ImplicitCast_<MockClass*>(this));
11643 }
11644
11645 template <typename A1, typename A2, typename A3, typename A4, typename A5,
11646 typename A6, typename A7, typename A8, typename A9, typename A10>
11647 StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
11648 const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9,
11649 const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
11650 ::testing::Mock::FailUninterestingCalls(
11651 internal::ImplicitCast_<MockClass*>(this));
11652 }
11653
11654 virtual ~StrictMock() {
11655 ::testing::Mock::UnregisterCallReaction(
11656 internal::ImplicitCast_<MockClass*>(this));
11657 }
11658
11659 private:
11660 GTEST_DISALLOW_COPY_AND_ASSIGN_(StrictMock);
11661 };
11662
11663
11664
11665
11666
11667
11668
11669
11670 template <typename MockClass>
11671 class NiceMock<NiceMock<MockClass> >;
11672 template <typename MockClass>
11673 class NiceMock<NaggyMock<MockClass> >;
11674 template <typename MockClass>
11675 class NiceMock<StrictMock<MockClass> >;
11676
11677 template <typename MockClass>
11678 class NaggyMock<NiceMock<MockClass> >;
11679 template <typename MockClass>
11680 class NaggyMock<NaggyMock<MockClass> >;
11681 template <typename MockClass>
11682 class NaggyMock<StrictMock<MockClass> >;
11683
11684 template <typename MockClass>
11685 class StrictMock<NiceMock<MockClass> >;
11686 template <typename MockClass>
11687 class StrictMock<NaggyMock<MockClass> >;
11688 template <typename MockClass>
11689 class StrictMock<StrictMock<MockClass> >;
11690
11691 }
11692
11693 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
11732 #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
11733
11734 #include <iterator>
11735 #include <sstream>
11736 #include <string>
11737 #include <vector>
11738
11739 namespace testing {
11740 namespace internal {
11741
11742
11743 #define GMOCK_FIELD_TYPE_(Tuple, i) \
11744 typename ::std::tr1::tuple_element<i, Tuple>::type
11745
11746
11747
11748
11749
11750
11751
11752
11753
11754
11755
11756
11757 template <class Tuple, int k0 = -1, int k1 = -1, int k2 = -1, int k3 = -1,
11758 int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
11759 int k9 = -1>
11760 class TupleFields;
11761
11762
11763 template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
11764 int k7, int k8, int k9>
11765 class TupleFields {
11766 public:
11767 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
11768 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
11769 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
11770 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
11771 GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8),
11772 GMOCK_FIELD_TYPE_(Tuple, k9)> type;
11773 static type GetSelectedFields(const Tuple& t) {
11774 using ::std::tr1::get;
11775 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
11776 get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t), get<k9>(t));
11777 }
11778 };
11779
11780
11781
11782 template <class Tuple>
11783 class TupleFields<Tuple, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
11784 public:
11785 typedef ::std::tr1::tuple<> type;
11786 static type GetSelectedFields(const Tuple& ) {
11787 using ::std::tr1::get;
11788 return type();
11789 }
11790 };
11791
11792 template <class Tuple, int k0>
11793 class TupleFields<Tuple, k0, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
11794 public:
11795 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0)> type;
11796 static type GetSelectedFields(const Tuple& t) {
11797 using ::std::tr1::get;
11798 return type(get<k0>(t));
11799 }
11800 };
11801
11802 template <class Tuple, int k0, int k1>
11803 class TupleFields<Tuple, k0, k1, -1, -1, -1, -1, -1, -1, -1, -1> {
11804 public:
11805 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
11806 GMOCK_FIELD_TYPE_(Tuple, k1)> type;
11807 static type GetSelectedFields(const Tuple& t) {
11808 using ::std::tr1::get;
11809 return type(get<k0>(t), get<k1>(t));
11810 }
11811 };
11812
11813 template <class Tuple, int k0, int k1, int k2>
11814 class TupleFields<Tuple, k0, k1, k2, -1, -1, -1, -1, -1, -1, -1> {
11815 public:
11816 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
11817 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2)> type;
11818 static type GetSelectedFields(const Tuple& t) {
11819 using ::std::tr1::get;
11820 return type(get<k0>(t), get<k1>(t), get<k2>(t));
11821 }
11822 };
11823
11824 template <class Tuple, int k0, int k1, int k2, int k3>
11825 class TupleFields<Tuple, k0, k1, k2, k3, -1, -1, -1, -1, -1, -1> {
11826 public:
11827 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
11828 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
11829 GMOCK_FIELD_TYPE_(Tuple, k3)> type;
11830 static type GetSelectedFields(const Tuple& t) {
11831 using ::std::tr1::get;
11832 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t));
11833 }
11834 };
11835
11836 template <class Tuple, int k0, int k1, int k2, int k3, int k4>
11837 class TupleFields<Tuple, k0, k1, k2, k3, k4, -1, -1, -1, -1, -1> {
11838 public:
11839 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
11840 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
11841 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4)> type;
11842 static type GetSelectedFields(const Tuple& t) {
11843 using ::std::tr1::get;
11844 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t));
11845 }
11846 };
11847
11848 template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5>
11849 class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, -1, -1, -1, -1> {
11850 public:
11851 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
11852 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
11853 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
11854 GMOCK_FIELD_TYPE_(Tuple, k5)> type;
11855 static type GetSelectedFields(const Tuple& t) {
11856 using ::std::tr1::get;
11857 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
11858 get<k5>(t));
11859 }
11860 };
11861
11862 template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6>
11863 class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, -1, -1, -1> {
11864 public:
11865 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
11866 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
11867 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
11868 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6)> type;
11869 static type GetSelectedFields(const Tuple& t) {
11870 using ::std::tr1::get;
11871 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
11872 get<k5>(t), get<k6>(t));
11873 }
11874 };
11875
11876 template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
11877 int k7>
11878 class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, -1, -1> {
11879 public:
11880 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
11881 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
11882 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
11883 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
11884 GMOCK_FIELD_TYPE_(Tuple, k7)> type;
11885 static type GetSelectedFields(const Tuple& t) {
11886 using ::std::tr1::get;
11887 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
11888 get<k5>(t), get<k6>(t), get<k7>(t));
11889 }
11890 };
11891
11892 template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
11893 int k7, int k8>
11894 class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, k8, -1> {
11895 public:
11896 typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
11897 GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
11898 GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
11899 GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
11900 GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8)> type;
11901 static type GetSelectedFields(const Tuple& t) {
11902 using ::std::tr1::get;
11903 return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
11904 get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t));
11905 }
11906 };
11907
11908 #undef GMOCK_FIELD_TYPE_
11909
11910
11911 template <class ArgsTuple, int k0 = -1, int k1 = -1, int k2 = -1, int k3 = -1,
11912 int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
11913 int k9 = -1>
11914 class ArgsMatcherImpl : public MatcherInterface<ArgsTuple> {
11915 public:
11916
11917 typedef GTEST_REMOVE_REFERENCE_AND_CONST_(ArgsTuple) RawArgsTuple;
11918 typedef typename internal::TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5,
11919 k6, k7, k8, k9>::type SelectedArgs;
11920 typedef Matcher<const SelectedArgs&> MonomorphicInnerMatcher;
11921
11922 template <typename InnerMatcher>
11923 explicit ArgsMatcherImpl(const InnerMatcher& inner_matcher)
11924 : inner_matcher_(SafeMatcherCast<const SelectedArgs&>(inner_matcher)) {}
11925
11926 virtual bool MatchAndExplain(ArgsTuple args,
11927 MatchResultListener* listener) const {
11928 const SelectedArgs& selected_args = GetSelectedArgs(args);
11929 if (!listener->IsInterested())
11930 return inner_matcher_.Matches(selected_args);
11931
11932 PrintIndices(listener->stream());
11933 *listener << "are " << PrintToString(selected_args);
11934
11935 StringMatchResultListener inner_listener;
11936 const bool match = inner_matcher_.MatchAndExplain(selected_args,
11937 &inner_listener);
11938 PrintIfNotEmpty(inner_listener.str(), listener->stream());
11939 return match;
11940 }
11941
11942 virtual void DescribeTo(::std::ostream* os) const {
11943 *os << "are a tuple ";
11944 PrintIndices(os);
11945 inner_matcher_.DescribeTo(os);
11946 }
11947
11948 virtual void DescribeNegationTo(::std::ostream* os) const {
11949 *os << "are a tuple ";
11950 PrintIndices(os);
11951 inner_matcher_.DescribeNegationTo(os);
11952 }
11953
11954 private:
11955 static SelectedArgs GetSelectedArgs(ArgsTuple args) {
11956 return TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5, k6, k7, k8,
11957 k9>::GetSelectedFields(args);
11958 }
11959
11960
11961 static void PrintIndices(::std::ostream* os) {
11962 *os << "whose fields (";
11963 const int indices[10] = { k0, k1, k2, k3, k4, k5, k6, k7, k8, k9 };
11964 for (int i = 0; i < 10; i++) {
11965 if (indices[i] < 0)
11966 break;
11967
11968 if (i >= 1)
11969 *os << ", ";
11970
11971 *os << "#" << indices[i];
11972 }
11973 *os << ") ";
11974 }
11975
11976 const MonomorphicInnerMatcher inner_matcher_;
11977
11978 GTEST_DISALLOW_ASSIGN_(ArgsMatcherImpl);
11979 };
11980
11981 template <class InnerMatcher, int k0 = -1, int k1 = -1, int k2 = -1,
11982 int k3 = -1, int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1,
11983 int k8 = -1, int k9 = -1>
11984 class ArgsMatcher {
11985 public:
11986 explicit ArgsMatcher(const InnerMatcher& inner_matcher)
11987 : inner_matcher_(inner_matcher) {}
11988
11989 template <typename ArgsTuple>
11990 operator Matcher<ArgsTuple>() const {
11991 return MakeMatcher(new ArgsMatcherImpl<ArgsTuple, k0, k1, k2, k3, k4, k5,
11992 k6, k7, k8, k9>(inner_matcher_));
11993 }
11994
11995 private:
11996 const InnerMatcher inner_matcher_;
11997
11998 GTEST_DISALLOW_ASSIGN_(ArgsMatcher);
11999 };
12000
12001
12002
12003
12004
12005
12006
12007 template <typename M1>
12008 struct AllOfResult1 {
12009 typedef M1 type;
12010 };
12011
12012 template <typename M1, typename M2>
12013 struct AllOfResult2 {
12014 typedef BothOfMatcher<
12015 typename AllOfResult1<M1>::type,
12016 typename AllOfResult1<M2>::type
12017 > type;
12018 };
12019
12020 template <typename M1, typename M2, typename M3>
12021 struct AllOfResult3 {
12022 typedef BothOfMatcher<
12023 typename AllOfResult1<M1>::type,
12024 typename AllOfResult2<M2, M3>::type
12025 > type;
12026 };
12027
12028 template <typename M1, typename M2, typename M3, typename M4>
12029 struct AllOfResult4 {
12030 typedef BothOfMatcher<
12031 typename AllOfResult2<M1, M2>::type,
12032 typename AllOfResult2<M3, M4>::type
12033 > type;
12034 };
12035
12036 template <typename M1, typename M2, typename M3, typename M4, typename M5>
12037 struct AllOfResult5 {
12038 typedef BothOfMatcher<
12039 typename AllOfResult2<M1, M2>::type,
12040 typename AllOfResult3<M3, M4, M5>::type
12041 > type;
12042 };
12043
12044 template <typename M1, typename M2, typename M3, typename M4, typename M5,
12045 typename M6>
12046 struct AllOfResult6 {
12047 typedef BothOfMatcher<
12048 typename AllOfResult3<M1, M2, M3>::type,
12049 typename AllOfResult3<M4, M5, M6>::type
12050 > type;
12051 };
12052
12053 template <typename M1, typename M2, typename M3, typename M4, typename M5,
12054 typename M6, typename M7>
12055 struct AllOfResult7 {
12056 typedef BothOfMatcher<
12057 typename AllOfResult3<M1, M2, M3>::type,
12058 typename AllOfResult4<M4, M5, M6, M7>::type
12059 > type;
12060 };
12061
12062 template <typename M1, typename M2, typename M3, typename M4, typename M5,
12063 typename M6, typename M7, typename M8>
12064 struct AllOfResult8 {
12065 typedef BothOfMatcher<
12066 typename AllOfResult4<M1, M2, M3, M4>::type,
12067 typename AllOfResult4<M5, M6, M7, M8>::type
12068 > type;
12069 };
12070
12071 template <typename M1, typename M2, typename M3, typename M4, typename M5,
12072 typename M6, typename M7, typename M8, typename M9>
12073 struct AllOfResult9 {
12074 typedef BothOfMatcher<
12075 typename AllOfResult4<M1, M2, M3, M4>::type,
12076 typename AllOfResult5<M5, M6, M7, M8, M9>::type
12077 > type;
12078 };
12079
12080 template <typename M1, typename M2, typename M3, typename M4, typename M5,
12081 typename M6, typename M7, typename M8, typename M9, typename M10>
12082 struct AllOfResult10 {
12083 typedef BothOfMatcher<
12084 typename AllOfResult5<M1, M2, M3, M4, M5>::type,
12085 typename AllOfResult5<M6, M7, M8, M9, M10>::type
12086 > type;
12087 };
12088
12089
12090
12091
12092
12093
12094
12095 template <typename M1>
12096 struct AnyOfResult1 {
12097 typedef M1 type;
12098 };
12099
12100 template <typename M1, typename M2>
12101 struct AnyOfResult2 {
12102 typedef EitherOfMatcher<
12103 typename AnyOfResult1<M1>::type,
12104 typename AnyOfResult1<M2>::type
12105 > type;
12106 };
12107
12108 template <typename M1, typename M2, typename M3>
12109 struct AnyOfResult3 {
12110 typedef EitherOfMatcher<
12111 typename AnyOfResult1<M1>::type,
12112 typename AnyOfResult2<M2, M3>::type
12113 > type;
12114 };
12115
12116 template <typename M1, typename M2, typename M3, typename M4>
12117 struct AnyOfResult4 {
12118 typedef EitherOfMatcher<
12119 typename AnyOfResult2<M1, M2>::type,
12120 typename AnyOfResult2<M3, M4>::type
12121 > type;
12122 };
12123
12124 template <typename M1, typename M2, typename M3, typename M4, typename M5>
12125 struct AnyOfResult5 {
12126 typedef EitherOfMatcher<
12127 typename AnyOfResult2<M1, M2>::type,
12128 typename AnyOfResult3<M3, M4, M5>::type
12129 > type;
12130 };
12131
12132 template <typename M1, typename M2, typename M3, typename M4, typename M5,
12133 typename M6>
12134 struct AnyOfResult6 {
12135 typedef EitherOfMatcher<
12136 typename AnyOfResult3<M1, M2, M3>::type,
12137 typename AnyOfResult3<M4, M5, M6>::type
12138 > type;
12139 };
12140
12141 template <typename M1, typename M2, typename M3, typename M4, typename M5,
12142 typename M6, typename M7>
12143 struct AnyOfResult7 {
12144 typedef EitherOfMatcher<
12145 typename AnyOfResult3<M1, M2, M3>::type,
12146 typename AnyOfResult4<M4, M5, M6, M7>::type
12147 > type;
12148 };
12149
12150 template <typename M1, typename M2, typename M3, typename M4, typename M5,
12151 typename M6, typename M7, typename M8>
12152 struct AnyOfResult8 {
12153 typedef EitherOfMatcher<
12154 typename AnyOfResult4<M1, M2, M3, M4>::type,
12155 typename AnyOfResult4<M5, M6, M7, M8>::type
12156 > type;
12157 };
12158
12159 template <typename M1, typename M2, typename M3, typename M4, typename M5,
12160 typename M6, typename M7, typename M8, typename M9>
12161 struct AnyOfResult9 {
12162 typedef EitherOfMatcher<
12163 typename AnyOfResult4<M1, M2, M3, M4>::type,
12164 typename AnyOfResult5<M5, M6, M7, M8, M9>::type
12165 > type;
12166 };
12167
12168 template <typename M1, typename M2, typename M3, typename M4, typename M5,
12169 typename M6, typename M7, typename M8, typename M9, typename M10>
12170 struct AnyOfResult10 {
12171 typedef EitherOfMatcher<
12172 typename AnyOfResult5<M1, M2, M3, M4, M5>::type,
12173 typename AnyOfResult5<M6, M7, M8, M9, M10>::type
12174 > type;
12175 };
12176
12177 }
12178
12179
12180
12181
12182 template <typename InnerMatcher>
12183 inline internal::ArgsMatcher<InnerMatcher>
12184 Args(const InnerMatcher& matcher) {
12185 return internal::ArgsMatcher<InnerMatcher>(matcher);
12186 }
12187
12188 template <int k1, typename InnerMatcher>
12189 inline internal::ArgsMatcher<InnerMatcher, k1>
12190 Args(const InnerMatcher& matcher) {
12191 return internal::ArgsMatcher<InnerMatcher, k1>(matcher);
12192 }
12193
12194 template <int k1, int k2, typename InnerMatcher>
12195 inline internal::ArgsMatcher<InnerMatcher, k1, k2>
12196 Args(const InnerMatcher& matcher) {
12197 return internal::ArgsMatcher<InnerMatcher, k1, k2>(matcher);
12198 }
12199
12200 template <int k1, int k2, int k3, typename InnerMatcher>
12201 inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3>
12202 Args(const InnerMatcher& matcher) {
12203 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3>(matcher);
12204 }
12205
12206 template <int k1, int k2, int k3, int k4, typename InnerMatcher>
12207 inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>
12208 Args(const InnerMatcher& matcher) {
12209 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>(matcher);
12210 }
12211
12212 template <int k1, int k2, int k3, int k4, int k5, typename InnerMatcher>
12213 inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>
12214 Args(const InnerMatcher& matcher) {
12215 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>(matcher);
12216 }
12217
12218 template <int k1, int k2, int k3, int k4, int k5, int k6, typename InnerMatcher>
12219 inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>
12220 Args(const InnerMatcher& matcher) {
12221 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>(matcher);
12222 }
12223
12224 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7,
12225 typename InnerMatcher>
12226 inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7>
12227 Args(const InnerMatcher& matcher) {
12228 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6,
12229 k7>(matcher);
12230 }
12231
12232 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
12233 typename InnerMatcher>
12234 inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8>
12235 Args(const InnerMatcher& matcher) {
12236 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7,
12237 k8>(matcher);
12238 }
12239
12240 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
12241 int k9, typename InnerMatcher>
12242 inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9>
12243 Args(const InnerMatcher& matcher) {
12244 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
12245 k9>(matcher);
12246 }
12247
12248 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
12249 int k9, int k10, typename InnerMatcher>
12250 inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9,
12251 k10>
12252 Args(const InnerMatcher& matcher) {
12253 return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
12254 k9, k10>(matcher);
12255 }
12256
12257
12258
12259
12260
12261
12262
12263
12264
12265
12266
12267
12268
12269
12270
12271 inline internal::ElementsAreMatcher<
12272 std::tr1::tuple<> >
12273 ElementsAre() {
12274 typedef std::tr1::tuple<> Args;
12275 return internal::ElementsAreMatcher<Args>(Args());
12276 }
12277
12278 template <typename T1>
12279 inline internal::ElementsAreMatcher<
12280 std::tr1::tuple<
12281 typename internal::DecayArray<T1>::type> >
12282 ElementsAre(const T1& e1) {
12283 typedef std::tr1::tuple<
12284 typename internal::DecayArray<T1>::type> Args;
12285 return internal::ElementsAreMatcher<Args>(Args(e1));
12286 }
12287
12288 template <typename T1, typename T2>
12289 inline internal::ElementsAreMatcher<
12290 std::tr1::tuple<
12291 typename internal::DecayArray<T1>::type,
12292 typename internal::DecayArray<T2>::type> >
12293 ElementsAre(const T1& e1, const T2& e2) {
12294 typedef std::tr1::tuple<
12295 typename internal::DecayArray<T1>::type,
12296 typename internal::DecayArray<T2>::type> Args;
12297 return internal::ElementsAreMatcher<Args>(Args(e1, e2));
12298 }
12299
12300 template <typename T1, typename T2, typename T3>
12301 inline internal::ElementsAreMatcher<
12302 std::tr1::tuple<
12303 typename internal::DecayArray<T1>::type,
12304 typename internal::DecayArray<T2>::type,
12305 typename internal::DecayArray<T3>::type> >
12306 ElementsAre(const T1& e1, const T2& e2, const T3& e3) {
12307 typedef std::tr1::tuple<
12308 typename internal::DecayArray<T1>::type,
12309 typename internal::DecayArray<T2>::type,
12310 typename internal::DecayArray<T3>::type> Args;
12311 return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3));
12312 }
12313
12314 template <typename T1, typename T2, typename T3, typename T4>
12315 inline internal::ElementsAreMatcher<
12316 std::tr1::tuple<
12317 typename internal::DecayArray<T1>::type,
12318 typename internal::DecayArray<T2>::type,
12319 typename internal::DecayArray<T3>::type,
12320 typename internal::DecayArray<T4>::type> >
12321 ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4) {
12322 typedef std::tr1::tuple<
12323 typename internal::DecayArray<T1>::type,
12324 typename internal::DecayArray<T2>::type,
12325 typename internal::DecayArray<T3>::type,
12326 typename internal::DecayArray<T4>::type> Args;
12327 return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4));
12328 }
12329
12330 template <typename T1, typename T2, typename T3, typename T4, typename T5>
12331 inline internal::ElementsAreMatcher<
12332 std::tr1::tuple<
12333 typename internal::DecayArray<T1>::type,
12334 typename internal::DecayArray<T2>::type,
12335 typename internal::DecayArray<T3>::type,
12336 typename internal::DecayArray<T4>::type,
12337 typename internal::DecayArray<T5>::type> >
12338 ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
12339 const T5& e5) {
12340 typedef std::tr1::tuple<
12341 typename internal::DecayArray<T1>::type,
12342 typename internal::DecayArray<T2>::type,
12343 typename internal::DecayArray<T3>::type,
12344 typename internal::DecayArray<T4>::type,
12345 typename internal::DecayArray<T5>::type> Args;
12346 return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5));
12347 }
12348
12349 template <typename T1, typename T2, typename T3, typename T4, typename T5,
12350 typename T6>
12351 inline internal::ElementsAreMatcher<
12352 std::tr1::tuple<
12353 typename internal::DecayArray<T1>::type,
12354 typename internal::DecayArray<T2>::type,
12355 typename internal::DecayArray<T3>::type,
12356 typename internal::DecayArray<T4>::type,
12357 typename internal::DecayArray<T5>::type,
12358 typename internal::DecayArray<T6>::type> >
12359 ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
12360 const T5& e5, const T6& e6) {
12361 typedef std::tr1::tuple<
12362 typename internal::DecayArray<T1>::type,
12363 typename internal::DecayArray<T2>::type,
12364 typename internal::DecayArray<T3>::type,
12365 typename internal::DecayArray<T4>::type,
12366 typename internal::DecayArray<T5>::type,
12367 typename internal::DecayArray<T6>::type> Args;
12368 return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6));
12369 }
12370
12371 template <typename T1, typename T2, typename T3, typename T4, typename T5,
12372 typename T6, typename T7>
12373 inline internal::ElementsAreMatcher<
12374 std::tr1::tuple<
12375 typename internal::DecayArray<T1>::type,
12376 typename internal::DecayArray<T2>::type,
12377 typename internal::DecayArray<T3>::type,
12378 typename internal::DecayArray<T4>::type,
12379 typename internal::DecayArray<T5>::type,
12380 typename internal::DecayArray<T6>::type,
12381 typename internal::DecayArray<T7>::type> >
12382 ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
12383 const T5& e5, const T6& e6, const T7& e7) {
12384 typedef std::tr1::tuple<
12385 typename internal::DecayArray<T1>::type,
12386 typename internal::DecayArray<T2>::type,
12387 typename internal::DecayArray<T3>::type,
12388 typename internal::DecayArray<T4>::type,
12389 typename internal::DecayArray<T5>::type,
12390 typename internal::DecayArray<T6>::type,
12391 typename internal::DecayArray<T7>::type> Args;
12392 return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7));
12393 }
12394
12395 template <typename T1, typename T2, typename T3, typename T4, typename T5,
12396 typename T6, typename T7, typename T8>
12397 inline internal::ElementsAreMatcher<
12398 std::tr1::tuple<
12399 typename internal::DecayArray<T1>::type,
12400 typename internal::DecayArray<T2>::type,
12401 typename internal::DecayArray<T3>::type,
12402 typename internal::DecayArray<T4>::type,
12403 typename internal::DecayArray<T5>::type,
12404 typename internal::DecayArray<T6>::type,
12405 typename internal::DecayArray<T7>::type,
12406 typename internal::DecayArray<T8>::type> >
12407 ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
12408 const T5& e5, const T6& e6, const T7& e7, const T8& e8) {
12409 typedef std::tr1::tuple<
12410 typename internal::DecayArray<T1>::type,
12411 typename internal::DecayArray<T2>::type,
12412 typename internal::DecayArray<T3>::type,
12413 typename internal::DecayArray<T4>::type,
12414 typename internal::DecayArray<T5>::type,
12415 typename internal::DecayArray<T6>::type,
12416 typename internal::DecayArray<T7>::type,
12417 typename internal::DecayArray<T8>::type> Args;
12418 return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7,
12419 e8));
12420 }
12421
12422 template <typename T1, typename T2, typename T3, typename T4, typename T5,
12423 typename T6, typename T7, typename T8, typename T9>
12424 inline internal::ElementsAreMatcher<
12425 std::tr1::tuple<
12426 typename internal::DecayArray<T1>::type,
12427 typename internal::DecayArray<T2>::type,
12428 typename internal::DecayArray<T3>::type,
12429 typename internal::DecayArray<T4>::type,
12430 typename internal::DecayArray<T5>::type,
12431 typename internal::DecayArray<T6>::type,
12432 typename internal::DecayArray<T7>::type,
12433 typename internal::DecayArray<T8>::type,
12434 typename internal::DecayArray<T9>::type> >
12435 ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
12436 const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9) {
12437 typedef std::tr1::tuple<
12438 typename internal::DecayArray<T1>::type,
12439 typename internal::DecayArray<T2>::type,
12440 typename internal::DecayArray<T3>::type,
12441 typename internal::DecayArray<T4>::type,
12442 typename internal::DecayArray<T5>::type,
12443 typename internal::DecayArray<T6>::type,
12444 typename internal::DecayArray<T7>::type,
12445 typename internal::DecayArray<T8>::type,
12446 typename internal::DecayArray<T9>::type> Args;
12447 return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7,
12448 e8, e9));
12449 }
12450
12451 template <typename T1, typename T2, typename T3, typename T4, typename T5,
12452 typename T6, typename T7, typename T8, typename T9, typename T10>
12453 inline internal::ElementsAreMatcher<
12454 std::tr1::tuple<
12455 typename internal::DecayArray<T1>::type,
12456 typename internal::DecayArray<T2>::type,
12457 typename internal::DecayArray<T3>::type,
12458 typename internal::DecayArray<T4>::type,
12459 typename internal::DecayArray<T5>::type,
12460 typename internal::DecayArray<T6>::type,
12461 typename internal::DecayArray<T7>::type,
12462 typename internal::DecayArray<T8>::type,
12463 typename internal::DecayArray<T9>::type,
12464 typename internal::DecayArray<T10>::type> >
12465 ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
12466 const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,
12467 const T10& e10) {
12468 typedef std::tr1::tuple<
12469 typename internal::DecayArray<T1>::type,
12470 typename internal::DecayArray<T2>::type,
12471 typename internal::DecayArray<T3>::type,
12472 typename internal::DecayArray<T4>::type,
12473 typename internal::DecayArray<T5>::type,
12474 typename internal::DecayArray<T6>::type,
12475 typename internal::DecayArray<T7>::type,
12476 typename internal::DecayArray<T8>::type,
12477 typename internal::DecayArray<T9>::type,
12478 typename internal::DecayArray<T10>::type> Args;
12479 return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7,
12480 e8, e9, e10));
12481 }
12482
12483
12484
12485
12486 inline internal::UnorderedElementsAreMatcher<
12487 std::tr1::tuple<> >
12488 UnorderedElementsAre() {
12489 typedef std::tr1::tuple<> Args;
12490 return internal::UnorderedElementsAreMatcher<Args>(Args());
12491 }
12492
12493 template <typename T1>
12494 inline internal::UnorderedElementsAreMatcher<
12495 std::tr1::tuple<
12496 typename internal::DecayArray<T1>::type> >
12497 UnorderedElementsAre(const T1& e1) {
12498 typedef std::tr1::tuple<
12499 typename internal::DecayArray<T1>::type> Args;
12500 return internal::UnorderedElementsAreMatcher<Args>(Args(e1));
12501 }
12502
12503 template <typename T1, typename T2>
12504 inline internal::UnorderedElementsAreMatcher<
12505 std::tr1::tuple<
12506 typename internal::DecayArray<T1>::type,
12507 typename internal::DecayArray<T2>::type> >
12508 UnorderedElementsAre(const T1& e1, const T2& e2) {
12509 typedef std::tr1::tuple<
12510 typename internal::DecayArray<T1>::type,
12511 typename internal::DecayArray<T2>::type> Args;
12512 return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2));
12513 }
12514
12515 template <typename T1, typename T2, typename T3>
12516 inline internal::UnorderedElementsAreMatcher<
12517 std::tr1::tuple<
12518 typename internal::DecayArray<T1>::type,
12519 typename internal::DecayArray<T2>::type,
12520 typename internal::DecayArray<T3>::type> >
12521 UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3) {
12522 typedef std::tr1::tuple<
12523 typename internal::DecayArray<T1>::type,
12524 typename internal::DecayArray<T2>::type,
12525 typename internal::DecayArray<T3>::type> Args;
12526 return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3));
12527 }
12528
12529 template <typename T1, typename T2, typename T3, typename T4>
12530 inline internal::UnorderedElementsAreMatcher<
12531 std::tr1::tuple<
12532 typename internal::DecayArray<T1>::type,
12533 typename internal::DecayArray<T2>::type,
12534 typename internal::DecayArray<T3>::type,
12535 typename internal::DecayArray<T4>::type> >
12536 UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4) {
12537 typedef std::tr1::tuple<
12538 typename internal::DecayArray<T1>::type,
12539 typename internal::DecayArray<T2>::type,
12540 typename internal::DecayArray<T3>::type,
12541 typename internal::DecayArray<T4>::type> Args;
12542 return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4));
12543 }
12544
12545 template <typename T1, typename T2, typename T3, typename T4, typename T5>
12546 inline internal::UnorderedElementsAreMatcher<
12547 std::tr1::tuple<
12548 typename internal::DecayArray<T1>::type,
12549 typename internal::DecayArray<T2>::type,
12550 typename internal::DecayArray<T3>::type,
12551 typename internal::DecayArray<T4>::type,
12552 typename internal::DecayArray<T5>::type> >
12553 UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
12554 const T5& e5) {
12555 typedef std::tr1::tuple<
12556 typename internal::DecayArray<T1>::type,
12557 typename internal::DecayArray<T2>::type,
12558 typename internal::DecayArray<T3>::type,
12559 typename internal::DecayArray<T4>::type,
12560 typename internal::DecayArray<T5>::type> Args;
12561 return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5));
12562 }
12563
12564 template <typename T1, typename T2, typename T3, typename T4, typename T5,
12565 typename T6>
12566 inline internal::UnorderedElementsAreMatcher<
12567 std::tr1::tuple<
12568 typename internal::DecayArray<T1>::type,
12569 typename internal::DecayArray<T2>::type,
12570 typename internal::DecayArray<T3>::type,
12571 typename internal::DecayArray<T4>::type,
12572 typename internal::DecayArray<T5>::type,
12573 typename internal::DecayArray<T6>::type> >
12574 UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
12575 const T5& e5, const T6& e6) {
12576 typedef std::tr1::tuple<
12577 typename internal::DecayArray<T1>::type,
12578 typename internal::DecayArray<T2>::type,
12579 typename internal::DecayArray<T3>::type,
12580 typename internal::DecayArray<T4>::type,
12581 typename internal::DecayArray<T5>::type,
12582 typename internal::DecayArray<T6>::type> Args;
12583 return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
12584 e6));
12585 }
12586
12587 template <typename T1, typename T2, typename T3, typename T4, typename T5,
12588 typename T6, typename T7>
12589 inline internal::UnorderedElementsAreMatcher<
12590 std::tr1::tuple<
12591 typename internal::DecayArray<T1>::type,
12592 typename internal::DecayArray<T2>::type,
12593 typename internal::DecayArray<T3>::type,
12594 typename internal::DecayArray<T4>::type,
12595 typename internal::DecayArray<T5>::type,
12596 typename internal::DecayArray<T6>::type,
12597 typename internal::DecayArray<T7>::type> >
12598 UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
12599 const T5& e5, const T6& e6, const T7& e7) {
12600 typedef std::tr1::tuple<
12601 typename internal::DecayArray<T1>::type,
12602 typename internal::DecayArray<T2>::type,
12603 typename internal::DecayArray<T3>::type,
12604 typename internal::DecayArray<T4>::type,
12605 typename internal::DecayArray<T5>::type,
12606 typename internal::DecayArray<T6>::type,
12607 typename internal::DecayArray<T7>::type> Args;
12608 return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
12609 e6, e7));
12610 }
12611
12612 template <typename T1, typename T2, typename T3, typename T4, typename T5,
12613 typename T6, typename T7, typename T8>
12614 inline internal::UnorderedElementsAreMatcher<
12615 std::tr1::tuple<
12616 typename internal::DecayArray<T1>::type,
12617 typename internal::DecayArray<T2>::type,
12618 typename internal::DecayArray<T3>::type,
12619 typename internal::DecayArray<T4>::type,
12620 typename internal::DecayArray<T5>::type,
12621 typename internal::DecayArray<T6>::type,
12622 typename internal::DecayArray<T7>::type,
12623 typename internal::DecayArray<T8>::type> >
12624 UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
12625 const T5& e5, const T6& e6, const T7& e7, const T8& e8) {
12626 typedef std::tr1::tuple<
12627 typename internal::DecayArray<T1>::type,
12628 typename internal::DecayArray<T2>::type,
12629 typename internal::DecayArray<T3>::type,
12630 typename internal::DecayArray<T4>::type,
12631 typename internal::DecayArray<T5>::type,
12632 typename internal::DecayArray<T6>::type,
12633 typename internal::DecayArray<T7>::type,
12634 typename internal::DecayArray<T8>::type> Args;
12635 return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
12636 e6, e7, e8));
12637 }
12638
12639 template <typename T1, typename T2, typename T3, typename T4, typename T5,
12640 typename T6, typename T7, typename T8, typename T9>
12641 inline internal::UnorderedElementsAreMatcher<
12642 std::tr1::tuple<
12643 typename internal::DecayArray<T1>::type,
12644 typename internal::DecayArray<T2>::type,
12645 typename internal::DecayArray<T3>::type,
12646 typename internal::DecayArray<T4>::type,
12647 typename internal::DecayArray<T5>::type,
12648 typename internal::DecayArray<T6>::type,
12649 typename internal::DecayArray<T7>::type,
12650 typename internal::DecayArray<T8>::type,
12651 typename internal::DecayArray<T9>::type> >
12652 UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
12653 const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9) {
12654 typedef std::tr1::tuple<
12655 typename internal::DecayArray<T1>::type,
12656 typename internal::DecayArray<T2>::type,
12657 typename internal::DecayArray<T3>::type,
12658 typename internal::DecayArray<T4>::type,
12659 typename internal::DecayArray<T5>::type,
12660 typename internal::DecayArray<T6>::type,
12661 typename internal::DecayArray<T7>::type,
12662 typename internal::DecayArray<T8>::type,
12663 typename internal::DecayArray<T9>::type> Args;
12664 return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
12665 e6, e7, e8, e9));
12666 }
12667
12668 template <typename T1, typename T2, typename T3, typename T4, typename T5,
12669 typename T6, typename T7, typename T8, typename T9, typename T10>
12670 inline internal::UnorderedElementsAreMatcher<
12671 std::tr1::tuple<
12672 typename internal::DecayArray<T1>::type,
12673 typename internal::DecayArray<T2>::type,
12674 typename internal::DecayArray<T3>::type,
12675 typename internal::DecayArray<T4>::type,
12676 typename internal::DecayArray<T5>::type,
12677 typename internal::DecayArray<T6>::type,
12678 typename internal::DecayArray<T7>::type,
12679 typename internal::DecayArray<T8>::type,
12680 typename internal::DecayArray<T9>::type,
12681 typename internal::DecayArray<T10>::type> >
12682 UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
12683 const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,
12684 const T10& e10) {
12685 typedef std::tr1::tuple<
12686 typename internal::DecayArray<T1>::type,
12687 typename internal::DecayArray<T2>::type,
12688 typename internal::DecayArray<T3>::type,
12689 typename internal::DecayArray<T4>::type,
12690 typename internal::DecayArray<T5>::type,
12691 typename internal::DecayArray<T6>::type,
12692 typename internal::DecayArray<T7>::type,
12693 typename internal::DecayArray<T8>::type,
12694 typename internal::DecayArray<T9>::type,
12695 typename internal::DecayArray<T10>::type> Args;
12696 return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
12697 e6, e7, e8, e9, e10));
12698 }
12699
12700
12701
12702
12703 template <typename M1, typename M2>
12704 inline typename internal::AllOfResult2<M1, M2>::type
12705 AllOf(M1 m1, M2 m2) {
12706 return typename internal::AllOfResult2<M1, M2>::type(
12707 m1,
12708 m2);
12709 }
12710
12711 template <typename M1, typename M2, typename M3>
12712 inline typename internal::AllOfResult3<M1, M2, M3>::type
12713 AllOf(M1 m1, M2 m2, M3 m3) {
12714 return typename internal::AllOfResult3<M1, M2, M3>::type(
12715 m1,
12716 ::testing::AllOf(m2, m3));
12717 }
12718
12719 template <typename M1, typename M2, typename M3, typename M4>
12720 inline typename internal::AllOfResult4<M1, M2, M3, M4>::type
12721 AllOf(M1 m1, M2 m2, M3 m3, M4 m4) {
12722 return typename internal::AllOfResult4<M1, M2, M3, M4>::type(
12723 ::testing::AllOf(m1, m2),
12724 ::testing::AllOf(m3, m4));
12725 }
12726
12727 template <typename M1, typename M2, typename M3, typename M4, typename M5>
12728 inline typename internal::AllOfResult5<M1, M2, M3, M4, M5>::type
12729 AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5) {
12730 return typename internal::AllOfResult5<M1, M2, M3, M4, M5>::type(
12731 ::testing::AllOf(m1, m2),
12732 ::testing::AllOf(m3, m4, m5));
12733 }
12734
12735 template <typename M1, typename M2, typename M3, typename M4, typename M5,
12736 typename M6>
12737 inline typename internal::AllOfResult6<M1, M2, M3, M4, M5, M6>::type
12738 AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6) {
12739 return typename internal::AllOfResult6<M1, M2, M3, M4, M5, M6>::type(
12740 ::testing::AllOf(m1, m2, m3),
12741 ::testing::AllOf(m4, m5, m6));
12742 }
12743
12744 template <typename M1, typename M2, typename M3, typename M4, typename M5,
12745 typename M6, typename M7>
12746 inline typename internal::AllOfResult7<M1, M2, M3, M4, M5, M6, M7>::type
12747 AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7) {
12748 return typename internal::AllOfResult7<M1, M2, M3, M4, M5, M6, M7>::type(
12749 ::testing::AllOf(m1, m2, m3),
12750 ::testing::AllOf(m4, m5, m6, m7));
12751 }
12752
12753 template <typename M1, typename M2, typename M3, typename M4, typename M5,
12754 typename M6, typename M7, typename M8>
12755 inline typename internal::AllOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type
12756 AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8) {
12757 return typename internal::AllOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type(
12758 ::testing::AllOf(m1, m2, m3, m4),
12759 ::testing::AllOf(m5, m6, m7, m8));
12760 }
12761
12762 template <typename M1, typename M2, typename M3, typename M4, typename M5,
12763 typename M6, typename M7, typename M8, typename M9>
12764 inline typename internal::AllOfResult9<M1, M2, M3, M4, M5, M6, M7, M8, M9>::type
12765 AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9) {
12766 return typename internal::AllOfResult9<M1, M2, M3, M4, M5, M6, M7, M8,
12767 M9>::type(
12768 ::testing::AllOf(m1, m2, m3, m4),
12769 ::testing::AllOf(m5, m6, m7, m8, m9));
12770 }
12771
12772 template <typename M1, typename M2, typename M3, typename M4, typename M5,
12773 typename M6, typename M7, typename M8, typename M9, typename M10>
12774 inline typename internal::AllOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
12775 M10>::type
12776 AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
12777 return typename internal::AllOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
12778 M10>::type(
12779 ::testing::AllOf(m1, m2, m3, m4, m5),
12780 ::testing::AllOf(m6, m7, m8, m9, m10));
12781 }
12782
12783
12784
12785
12786 template <typename M1, typename M2>
12787 inline typename internal::AnyOfResult2<M1, M2>::type
12788 AnyOf(M1 m1, M2 m2) {
12789 return typename internal::AnyOfResult2<M1, M2>::type(
12790 m1,
12791 m2);
12792 }
12793
12794 template <typename M1, typename M2, typename M3>
12795 inline typename internal::AnyOfResult3<M1, M2, M3>::type
12796 AnyOf(M1 m1, M2 m2, M3 m3) {
12797 return typename internal::AnyOfResult3<M1, M2, M3>::type(
12798 m1,
12799 ::testing::AnyOf(m2, m3));
12800 }
12801
12802 template <typename M1, typename M2, typename M3, typename M4>
12803 inline typename internal::AnyOfResult4<M1, M2, M3, M4>::type
12804 AnyOf(M1 m1, M2 m2, M3 m3, M4 m4) {
12805 return typename internal::AnyOfResult4<M1, M2, M3, M4>::type(
12806 ::testing::AnyOf(m1, m2),
12807 ::testing::AnyOf(m3, m4));
12808 }
12809
12810 template <typename M1, typename M2, typename M3, typename M4, typename M5>
12811 inline typename internal::AnyOfResult5<M1, M2, M3, M4, M5>::type
12812 AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5) {
12813 return typename internal::AnyOfResult5<M1, M2, M3, M4, M5>::type(
12814 ::testing::AnyOf(m1, m2),
12815 ::testing::AnyOf(m3, m4, m5));
12816 }
12817
12818 template <typename M1, typename M2, typename M3, typename M4, typename M5,
12819 typename M6>
12820 inline typename internal::AnyOfResult6<M1, M2, M3, M4, M5, M6>::type
12821 AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6) {
12822 return typename internal::AnyOfResult6<M1, M2, M3, M4, M5, M6>::type(
12823 ::testing::AnyOf(m1, m2, m3),
12824 ::testing::AnyOf(m4, m5, m6));
12825 }
12826
12827 template <typename M1, typename M2, typename M3, typename M4, typename M5,
12828 typename M6, typename M7>
12829 inline typename internal::AnyOfResult7<M1, M2, M3, M4, M5, M6, M7>::type
12830 AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7) {
12831 return typename internal::AnyOfResult7<M1, M2, M3, M4, M5, M6, M7>::type(
12832 ::testing::AnyOf(m1, m2, m3),
12833 ::testing::AnyOf(m4, m5, m6, m7));
12834 }
12835
12836 template <typename M1, typename M2, typename M3, typename M4, typename M5,
12837 typename M6, typename M7, typename M8>
12838 inline typename internal::AnyOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type
12839 AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8) {
12840 return typename internal::AnyOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type(
12841 ::testing::AnyOf(m1, m2, m3, m4),
12842 ::testing::AnyOf(m5, m6, m7, m8));
12843 }
12844
12845 template <typename M1, typename M2, typename M3, typename M4, typename M5,
12846 typename M6, typename M7, typename M8, typename M9>
12847 inline typename internal::AnyOfResult9<M1, M2, M3, M4, M5, M6, M7, M8, M9>::type
12848 AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9) {
12849 return typename internal::AnyOfResult9<M1, M2, M3, M4, M5, M6, M7, M8,
12850 M9>::type(
12851 ::testing::AnyOf(m1, m2, m3, m4),
12852 ::testing::AnyOf(m5, m6, m7, m8, m9));
12853 }
12854
12855 template <typename M1, typename M2, typename M3, typename M4, typename M5,
12856 typename M6, typename M7, typename M8, typename M9, typename M10>
12857 inline typename internal::AnyOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
12858 M10>::type
12859 AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
12860 return typename internal::AnyOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
12861 M10>::type(
12862 ::testing::AnyOf(m1, m2, m3, m4, m5),
12863 ::testing::AnyOf(m6, m7, m8, m9, m10));
12864 }
12865
12866 }
12867
12868
12869
12870
12871
12872
12873
12874
12875
12876
12877
12878
12879
12880
12881
12882
12883
12884
12885
12886
12887
12888
12889
12890
12891
12892
12893
12894
12895
12896
12897
12898
12899
12900
12901
12902
12903
12904
12905
12906
12907
12908
12909
12910
12911
12912
12913
12914
12915
12916
12917
12918
12919
12920
12921
12922
12923
12924
12925
12926
12927
12928
12929
12930
12931
12932
12933
12934
12935
12936
12937
12938
12939
12940
12941
12942
12943
12944
12945
12946
12947
12948
12949
12950
12951
12952
12953
12954
12955
12956
12957
12958
12959
12960
12961
12962
12963
12964
12965
12966
12967
12968
12969
12970
12971
12972
12973
12974
12975
12976
12977
12978
12979
12980
12981
12982
12983
12984
12985
12986
12987
12988
12989
12990
12991
12992
12993
12994
12995
12996
12997
12998
12999
13000
13001
13002
13003
13004
13005
13006
13007
13008
13009
13010
13011
13012
13013
13014
13015
13016
13017
13018
13019
13020
13021
13022
13023
13024
13025
13026
13027
13028
13029
13030
13031
13032
13033
13034
13035
13036
13037
13038
13039
13040
13041
13042
13043
13044
13045
13046
13047
13049
13050
13051
13052
13053
13054
13055
13056
13057
13058
13059
13060
13061
13062
13063
13064
13065
13066
13067
13068
13069
13070
13071
13072
13073
13074
13075
13076
13077
13078
13079
13080
13081
13082
13083
13084 #define MATCHER(name, description)\
13085 class name##Matcher {\
13086 public:\
13087 template <typename arg_type>\
13088 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
13089 public:\
13090 gmock_Impl()\
13091 {}\
13092 virtual bool MatchAndExplain(\
13093 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
13094 virtual void DescribeTo(::std::ostream* gmock_os) const {\
13095 *gmock_os << FormatDescription(false);\
13096 }\
13097 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
13098 *gmock_os << FormatDescription(true);\
13099 }\
13100 private:\
13101 ::testing::internal::string FormatDescription(bool negation) const {\
13102 const ::testing::internal::string gmock_description = (description);\
13103 if (!gmock_description.empty())\
13104 return gmock_description;\
13105 return ::testing::internal::FormatMatcherDescription(\
13106 negation, #name, \
13107 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
13108 ::std::tr1::tuple<>()));\
13109 }\
13110 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
13111 };\
13112 template <typename arg_type>\
13113 operator ::testing::Matcher<arg_type>() const {\
13114 return ::testing::Matcher<arg_type>(\
13115 new gmock_Impl<arg_type>());\
13116 }\
13117 name##Matcher() {\
13118 }\
13119 private:\
13120 GTEST_DISALLOW_ASSIGN_(name##Matcher);\
13121 };\
13122 inline name##Matcher name() {\
13123 return name##Matcher();\
13124 }\
13125 template <typename arg_type>\
13126 bool name##Matcher::gmock_Impl<arg_type>::MatchAndExplain(\
13127 arg_type arg, \
13128 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
13129 const
13130
13131 #define MATCHER_P(name, p0, description)\
13132 template <typename p0##_type>\
13133 class name##MatcherP {\
13134 public:\
13135 template <typename arg_type>\
13136 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
13137 public:\
13138 explicit gmock_Impl(p0##_type gmock_p0)\
13139 : p0(gmock_p0) {}\
13140 virtual bool MatchAndExplain(\
13141 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
13142 virtual void DescribeTo(::std::ostream* gmock_os) const {\
13143 *gmock_os << FormatDescription(false);\
13144 }\
13145 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
13146 *gmock_os << FormatDescription(true);\
13147 }\
13148 p0##_type p0;\
13149 private:\
13150 ::testing::internal::string FormatDescription(bool negation) const {\
13151 const ::testing::internal::string gmock_description = (description);\
13152 if (!gmock_description.empty())\
13153 return gmock_description;\
13154 return ::testing::internal::FormatMatcherDescription(\
13155 negation, #name, \
13156 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
13157 ::std::tr1::tuple<p0##_type>(p0)));\
13158 }\
13159 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
13160 };\
13161 template <typename arg_type>\
13162 operator ::testing::Matcher<arg_type>() const {\
13163 return ::testing::Matcher<arg_type>(\
13164 new gmock_Impl<arg_type>(p0));\
13165 }\
13166 name##MatcherP(p0##_type gmock_p0) : p0(gmock_p0) {\
13167 }\
13168 p0##_type p0;\
13169 private:\
13170 GTEST_DISALLOW_ASSIGN_(name##MatcherP);\
13171 };\
13172 template <typename p0##_type>\
13173 inline name##MatcherP<p0##_type> name(p0##_type p0) {\
13174 return name##MatcherP<p0##_type>(p0);\
13175 }\
13176 template <typename p0##_type>\
13177 template <typename arg_type>\
13178 bool name##MatcherP<p0##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
13179 arg_type arg, \
13180 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
13181 const
13182
13183 #define MATCHER_P2(name, p0, p1, description)\
13184 template <typename p0##_type, typename p1##_type>\
13185 class name##MatcherP2 {\
13186 public:\
13187 template <typename arg_type>\
13188 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
13189 public:\
13190 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1)\
13191 : p0(gmock_p0), p1(gmock_p1) {}\
13192 virtual bool MatchAndExplain(\
13193 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
13194 virtual void DescribeTo(::std::ostream* gmock_os) const {\
13195 *gmock_os << FormatDescription(false);\
13196 }\
13197 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
13198 *gmock_os << FormatDescription(true);\
13199 }\
13200 p0##_type p0;\
13201 p1##_type p1;\
13202 private:\
13203 ::testing::internal::string FormatDescription(bool negation) const {\
13204 const ::testing::internal::string gmock_description = (description);\
13205 if (!gmock_description.empty())\
13206 return gmock_description;\
13207 return ::testing::internal::FormatMatcherDescription(\
13208 negation, #name, \
13209 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
13210 ::std::tr1::tuple<p0##_type, p1##_type>(p0, p1)));\
13211 }\
13212 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
13213 };\
13214 template <typename arg_type>\
13215 operator ::testing::Matcher<arg_type>() const {\
13216 return ::testing::Matcher<arg_type>(\
13217 new gmock_Impl<arg_type>(p0, p1));\
13218 }\
13219 name##MatcherP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
13220 p1(gmock_p1) {\
13221 }\
13222 p0##_type p0;\
13223 p1##_type p1;\
13224 private:\
13225 GTEST_DISALLOW_ASSIGN_(name##MatcherP2);\
13226 };\
13227 template <typename p0##_type, typename p1##_type>\
13228 inline name##MatcherP2<p0##_type, p1##_type> name(p0##_type p0, \
13229 p1##_type p1) {\
13230 return name##MatcherP2<p0##_type, p1##_type>(p0, p1);\
13231 }\
13232 template <typename p0##_type, typename p1##_type>\
13233 template <typename arg_type>\
13234 bool name##MatcherP2<p0##_type, \
13235 p1##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
13236 arg_type arg, \
13237 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
13238 const
13239
13240 #define MATCHER_P3(name, p0, p1, p2, description)\
13241 template <typename p0##_type, typename p1##_type, typename p2##_type>\
13242 class name##MatcherP3 {\
13243 public:\
13244 template <typename arg_type>\
13245 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
13246 public:\
13247 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2)\
13248 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\
13249 virtual bool MatchAndExplain(\
13250 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
13251 virtual void DescribeTo(::std::ostream* gmock_os) const {\
13252 *gmock_os << FormatDescription(false);\
13253 }\
13254 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
13255 *gmock_os << FormatDescription(true);\
13256 }\
13257 p0##_type p0;\
13258 p1##_type p1;\
13259 p2##_type p2;\
13260 private:\
13261 ::testing::internal::string FormatDescription(bool negation) const {\
13262 const ::testing::internal::string gmock_description = (description);\
13263 if (!gmock_description.empty())\
13264 return gmock_description;\
13265 return ::testing::internal::FormatMatcherDescription(\
13266 negation, #name, \
13267 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
13268 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type>(p0, p1, \
13269 p2)));\
13270 }\
13271 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
13272 };\
13273 template <typename arg_type>\
13274 operator ::testing::Matcher<arg_type>() const {\
13275 return ::testing::Matcher<arg_type>(\
13276 new gmock_Impl<arg_type>(p0, p1, p2));\
13277 }\
13278 name##MatcherP3(p0##_type gmock_p0, p1##_type gmock_p1, \
13279 p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {\
13280 }\
13281 p0##_type p0;\
13282 p1##_type p1;\
13283 p2##_type p2;\
13284 private:\
13285 GTEST_DISALLOW_ASSIGN_(name##MatcherP3);\
13286 };\
13287 template <typename p0##_type, typename p1##_type, typename p2##_type>\
13288 inline name##MatcherP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0, \
13289 p1##_type p1, p2##_type p2) {\
13290 return name##MatcherP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\
13291 }\
13292 template <typename p0##_type, typename p1##_type, typename p2##_type>\
13293 template <typename arg_type>\
13294 bool name##MatcherP3<p0##_type, p1##_type, \
13295 p2##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
13296 arg_type arg, \
13297 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
13298 const
13299
13300 #define MATCHER_P4(name, p0, p1, p2, p3, description)\
13301 template <typename p0##_type, typename p1##_type, typename p2##_type, \
13302 typename p3##_type>\
13303 class name##MatcherP4 {\
13304 public:\
13305 template <typename arg_type>\
13306 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
13307 public:\
13308 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
13309 p3##_type gmock_p3)\
13310 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3) {}\
13311 virtual bool MatchAndExplain(\
13312 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
13313 virtual void DescribeTo(::std::ostream* gmock_os) const {\
13314 *gmock_os << FormatDescription(false);\
13315 }\
13316 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
13317 *gmock_os << FormatDescription(true);\
13318 }\
13319 p0##_type p0;\
13320 p1##_type p1;\
13321 p2##_type p2;\
13322 p3##_type p3;\
13323 private:\
13324 ::testing::internal::string FormatDescription(bool negation) const {\
13325 const ::testing::internal::string gmock_description = (description);\
13326 if (!gmock_description.empty())\
13327 return gmock_description;\
13328 return ::testing::internal::FormatMatcherDescription(\
13329 negation, #name, \
13330 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
13331 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, \
13332 p3##_type>(p0, p1, p2, p3)));\
13333 }\
13334 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
13335 };\
13336 template <typename arg_type>\
13337 operator ::testing::Matcher<arg_type>() const {\
13338 return ::testing::Matcher<arg_type>(\
13339 new gmock_Impl<arg_type>(p0, p1, p2, p3));\
13340 }\
13341 name##MatcherP4(p0##_type gmock_p0, p1##_type gmock_p1, \
13342 p2##_type gmock_p2, p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), \
13343 p2(gmock_p2), p3(gmock_p3) {\
13344 }\
13345 p0##_type p0;\
13346 p1##_type p1;\
13347 p2##_type p2;\
13348 p3##_type p3;\
13349 private:\
13350 GTEST_DISALLOW_ASSIGN_(name##MatcherP4);\
13351 };\
13352 template <typename p0##_type, typename p1##_type, typename p2##_type, \
13353 typename p3##_type>\
13354 inline name##MatcherP4<p0##_type, p1##_type, p2##_type, \
13355 p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
13356 p3##_type p3) {\
13357 return name##MatcherP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, \
13358 p1, p2, p3);\
13359 }\
13360 template <typename p0##_type, typename p1##_type, typename p2##_type, \
13361 typename p3##_type>\
13362 template <typename arg_type>\
13363 bool name##MatcherP4<p0##_type, p1##_type, p2##_type, \
13364 p3##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
13365 arg_type arg, \
13366 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
13367 const
13368
13369 #define MATCHER_P5(name, p0, p1, p2, p3, p4, description)\
13370 template <typename p0##_type, typename p1##_type, typename p2##_type, \
13371 typename p3##_type, typename p4##_type>\
13372 class name##MatcherP5 {\
13373 public:\
13374 template <typename arg_type>\
13375 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
13376 public:\
13377 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
13378 p3##_type gmock_p3, p4##_type gmock_p4)\
13379 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
13380 p4(gmock_p4) {}\
13381 virtual bool MatchAndExplain(\
13382 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
13383 virtual void DescribeTo(::std::ostream* gmock_os) const {\
13384 *gmock_os << FormatDescription(false);\
13385 }\
13386 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
13387 *gmock_os << FormatDescription(true);\
13388 }\
13389 p0##_type p0;\
13390 p1##_type p1;\
13391 p2##_type p2;\
13392 p3##_type p3;\
13393 p4##_type p4;\
13394 private:\
13395 ::testing::internal::string FormatDescription(bool negation) const {\
13396 const ::testing::internal::string gmock_description = (description);\
13397 if (!gmock_description.empty())\
13398 return gmock_description;\
13399 return ::testing::internal::FormatMatcherDescription(\
13400 negation, #name, \
13401 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
13402 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
13403 p4##_type>(p0, p1, p2, p3, p4)));\
13404 }\
13405 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
13406 };\
13407 template <typename arg_type>\
13408 operator ::testing::Matcher<arg_type>() const {\
13409 return ::testing::Matcher<arg_type>(\
13410 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4));\
13411 }\
13412 name##MatcherP5(p0##_type gmock_p0, p1##_type gmock_p1, \
13413 p2##_type gmock_p2, p3##_type gmock_p3, \
13414 p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
13415 p3(gmock_p3), p4(gmock_p4) {\
13416 }\
13417 p0##_type p0;\
13418 p1##_type p1;\
13419 p2##_type p2;\
13420 p3##_type p3;\
13421 p4##_type p4;\
13422 private:\
13423 GTEST_DISALLOW_ASSIGN_(name##MatcherP5);\
13424 };\
13425 template <typename p0##_type, typename p1##_type, typename p2##_type, \
13426 typename p3##_type, typename p4##_type>\
13427 inline name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
13428 p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
13429 p4##_type p4) {\
13430 return name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
13431 p4##_type>(p0, p1, p2, p3, p4);\
13432 }\
13433 template <typename p0##_type, typename p1##_type, typename p2##_type, \
13434 typename p3##_type, typename p4##_type>\
13435 template <typename arg_type>\
13436 bool name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
13437 p4##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
13438 arg_type arg, \
13439 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
13440 const
13441
13442 #define MATCHER_P6(name, p0, p1, p2, p3, p4, p5, description)\
13443 template <typename p0##_type, typename p1##_type, typename p2##_type, \
13444 typename p3##_type, typename p4##_type, typename p5##_type>\
13445 class name##MatcherP6 {\
13446 public:\
13447 template <typename arg_type>\
13448 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
13449 public:\
13450 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
13451 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5)\
13452 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
13453 p4(gmock_p4), p5(gmock_p5) {}\
13454 virtual bool MatchAndExplain(\
13455 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
13456 virtual void DescribeTo(::std::ostream* gmock_os) const {\
13457 *gmock_os << FormatDescription(false);\
13458 }\
13459 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
13460 *gmock_os << FormatDescription(true);\
13461 }\
13462 p0##_type p0;\
13463 p1##_type p1;\
13464 p2##_type p2;\
13465 p3##_type p3;\
13466 p4##_type p4;\
13467 p5##_type p5;\
13468 private:\
13469 ::testing::internal::string FormatDescription(bool negation) const {\
13470 const ::testing::internal::string gmock_description = (description);\
13471 if (!gmock_description.empty())\
13472 return gmock_description;\
13473 return ::testing::internal::FormatMatcherDescription(\
13474 negation, #name, \
13475 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
13476 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
13477 p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5)));\
13478 }\
13479 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
13480 };\
13481 template <typename arg_type>\
13482 operator ::testing::Matcher<arg_type>() const {\
13483 return ::testing::Matcher<arg_type>(\
13484 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5));\
13485 }\
13486 name##MatcherP6(p0##_type gmock_p0, p1##_type gmock_p1, \
13487 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
13488 p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
13489 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {\
13490 }\
13491 p0##_type p0;\
13492 p1##_type p1;\
13493 p2##_type p2;\
13494 p3##_type p3;\
13495 p4##_type p4;\
13496 p5##_type p5;\
13497 private:\
13498 GTEST_DISALLOW_ASSIGN_(name##MatcherP6);\
13499 };\
13500 template <typename p0##_type, typename p1##_type, typename p2##_type, \
13501 typename p3##_type, typename p4##_type, typename p5##_type>\
13502 inline name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
13503 p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
13504 p3##_type p3, p4##_type p4, p5##_type p5) {\
13505 return name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
13506 p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\
13507 }\
13508 template <typename p0##_type, typename p1##_type, typename p2##_type, \
13509 typename p3##_type, typename p4##_type, typename p5##_type>\
13510 template <typename arg_type>\
13511 bool name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
13512 p5##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
13513 arg_type arg, \
13514 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
13515 const
13516
13517 #define MATCHER_P7(name, p0, p1, p2, p3, p4, p5, p6, description)\
13518 template <typename p0##_type, typename p1##_type, typename p2##_type, \
13519 typename p3##_type, typename p4##_type, typename p5##_type, \
13520 typename p6##_type>\
13521 class name##MatcherP7 {\
13522 public:\
13523 template <typename arg_type>\
13524 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
13525 public:\
13526 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
13527 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
13528 p6##_type gmock_p6)\
13529 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
13530 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6) {}\
13531 virtual bool MatchAndExplain(\
13532 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
13533 virtual void DescribeTo(::std::ostream* gmock_os) const {\
13534 *gmock_os << FormatDescription(false);\
13535 }\
13536 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
13537 *gmock_os << FormatDescription(true);\
13538 }\
13539 p0##_type p0;\
13540 p1##_type p1;\
13541 p2##_type p2;\
13542 p3##_type p3;\
13543 p4##_type p4;\
13544 p5##_type p5;\
13545 p6##_type p6;\
13546 private:\
13547 ::testing::internal::string FormatDescription(bool negation) const {\
13548 const ::testing::internal::string gmock_description = (description);\
13549 if (!gmock_description.empty())\
13550 return gmock_description;\
13551 return ::testing::internal::FormatMatcherDescription(\
13552 negation, #name, \
13553 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
13554 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
13555 p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, \
13556 p6)));\
13557 }\
13558 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
13559 };\
13560 template <typename arg_type>\
13561 operator ::testing::Matcher<arg_type>() const {\
13562 return ::testing::Matcher<arg_type>(\
13563 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6));\
13564 }\
13565 name##MatcherP7(p0##_type gmock_p0, p1##_type gmock_p1, \
13566 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
13567 p5##_type gmock_p5, p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), \
13568 p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), \
13569 p6(gmock_p6) {\
13570 }\
13571 p0##_type p0;\
13572 p1##_type p1;\
13573 p2##_type p2;\
13574 p3##_type p3;\
13575 p4##_type p4;\
13576 p5##_type p5;\
13577 p6##_type p6;\
13578 private:\
13579 GTEST_DISALLOW_ASSIGN_(name##MatcherP7);\
13580 };\
13581 template <typename p0##_type, typename p1##_type, typename p2##_type, \
13582 typename p3##_type, typename p4##_type, typename p5##_type, \
13583 typename p6##_type>\
13584 inline name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
13585 p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \
13586 p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
13587 p6##_type p6) {\
13588 return name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
13589 p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\
13590 }\
13591 template <typename p0##_type, typename p1##_type, typename p2##_type, \
13592 typename p3##_type, typename p4##_type, typename p5##_type, \
13593 typename p6##_type>\
13594 template <typename arg_type>\
13595 bool name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
13596 p5##_type, p6##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
13597 arg_type arg, \
13598 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
13599 const
13600
13601 #define MATCHER_P8(name, p0, p1, p2, p3, p4, p5, p6, p7, description)\
13602 template <typename p0##_type, typename p1##_type, typename p2##_type, \
13603 typename p3##_type, typename p4##_type, typename p5##_type, \
13604 typename p6##_type, typename p7##_type>\
13605 class name##MatcherP8 {\
13606 public:\
13607 template <typename arg_type>\
13608 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
13609 public:\
13610 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
13611 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
13612 p6##_type gmock_p6, p7##_type gmock_p7)\
13613 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
13614 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7) {}\
13615 virtual bool MatchAndExplain(\
13616 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
13617 virtual void DescribeTo(::std::ostream* gmock_os) const {\
13618 *gmock_os << FormatDescription(false);\
13619 }\
13620 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
13621 *gmock_os << FormatDescription(true);\
13622 }\
13623 p0##_type p0;\
13624 p1##_type p1;\
13625 p2##_type p2;\
13626 p3##_type p3;\
13627 p4##_type p4;\
13628 p5##_type p5;\
13629 p6##_type p6;\
13630 p7##_type p7;\
13631 private:\
13632 ::testing::internal::string FormatDescription(bool negation) const {\
13633 const ::testing::internal::string gmock_description = (description);\
13634 if (!gmock_description.empty())\
13635 return gmock_description;\
13636 return ::testing::internal::FormatMatcherDescription(\
13637 negation, #name, \
13638 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
13639 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
13640 p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, \
13641 p3, p4, p5, p6, p7)));\
13642 }\
13643 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
13644 };\
13645 template <typename arg_type>\
13646 operator ::testing::Matcher<arg_type>() const {\
13647 return ::testing::Matcher<arg_type>(\
13648 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7));\
13649 }\
13650 name##MatcherP8(p0##_type gmock_p0, p1##_type gmock_p1, \
13651 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
13652 p5##_type gmock_p5, p6##_type gmock_p6, \
13653 p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
13654 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
13655 p7(gmock_p7) {\
13656 }\
13657 p0##_type p0;\
13658 p1##_type p1;\
13659 p2##_type p2;\
13660 p3##_type p3;\
13661 p4##_type p4;\
13662 p5##_type p5;\
13663 p6##_type p6;\
13664 p7##_type p7;\
13665 private:\
13666 GTEST_DISALLOW_ASSIGN_(name##MatcherP8);\
13667 };\
13668 template <typename p0##_type, typename p1##_type, typename p2##_type, \
13669 typename p3##_type, typename p4##_type, typename p5##_type, \
13670 typename p6##_type, typename p7##_type>\
13671 inline name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
13672 p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \
13673 p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
13674 p6##_type p6, p7##_type p7) {\
13675 return name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
13676 p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5, \
13677 p6, p7);\
13678 }\
13679 template <typename p0##_type, typename p1##_type, typename p2##_type, \
13680 typename p3##_type, typename p4##_type, typename p5##_type, \
13681 typename p6##_type, typename p7##_type>\
13682 template <typename arg_type>\
13683 bool name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
13684 p5##_type, p6##_type, \
13685 p7##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
13686 arg_type arg, \
13687 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
13688 const
13689
13690 #define MATCHER_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, description)\
13691 template <typename p0##_type, typename p1##_type, typename p2##_type, \
13692 typename p3##_type, typename p4##_type, typename p5##_type, \
13693 typename p6##_type, typename p7##_type, typename p8##_type>\
13694 class name##MatcherP9 {\
13695 public:\
13696 template <typename arg_type>\
13697 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
13698 public:\
13699 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
13700 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
13701 p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8)\
13702 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
13703 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
13704 p8(gmock_p8) {}\
13705 virtual bool MatchAndExplain(\
13706 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
13707 virtual void DescribeTo(::std::ostream* gmock_os) const {\
13708 *gmock_os << FormatDescription(false);\
13709 }\
13710 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
13711 *gmock_os << FormatDescription(true);\
13712 }\
13713 p0##_type p0;\
13714 p1##_type p1;\
13715 p2##_type p2;\
13716 p3##_type p3;\
13717 p4##_type p4;\
13718 p5##_type p5;\
13719 p6##_type p6;\
13720 p7##_type p7;\
13721 p8##_type p8;\
13722 private:\
13723 ::testing::internal::string FormatDescription(bool negation) const {\
13724 const ::testing::internal::string gmock_description = (description);\
13725 if (!gmock_description.empty())\
13726 return gmock_description;\
13727 return ::testing::internal::FormatMatcherDescription(\
13728 negation, #name, \
13729 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
13730 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
13731 p4##_type, p5##_type, p6##_type, p7##_type, \
13732 p8##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8)));\
13733 }\
13734 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
13735 };\
13736 template <typename arg_type>\
13737 operator ::testing::Matcher<arg_type>() const {\
13738 return ::testing::Matcher<arg_type>(\
13739 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8));\
13740 }\
13741 name##MatcherP9(p0##_type gmock_p0, p1##_type gmock_p1, \
13742 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
13743 p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
13744 p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
13745 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
13746 p8(gmock_p8) {\
13747 }\
13748 p0##_type p0;\
13749 p1##_type p1;\
13750 p2##_type p2;\
13751 p3##_type p3;\
13752 p4##_type p4;\
13753 p5##_type p5;\
13754 p6##_type p6;\
13755 p7##_type p7;\
13756 p8##_type p8;\
13757 private:\
13758 GTEST_DISALLOW_ASSIGN_(name##MatcherP9);\
13759 };\
13760 template <typename p0##_type, typename p1##_type, typename p2##_type, \
13761 typename p3##_type, typename p4##_type, typename p5##_type, \
13762 typename p6##_type, typename p7##_type, typename p8##_type>\
13763 inline name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \
13764 p4##_type, p5##_type, p6##_type, p7##_type, \
13765 p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
13766 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \
13767 p8##_type p8) {\
13768 return name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \
13769 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type>(p0, p1, p2, \
13770 p3, p4, p5, p6, p7, p8);\
13771 }\
13772 template <typename p0##_type, typename p1##_type, typename p2##_type, \
13773 typename p3##_type, typename p4##_type, typename p5##_type, \
13774 typename p6##_type, typename p7##_type, typename p8##_type>\
13775 template <typename arg_type>\
13776 bool name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
13777 p5##_type, p6##_type, p7##_type, \
13778 p8##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
13779 arg_type arg, \
13780 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
13781 const
13782
13783 #define MATCHER_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, description)\
13784 template <typename p0##_type, typename p1##_type, typename p2##_type, \
13785 typename p3##_type, typename p4##_type, typename p5##_type, \
13786 typename p6##_type, typename p7##_type, typename p8##_type, \
13787 typename p9##_type>\
13788 class name##MatcherP10 {\
13789 public:\
13790 template <typename arg_type>\
13791 class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
13792 public:\
13793 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
13794 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
13795 p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
13796 p9##_type gmock_p9)\
13797 : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
13798 p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
13799 p8(gmock_p8), p9(gmock_p9) {}\
13800 virtual bool MatchAndExplain(\
13801 arg_type arg, ::testing::MatchResultListener* result_listener) const;\
13802 virtual void DescribeTo(::std::ostream* gmock_os) const {\
13803 *gmock_os << FormatDescription(false);\
13804 }\
13805 virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
13806 *gmock_os << FormatDescription(true);\
13807 }\
13808 p0##_type p0;\
13809 p1##_type p1;\
13810 p2##_type p2;\
13811 p3##_type p3;\
13812 p4##_type p4;\
13813 p5##_type p5;\
13814 p6##_type p6;\
13815 p7##_type p7;\
13816 p8##_type p8;\
13817 p9##_type p9;\
13818 private:\
13819 ::testing::internal::string FormatDescription(bool negation) const {\
13820 const ::testing::internal::string gmock_description = (description);\
13821 if (!gmock_description.empty())\
13822 return gmock_description;\
13823 return ::testing::internal::FormatMatcherDescription(\
13824 negation, #name, \
13825 ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
13826 ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
13827 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
13828 p9##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)));\
13829 }\
13830 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
13831 };\
13832 template <typename arg_type>\
13833 operator ::testing::Matcher<arg_type>() const {\
13834 return ::testing::Matcher<arg_type>(\
13835 new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9));\
13836 }\
13837 name##MatcherP10(p0##_type gmock_p0, p1##_type gmock_p1, \
13838 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
13839 p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
13840 p8##_type gmock_p8, p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), \
13841 p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
13842 p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {\
13843 }\
13844 p0##_type p0;\
13845 p1##_type p1;\
13846 p2##_type p2;\
13847 p3##_type p3;\
13848 p4##_type p4;\
13849 p5##_type p5;\
13850 p6##_type p6;\
13851 p7##_type p7;\
13852 p8##_type p8;\
13853 p9##_type p9;\
13854 private:\
13855 GTEST_DISALLOW_ASSIGN_(name##MatcherP10);\
13856 };\
13857 template <typename p0##_type, typename p1##_type, typename p2##_type, \
13858 typename p3##_type, typename p4##_type, typename p5##_type, \
13859 typename p6##_type, typename p7##_type, typename p8##_type, \
13860 typename p9##_type>\
13861 inline name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
13862 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
13863 p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
13864 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
13865 p9##_type p9) {\
13866 return name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
13867 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>(p0, \
13868 p1, p2, p3, p4, p5, p6, p7, p8, p9);\
13869 }\
13870 template <typename p0##_type, typename p1##_type, typename p2##_type, \
13871 typename p3##_type, typename p4##_type, typename p5##_type, \
13872 typename p6##_type, typename p7##_type, typename p8##_type, \
13873 typename p9##_type>\
13874 template <typename arg_type>\
13875 bool name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
13876 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
13877 p9##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
13878 arg_type arg, \
13879 ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
13880 const
13881
13882 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
13883
13884
13885
13886
13887
13888
13889
13890
13891
13892
13893
13894
13895
13896
13897
13898
13899
13900
13901
13902
13903
13904
13905
13906
13907
13908
13909
13910
13911
13912
13913
13914
13915
13916
13917
13918 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
13919 #define GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
13920
13921 #include <algorithm>
13922
13923
13924 namespace testing {
13925 namespace internal {
13926
13927
13928
13929
13930
13931
13932 template <typename FunctionImpl>
13933 class InvokeAction {
13934 public:
13935
13936
13937 explicit InvokeAction(FunctionImpl function_impl)
13938 : function_impl_(function_impl) {}
13939
13940 template <typename Result, typename ArgumentTuple>
13941 Result Perform(const ArgumentTuple& args) {
13942 return InvokeHelper<Result, ArgumentTuple>::Invoke(function_impl_, args);
13943 }
13944
13945 private:
13946 FunctionImpl function_impl_;
13947
13948 GTEST_DISALLOW_ASSIGN_(InvokeAction);
13949 };
13950
13951
13952 template <class Class, typename MethodPtr>
13953 class InvokeMethodAction {
13954 public:
13955 InvokeMethodAction(Class* obj_ptr, MethodPtr method_ptr)
13956 : obj_ptr_(obj_ptr), method_ptr_(method_ptr) {}
13957
13958 template <typename Result, typename ArgumentTuple>
13959 Result Perform(const ArgumentTuple& args) const {
13960 return InvokeHelper<Result, ArgumentTuple>::InvokeMethod(
13961 obj_ptr_, method_ptr_, args);
13962 }
13963
13964 private:
13965 Class* const obj_ptr_;
13966 const MethodPtr method_ptr_;
13967
13968 GTEST_DISALLOW_ASSIGN_(InvokeMethodAction);
13969 };
13970
13971 }
13972
13973
13974
13975
13976
13977 template <typename FunctionImpl>
13978 PolymorphicAction<internal::InvokeAction<FunctionImpl> > Invoke(
13979 FunctionImpl function_impl) {
13980 return MakePolymorphicAction(
13981 internal::InvokeAction<FunctionImpl>(function_impl));
13982 }
13983
13984
13985
13986 template <class Class, typename MethodPtr>
13987 PolymorphicAction<internal::InvokeMethodAction<Class, MethodPtr> > Invoke(
13988 Class* obj_ptr, MethodPtr method_ptr) {
13989 return MakePolymorphicAction(
13990 internal::InvokeMethodAction<Class, MethodPtr>(obj_ptr, method_ptr));
13991 }
13992
13993
13994
13995
13996
13997 template <typename InnerAction>
13998 inline internal::WithArgsAction<InnerAction>
13999 WithoutArgs(const InnerAction& action) {
14000 return internal::WithArgsAction<InnerAction>(action);
14001 }
14002
14003
14004
14005
14006
14007
14008 template <int k, typename InnerAction>
14009 inline internal::WithArgsAction<InnerAction, k>
14010 WithArg(const InnerAction& action) {
14011 return internal::WithArgsAction<InnerAction, k>(action);
14012 }
14013
14014
14015
14016
14017
14018
14019 #ifdef _MSC_VER
14020 # pragma warning(push)
14021 # pragma warning(disable:4100)
14022 #endif
14023
14024
14025 ACTION_TEMPLATE(ReturnArg,
14026 HAS_1_TEMPLATE_PARAMS(int, k),
14027 AND_0_VALUE_PARAMS()) {
14028 return std::tr1::get<k>(args);
14029 }
14030
14031
14032
14033 ACTION_TEMPLATE(SaveArg,
14034 HAS_1_TEMPLATE_PARAMS(int, k),
14035 AND_1_VALUE_PARAMS(pointer)) {
14036 *pointer = ::std::tr1::get<k>(args);
14037 }
14038
14039
14040
14041 ACTION_TEMPLATE(SaveArgPointee,
14042 HAS_1_TEMPLATE_PARAMS(int, k),
14043 AND_1_VALUE_PARAMS(pointer)) {
14044 *pointer = *::std::tr1::get<k>(args);
14045 }
14046
14047
14048
14049 ACTION_TEMPLATE(SetArgReferee,
14050 HAS_1_TEMPLATE_PARAMS(int, k),
14051 AND_1_VALUE_PARAMS(value)) {
14052 typedef typename ::std::tr1::tuple_element<k, args_type>::type argk_type;
14053
14054
14055
14056 GTEST_COMPILE_ASSERT_(internal::is_reference<argk_type>::value,
14057 SetArgReferee_must_be_used_with_a_reference_argument);
14058 ::std::tr1::get<k>(args) = value;
14059 }
14060
14061
14062
14063
14064
14065
14066 ACTION_TEMPLATE(SetArrayArgument,
14067 HAS_1_TEMPLATE_PARAMS(int, k),
14068 AND_2_VALUE_PARAMS(first, last)) {
14069
14070
14071 #ifdef _MSC_VER
14072 # pragma warning(push) // Saves the current warning state.
14073 # pragma warning(disable:4996) // Temporarily disables warning 4996.
14074 #endif
14075 ::std::copy(first, last, ::std::tr1::get<k>(args));
14076 #ifdef _MSC_VER
14077 # pragma warning(pop) // Restores the warning state.
14078 #endif
14079 }
14080
14081
14082
14083 ACTION_TEMPLATE(DeleteArg,
14084 HAS_1_TEMPLATE_PARAMS(int, k),
14085 AND_0_VALUE_PARAMS()) {
14086 delete ::std::tr1::get<k>(args);
14087 }
14088
14089
14090 ACTION_P(ReturnPointee, pointer) { return *pointer; }
14091
14092
14093
14094 #if GTEST_HAS_EXCEPTIONS
14095
14096
14097 # ifdef _MSC_VER
14098 # pragma warning(push) // Saves the current warning state.
14099 # pragma warning(disable:4702) // Temporarily disables warning 4702.
14100 # endif
14101 ACTION_P(Throw, exception) { throw exception; }
14102 # ifdef _MSC_VER
14103 # pragma warning(pop) // Restores the warning state.
14104 # endif
14105
14106 #endif // GTEST_HAS_EXCEPTIONS
14107
14108 #ifdef _MSC_VER
14109 # pragma warning(pop)
14110 #endif
14111
14112 }
14113
14114 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
14115
14116
14117
14118
14119
14120
14121
14122
14123
14124
14125
14126
14127
14128
14129
14130
14131
14132
14133
14134
14135
14136
14137
14138
14139
14140
14141
14142
14143
14144
14145
14146
14147
14148
14149
14150
14151
14152
14153 #ifndef GMOCK_GMOCK_MORE_MATCHERS_H_
14154 #define GMOCK_GMOCK_MORE_MATCHERS_H_
14155
14156
14157 namespace testing {
14158
14159
14160
14161 MATCHER(IsEmpty, negation ? "isn't empty" : "is empty") {
14162 if (arg.empty()) {
14163 return true;
14164 }
14165 *result_listener << "whose size is " << arg.size();
14166 return false;
14167 }
14168
14169 }
14170
14171 #endif // GMOCK_GMOCK_MORE_MATCHERS_H_
14172
14173 namespace testing {
14174
14175
14176 GMOCK_DECLARE_bool_(catch_leaked_mocks);
14177 GMOCK_DECLARE_string_(verbose);
14178
14179
14180
14181
14182
14183
14184
14185
14186
14187
14188
14189
14190 GTEST_API_ void InitGoogleMock(int* argc, char** argv);
14191
14192
14193
14194 GTEST_API_ void InitGoogleMock(int* argc, wchar_t** argv);
14195
14196 }
14197
14198 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_H_