gmock-generated-function-mockers.h 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095
  1. // This file was GENERATED by command:
  2. // pump.py gmock-generated-function-mockers.h.pump
  3. // DO NOT EDIT BY HAND!!!
  4. // Copyright 2007, Google Inc.
  5. // All rights reserved.
  6. //
  7. // Redistribution and use in source and binary forms, with or without
  8. // modification, are permitted provided that the following conditions are
  9. // met:
  10. //
  11. // * Redistributions of source code must retain the above copyright
  12. // notice, this list of conditions and the following disclaimer.
  13. // * Redistributions in binary form must reproduce the above
  14. // copyright notice, this list of conditions and the following disclaimer
  15. // in the documentation and/or other materials provided with the
  16. // distribution.
  17. // * Neither the name of Google Inc. nor the names of its
  18. // contributors may be used to endorse or promote products derived from
  19. // this software without specific prior written permission.
  20. //
  21. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. //
  33. // Author: wan@google.com (Zhanyong Wan)
  34. // Google Mock - a framework for writing C++ mock classes.
  35. //
  36. // This file implements function mockers of various arities.
  37. #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
  38. #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
  39. #include "gmock/gmock-spec-builders.h"
  40. #include "gmock/internal/gmock-internal-utils.h"
  41. #if GTEST_HAS_STD_FUNCTION_
  42. # include <functional>
  43. #endif
  44. namespace testing {
  45. namespace internal {
  46. template <typename F>
  47. class FunctionMockerBase;
  48. // Note: class FunctionMocker really belongs to the ::testing
  49. // namespace. However if we define it in ::testing, MSVC will
  50. // complain when classes in ::testing::internal declare it as a
  51. // friend class template. To workaround this compiler bug, we define
  52. // FunctionMocker in ::testing::internal and import it into ::testing.
  53. template <typename F>
  54. class FunctionMocker;
  55. template <typename R>
  56. class FunctionMocker<R()> : public
  57. internal::FunctionMockerBase<R()> {
  58. public:
  59. typedef R F();
  60. typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
  61. MockSpec<F>& With() {
  62. return this->current_spec();
  63. }
  64. R Invoke() {
  65. // Even though gcc and MSVC don't enforce it, 'this->' is required
  66. // by the C++ standard [14.6.4] here, as the base class type is
  67. // dependent on the template argument (and thus shouldn't be
  68. // looked into when resolving InvokeWith).
  69. return this->InvokeWith(ArgumentTuple());
  70. }
  71. };
  72. template <typename R, typename A1>
  73. class FunctionMocker<R(A1)> : public
  74. internal::FunctionMockerBase<R(A1)> {
  75. public:
  76. typedef R F(A1);
  77. typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
  78. MockSpec<F>& With(const Matcher<A1>& m1) {
  79. this->current_spec().SetMatchers(::testing::make_tuple(m1));
  80. return this->current_spec();
  81. }
  82. R Invoke(A1 a1) {
  83. // Even though gcc and MSVC don't enforce it, 'this->' is required
  84. // by the C++ standard [14.6.4] here, as the base class type is
  85. // dependent on the template argument (and thus shouldn't be
  86. // looked into when resolving InvokeWith).
  87. return this->InvokeWith(ArgumentTuple(a1));
  88. }
  89. };
  90. template <typename R, typename A1, typename A2>
  91. class FunctionMocker<R(A1, A2)> : public
  92. internal::FunctionMockerBase<R(A1, A2)> {
  93. public:
  94. typedef R F(A1, A2);
  95. typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
  96. MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2) {
  97. this->current_spec().SetMatchers(::testing::make_tuple(m1, m2));
  98. return this->current_spec();
  99. }
  100. R Invoke(A1 a1, A2 a2) {
  101. // Even though gcc and MSVC don't enforce it, 'this->' is required
  102. // by the C++ standard [14.6.4] here, as the base class type is
  103. // dependent on the template argument (and thus shouldn't be
  104. // looked into when resolving InvokeWith).
  105. return this->InvokeWith(ArgumentTuple(a1, a2));
  106. }
  107. };
  108. template <typename R, typename A1, typename A2, typename A3>
  109. class FunctionMocker<R(A1, A2, A3)> : public
  110. internal::FunctionMockerBase<R(A1, A2, A3)> {
  111. public:
  112. typedef R F(A1, A2, A3);
  113. typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
  114. MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
  115. const Matcher<A3>& m3) {
  116. this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3));
  117. return this->current_spec();
  118. }
  119. R Invoke(A1 a1, A2 a2, A3 a3) {
  120. // Even though gcc and MSVC don't enforce it, 'this->' is required
  121. // by the C++ standard [14.6.4] here, as the base class type is
  122. // dependent on the template argument (and thus shouldn't be
  123. // looked into when resolving InvokeWith).
  124. return this->InvokeWith(ArgumentTuple(a1, a2, a3));
  125. }
  126. };
  127. template <typename R, typename A1, typename A2, typename A3, typename A4>
  128. class FunctionMocker<R(A1, A2, A3, A4)> : public
  129. internal::FunctionMockerBase<R(A1, A2, A3, A4)> {
  130. public:
  131. typedef R F(A1, A2, A3, A4);
  132. typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
  133. MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
  134. const Matcher<A3>& m3, const Matcher<A4>& m4) {
  135. this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4));
  136. return this->current_spec();
  137. }
  138. R Invoke(A1 a1, A2 a2, A3 a3, A4 a4) {
  139. // Even though gcc and MSVC don't enforce it, 'this->' is required
  140. // by the C++ standard [14.6.4] here, as the base class type is
  141. // dependent on the template argument (and thus shouldn't be
  142. // looked into when resolving InvokeWith).
  143. return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4));
  144. }
  145. };
  146. template <typename R, typename A1, typename A2, typename A3, typename A4,
  147. typename A5>
  148. class FunctionMocker<R(A1, A2, A3, A4, A5)> : public
  149. internal::FunctionMockerBase<R(A1, A2, A3, A4, A5)> {
  150. public:
  151. typedef R F(A1, A2, A3, A4, A5);
  152. typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
  153. MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
  154. const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5) {
  155. this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4, m5));
  156. return this->current_spec();
  157. }
  158. R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {
  159. // Even though gcc and MSVC don't enforce it, 'this->' is required
  160. // by the C++ standard [14.6.4] here, as the base class type is
  161. // dependent on the template argument (and thus shouldn't be
  162. // looked into when resolving InvokeWith).
  163. return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5));
  164. }
  165. };
  166. template <typename R, typename A1, typename A2, typename A3, typename A4,
  167. typename A5, typename A6>
  168. class FunctionMocker<R(A1, A2, A3, A4, A5, A6)> : public
  169. internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6)> {
  170. public:
  171. typedef R F(A1, A2, A3, A4, A5, A6);
  172. typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
  173. MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
  174. const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
  175. const Matcher<A6>& m6) {
  176. this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4, m5,
  177. m6));
  178. return this->current_spec();
  179. }
  180. R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) {
  181. // Even though gcc and MSVC don't enforce it, 'this->' is required
  182. // by the C++ standard [14.6.4] here, as the base class type is
  183. // dependent on the template argument (and thus shouldn't be
  184. // looked into when resolving InvokeWith).
  185. return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6));
  186. }
  187. };
  188. template <typename R, typename A1, typename A2, typename A3, typename A4,
  189. typename A5, typename A6, typename A7>
  190. class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7)> : public
  191. internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7)> {
  192. public:
  193. typedef R F(A1, A2, A3, A4, A5, A6, A7);
  194. typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
  195. MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
  196. const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
  197. const Matcher<A6>& m6, const Matcher<A7>& m7) {
  198. this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4, m5,
  199. m6, m7));
  200. return this->current_spec();
  201. }
  202. R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) {
  203. // Even though gcc and MSVC don't enforce it, 'this->' is required
  204. // by the C++ standard [14.6.4] here, as the base class type is
  205. // dependent on the template argument (and thus shouldn't be
  206. // looked into when resolving InvokeWith).
  207. return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7));
  208. }
  209. };
  210. template <typename R, typename A1, typename A2, typename A3, typename A4,
  211. typename A5, typename A6, typename A7, typename A8>
  212. class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8)> : public
  213. internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8)> {
  214. public:
  215. typedef R F(A1, A2, A3, A4, A5, A6, A7, A8);
  216. typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
  217. MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
  218. const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
  219. const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8) {
  220. this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4, m5,
  221. m6, m7, m8));
  222. return this->current_spec();
  223. }
  224. R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) {
  225. // Even though gcc and MSVC don't enforce it, 'this->' is required
  226. // by the C++ standard [14.6.4] here, as the base class type is
  227. // dependent on the template argument (and thus shouldn't be
  228. // looked into when resolving InvokeWith).
  229. return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8));
  230. }
  231. };
  232. template <typename R, typename A1, typename A2, typename A3, typename A4,
  233. typename A5, typename A6, typename A7, typename A8, typename A9>
  234. class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> : public
  235. internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
  236. public:
  237. typedef R F(A1, A2, A3, A4, A5, A6, A7, A8, A9);
  238. typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
  239. MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
  240. const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
  241. const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8,
  242. const Matcher<A9>& m9) {
  243. this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4, m5,
  244. m6, m7, m8, m9));
  245. return this->current_spec();
  246. }
  247. R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) {
  248. // Even though gcc and MSVC don't enforce it, 'this->' is required
  249. // by the C++ standard [14.6.4] here, as the base class type is
  250. // dependent on the template argument (and thus shouldn't be
  251. // looked into when resolving InvokeWith).
  252. return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8, a9));
  253. }
  254. };
  255. template <typename R, typename A1, typename A2, typename A3, typename A4,
  256. typename A5, typename A6, typename A7, typename A8, typename A9,
  257. typename A10>
  258. class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> : public
  259. internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> {
  260. public:
  261. typedef R F(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
  262. typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
  263. MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
  264. const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
  265. const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8,
  266. const Matcher<A9>& m9, const Matcher<A10>& m10) {
  267. this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4, m5,
  268. m6, m7, m8, m9, m10));
  269. return this->current_spec();
  270. }
  271. R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9,
  272. A10 a10) {
  273. // Even though gcc and MSVC don't enforce it, 'this->' is required
  274. // by the C++ standard [14.6.4] here, as the base class type is
  275. // dependent on the template argument (and thus shouldn't be
  276. // looked into when resolving InvokeWith).
  277. return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8, a9,
  278. a10));
  279. }
  280. };
  281. } // namespace internal
  282. // The style guide prohibits "using" statements in a namespace scope
  283. // inside a header file. However, the FunctionMocker class template
  284. // is meant to be defined in the ::testing namespace. The following
  285. // line is just a trick for working around a bug in MSVC 8.0, which
  286. // cannot handle it if we define FunctionMocker in ::testing.
  287. using internal::FunctionMocker;
  288. // GMOCK_RESULT_(tn, F) expands to the result type of function type F.
  289. // We define this as a variadic macro in case F contains unprotected
  290. // commas (the same reason that we use variadic macros in other places
  291. // in this file).
  292. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  293. #define GMOCK_RESULT_(tn, ...) \
  294. tn ::testing::internal::Function<__VA_ARGS__>::Result
  295. // The type of argument N of the given function type.
  296. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  297. #define GMOCK_ARG_(tn, N, ...) \
  298. tn ::testing::internal::Function<__VA_ARGS__>::Argument##N
  299. // The matcher type for argument N of the given function type.
  300. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  301. #define GMOCK_MATCHER_(tn, N, ...) \
  302. const ::testing::Matcher<GMOCK_ARG_(tn, N, __VA_ARGS__)>&
  303. // The variable for mocking the given method.
  304. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  305. #define GMOCK_MOCKER_(arity, constness, Method) \
  306. GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__)
  307. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  308. #define GMOCK_METHOD0_(tn, constness, ct, Method, ...) \
  309. GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
  310. ) constness { \
  311. GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
  312. tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
  313. == 0), \
  314. this_method_does_not_take_0_arguments); \
  315. GMOCK_MOCKER_(0, constness, Method).SetOwnerAndName(this, #Method); \
  316. return GMOCK_MOCKER_(0, constness, Method).Invoke(); \
  317. } \
  318. ::testing::MockSpec<__VA_ARGS__>& \
  319. gmock_##Method() constness { \
  320. GMOCK_MOCKER_(0, constness, Method).RegisterOwner(this); \
  321. return GMOCK_MOCKER_(0, constness, Method).With(); \
  322. } \
  323. mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(0, constness, \
  324. Method)
  325. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  326. #define GMOCK_METHOD1_(tn, constness, ct, Method, ...) \
  327. GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
  328. GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1) constness { \
  329. GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
  330. tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
  331. == 1), \
  332. this_method_does_not_take_1_argument); \
  333. GMOCK_MOCKER_(1, constness, Method).SetOwnerAndName(this, #Method); \
  334. return GMOCK_MOCKER_(1, constness, Method).Invoke(gmock_a1); \
  335. } \
  336. ::testing::MockSpec<__VA_ARGS__>& \
  337. gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1) constness { \
  338. GMOCK_MOCKER_(1, constness, Method).RegisterOwner(this); \
  339. return GMOCK_MOCKER_(1, constness, Method).With(gmock_a1); \
  340. } \
  341. mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(1, constness, \
  342. Method)
  343. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  344. #define GMOCK_METHOD2_(tn, constness, ct, Method, ...) \
  345. GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
  346. GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
  347. GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2) constness { \
  348. GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
  349. tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
  350. == 2), \
  351. this_method_does_not_take_2_arguments); \
  352. GMOCK_MOCKER_(2, constness, Method).SetOwnerAndName(this, #Method); \
  353. return GMOCK_MOCKER_(2, constness, Method).Invoke(gmock_a1, gmock_a2); \
  354. } \
  355. ::testing::MockSpec<__VA_ARGS__>& \
  356. gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
  357. GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2) constness { \
  358. GMOCK_MOCKER_(2, constness, Method).RegisterOwner(this); \
  359. return GMOCK_MOCKER_(2, constness, Method).With(gmock_a1, gmock_a2); \
  360. } \
  361. mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(2, constness, \
  362. Method)
  363. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  364. #define GMOCK_METHOD3_(tn, constness, ct, Method, ...) \
  365. GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
  366. GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
  367. GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
  368. GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3) constness { \
  369. GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
  370. tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
  371. == 3), \
  372. this_method_does_not_take_3_arguments); \
  373. GMOCK_MOCKER_(3, constness, Method).SetOwnerAndName(this, #Method); \
  374. return GMOCK_MOCKER_(3, constness, Method).Invoke(gmock_a1, gmock_a2, \
  375. gmock_a3); \
  376. } \
  377. ::testing::MockSpec<__VA_ARGS__>& \
  378. gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
  379. GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
  380. GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3) constness { \
  381. GMOCK_MOCKER_(3, constness, Method).RegisterOwner(this); \
  382. return GMOCK_MOCKER_(3, constness, Method).With(gmock_a1, gmock_a2, \
  383. gmock_a3); \
  384. } \
  385. mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(3, constness, \
  386. Method)
  387. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  388. #define GMOCK_METHOD4_(tn, constness, ct, Method, ...) \
  389. GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
  390. GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
  391. GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
  392. GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
  393. GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4) constness { \
  394. GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
  395. tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
  396. == 4), \
  397. this_method_does_not_take_4_arguments); \
  398. GMOCK_MOCKER_(4, constness, Method).SetOwnerAndName(this, #Method); \
  399. return GMOCK_MOCKER_(4, constness, Method).Invoke(gmock_a1, gmock_a2, \
  400. gmock_a3, gmock_a4); \
  401. } \
  402. ::testing::MockSpec<__VA_ARGS__>& \
  403. gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
  404. GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
  405. GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
  406. GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4) constness { \
  407. GMOCK_MOCKER_(4, constness, Method).RegisterOwner(this); \
  408. return GMOCK_MOCKER_(4, constness, Method).With(gmock_a1, gmock_a2, \
  409. gmock_a3, gmock_a4); \
  410. } \
  411. mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(4, constness, \
  412. Method)
  413. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  414. #define GMOCK_METHOD5_(tn, constness, ct, Method, ...) \
  415. GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
  416. GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
  417. GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
  418. GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
  419. GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
  420. GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5) constness { \
  421. GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
  422. tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
  423. == 5), \
  424. this_method_does_not_take_5_arguments); \
  425. GMOCK_MOCKER_(5, constness, Method).SetOwnerAndName(this, #Method); \
  426. return GMOCK_MOCKER_(5, constness, Method).Invoke(gmock_a1, gmock_a2, \
  427. gmock_a3, gmock_a4, gmock_a5); \
  428. } \
  429. ::testing::MockSpec<__VA_ARGS__>& \
  430. gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
  431. GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
  432. GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
  433. GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
  434. GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5) constness { \
  435. GMOCK_MOCKER_(5, constness, Method).RegisterOwner(this); \
  436. return GMOCK_MOCKER_(5, constness, Method).With(gmock_a1, gmock_a2, \
  437. gmock_a3, gmock_a4, gmock_a5); \
  438. } \
  439. mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(5, constness, \
  440. Method)
  441. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  442. #define GMOCK_METHOD6_(tn, constness, ct, Method, ...) \
  443. GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
  444. GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
  445. GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
  446. GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
  447. GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
  448. GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
  449. GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6) constness { \
  450. GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
  451. tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
  452. == 6), \
  453. this_method_does_not_take_6_arguments); \
  454. GMOCK_MOCKER_(6, constness, Method).SetOwnerAndName(this, #Method); \
  455. return GMOCK_MOCKER_(6, constness, Method).Invoke(gmock_a1, gmock_a2, \
  456. gmock_a3, gmock_a4, gmock_a5, gmock_a6); \
  457. } \
  458. ::testing::MockSpec<__VA_ARGS__>& \
  459. gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
  460. GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
  461. GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
  462. GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
  463. GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
  464. GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6) constness { \
  465. GMOCK_MOCKER_(6, constness, Method).RegisterOwner(this); \
  466. return GMOCK_MOCKER_(6, constness, Method).With(gmock_a1, gmock_a2, \
  467. gmock_a3, gmock_a4, gmock_a5, gmock_a6); \
  468. } \
  469. mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(6, constness, \
  470. Method)
  471. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  472. #define GMOCK_METHOD7_(tn, constness, ct, Method, ...) \
  473. GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
  474. GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
  475. GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
  476. GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
  477. GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
  478. GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
  479. GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
  480. GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7) constness { \
  481. GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
  482. tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
  483. == 7), \
  484. this_method_does_not_take_7_arguments); \
  485. GMOCK_MOCKER_(7, constness, Method).SetOwnerAndName(this, #Method); \
  486. return GMOCK_MOCKER_(7, constness, Method).Invoke(gmock_a1, gmock_a2, \
  487. gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7); \
  488. } \
  489. ::testing::MockSpec<__VA_ARGS__>& \
  490. gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
  491. GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
  492. GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
  493. GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
  494. GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
  495. GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
  496. GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7) constness { \
  497. GMOCK_MOCKER_(7, constness, Method).RegisterOwner(this); \
  498. return GMOCK_MOCKER_(7, constness, Method).With(gmock_a1, gmock_a2, \
  499. gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7); \
  500. } \
  501. mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(7, constness, \
  502. Method)
  503. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  504. #define GMOCK_METHOD8_(tn, constness, ct, Method, ...) \
  505. GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
  506. GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
  507. GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
  508. GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
  509. GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
  510. GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
  511. GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
  512. GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \
  513. GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8) constness { \
  514. GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
  515. tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
  516. == 8), \
  517. this_method_does_not_take_8_arguments); \
  518. GMOCK_MOCKER_(8, constness, Method).SetOwnerAndName(this, #Method); \
  519. return GMOCK_MOCKER_(8, constness, Method).Invoke(gmock_a1, gmock_a2, \
  520. gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \
  521. } \
  522. ::testing::MockSpec<__VA_ARGS__>& \
  523. gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
  524. GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
  525. GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
  526. GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
  527. GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
  528. GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
  529. GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \
  530. GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8) constness { \
  531. GMOCK_MOCKER_(8, constness, Method).RegisterOwner(this); \
  532. return GMOCK_MOCKER_(8, constness, Method).With(gmock_a1, gmock_a2, \
  533. gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \
  534. } \
  535. mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(8, constness, \
  536. Method)
  537. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  538. #define GMOCK_METHOD9_(tn, constness, ct, Method, ...) \
  539. GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
  540. GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
  541. GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
  542. GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
  543. GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
  544. GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
  545. GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
  546. GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \
  547. GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8, \
  548. GMOCK_ARG_(tn, 9, __VA_ARGS__) gmock_a9) constness { \
  549. GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
  550. tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
  551. == 9), \
  552. this_method_does_not_take_9_arguments); \
  553. GMOCK_MOCKER_(9, constness, Method).SetOwnerAndName(this, #Method); \
  554. return GMOCK_MOCKER_(9, constness, Method).Invoke(gmock_a1, gmock_a2, \
  555. gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, \
  556. gmock_a9); \
  557. } \
  558. ::testing::MockSpec<__VA_ARGS__>& \
  559. gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
  560. GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
  561. GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
  562. GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
  563. GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
  564. GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
  565. GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \
  566. GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8, \
  567. GMOCK_MATCHER_(tn, 9, __VA_ARGS__) gmock_a9) constness { \
  568. GMOCK_MOCKER_(9, constness, Method).RegisterOwner(this); \
  569. return GMOCK_MOCKER_(9, constness, Method).With(gmock_a1, gmock_a2, \
  570. gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, \
  571. gmock_a9); \
  572. } \
  573. mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(9, constness, \
  574. Method)
  575. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  576. #define GMOCK_METHOD10_(tn, constness, ct, Method, ...) \
  577. GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
  578. GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
  579. GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
  580. GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
  581. GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
  582. GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
  583. GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
  584. GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \
  585. GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8, \
  586. GMOCK_ARG_(tn, 9, __VA_ARGS__) gmock_a9, \
  587. GMOCK_ARG_(tn, 10, __VA_ARGS__) gmock_a10) constness { \
  588. GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
  589. tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
  590. == 10), \
  591. this_method_does_not_take_10_arguments); \
  592. GMOCK_MOCKER_(10, constness, Method).SetOwnerAndName(this, #Method); \
  593. return GMOCK_MOCKER_(10, constness, Method).Invoke(gmock_a1, gmock_a2, \
  594. gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9, \
  595. gmock_a10); \
  596. } \
  597. ::testing::MockSpec<__VA_ARGS__>& \
  598. gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
  599. GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
  600. GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
  601. GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
  602. GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
  603. GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
  604. GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \
  605. GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8, \
  606. GMOCK_MATCHER_(tn, 9, __VA_ARGS__) gmock_a9, \
  607. GMOCK_MATCHER_(tn, 10, \
  608. __VA_ARGS__) gmock_a10) constness { \
  609. GMOCK_MOCKER_(10, constness, Method).RegisterOwner(this); \
  610. return GMOCK_MOCKER_(10, constness, Method).With(gmock_a1, gmock_a2, \
  611. gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9, \
  612. gmock_a10); \
  613. } \
  614. mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(10, constness, \
  615. Method)
  616. #define MOCK_METHOD0(m, ...) GMOCK_METHOD0_(, , , m, __VA_ARGS__)
  617. #define MOCK_METHOD1(m, ...) GMOCK_METHOD1_(, , , m, __VA_ARGS__)
  618. #define MOCK_METHOD2(m, ...) GMOCK_METHOD2_(, , , m, __VA_ARGS__)
  619. #define MOCK_METHOD3(m, ...) GMOCK_METHOD3_(, , , m, __VA_ARGS__)
  620. #define MOCK_METHOD4(m, ...) GMOCK_METHOD4_(, , , m, __VA_ARGS__)
  621. #define MOCK_METHOD5(m, ...) GMOCK_METHOD5_(, , , m, __VA_ARGS__)
  622. #define MOCK_METHOD6(m, ...) GMOCK_METHOD6_(, , , m, __VA_ARGS__)
  623. #define MOCK_METHOD7(m, ...) GMOCK_METHOD7_(, , , m, __VA_ARGS__)
  624. #define MOCK_METHOD8(m, ...) GMOCK_METHOD8_(, , , m, __VA_ARGS__)
  625. #define MOCK_METHOD9(m, ...) GMOCK_METHOD9_(, , , m, __VA_ARGS__)
  626. #define MOCK_METHOD10(m, ...) GMOCK_METHOD10_(, , , m, __VA_ARGS__)
  627. #define MOCK_CONST_METHOD0(m, ...) GMOCK_METHOD0_(, const, , m, __VA_ARGS__)
  628. #define MOCK_CONST_METHOD1(m, ...) GMOCK_METHOD1_(, const, , m, __VA_ARGS__)
  629. #define MOCK_CONST_METHOD2(m, ...) GMOCK_METHOD2_(, const, , m, __VA_ARGS__)
  630. #define MOCK_CONST_METHOD3(m, ...) GMOCK_METHOD3_(, const, , m, __VA_ARGS__)
  631. #define MOCK_CONST_METHOD4(m, ...) GMOCK_METHOD4_(, const, , m, __VA_ARGS__)
  632. #define MOCK_CONST_METHOD5(m, ...) GMOCK_METHOD5_(, const, , m, __VA_ARGS__)
  633. #define MOCK_CONST_METHOD6(m, ...) GMOCK_METHOD6_(, const, , m, __VA_ARGS__)
  634. #define MOCK_CONST_METHOD7(m, ...) GMOCK_METHOD7_(, const, , m, __VA_ARGS__)
  635. #define MOCK_CONST_METHOD8(m, ...) GMOCK_METHOD8_(, const, , m, __VA_ARGS__)
  636. #define MOCK_CONST_METHOD9(m, ...) GMOCK_METHOD9_(, const, , m, __VA_ARGS__)
  637. #define MOCK_CONST_METHOD10(m, ...) GMOCK_METHOD10_(, const, , m, __VA_ARGS__)
  638. #define MOCK_METHOD0_T(m, ...) GMOCK_METHOD0_(typename, , , m, __VA_ARGS__)
  639. #define MOCK_METHOD1_T(m, ...) GMOCK_METHOD1_(typename, , , m, __VA_ARGS__)
  640. #define MOCK_METHOD2_T(m, ...) GMOCK_METHOD2_(typename, , , m, __VA_ARGS__)
  641. #define MOCK_METHOD3_T(m, ...) GMOCK_METHOD3_(typename, , , m, __VA_ARGS__)
  642. #define MOCK_METHOD4_T(m, ...) GMOCK_METHOD4_(typename, , , m, __VA_ARGS__)
  643. #define MOCK_METHOD5_T(m, ...) GMOCK_METHOD5_(typename, , , m, __VA_ARGS__)
  644. #define MOCK_METHOD6_T(m, ...) GMOCK_METHOD6_(typename, , , m, __VA_ARGS__)
  645. #define MOCK_METHOD7_T(m, ...) GMOCK_METHOD7_(typename, , , m, __VA_ARGS__)
  646. #define MOCK_METHOD8_T(m, ...) GMOCK_METHOD8_(typename, , , m, __VA_ARGS__)
  647. #define MOCK_METHOD9_T(m, ...) GMOCK_METHOD9_(typename, , , m, __VA_ARGS__)
  648. #define MOCK_METHOD10_T(m, ...) GMOCK_METHOD10_(typename, , , m, __VA_ARGS__)
  649. #define MOCK_CONST_METHOD0_T(m, ...) \
  650. GMOCK_METHOD0_(typename, const, , m, __VA_ARGS__)
  651. #define MOCK_CONST_METHOD1_T(m, ...) \
  652. GMOCK_METHOD1_(typename, const, , m, __VA_ARGS__)
  653. #define MOCK_CONST_METHOD2_T(m, ...) \
  654. GMOCK_METHOD2_(typename, const, , m, __VA_ARGS__)
  655. #define MOCK_CONST_METHOD3_T(m, ...) \
  656. GMOCK_METHOD3_(typename, const, , m, __VA_ARGS__)
  657. #define MOCK_CONST_METHOD4_T(m, ...) \
  658. GMOCK_METHOD4_(typename, const, , m, __VA_ARGS__)
  659. #define MOCK_CONST_METHOD5_T(m, ...) \
  660. GMOCK_METHOD5_(typename, const, , m, __VA_ARGS__)
  661. #define MOCK_CONST_METHOD6_T(m, ...) \
  662. GMOCK_METHOD6_(typename, const, , m, __VA_ARGS__)
  663. #define MOCK_CONST_METHOD7_T(m, ...) \
  664. GMOCK_METHOD7_(typename, const, , m, __VA_ARGS__)
  665. #define MOCK_CONST_METHOD8_T(m, ...) \
  666. GMOCK_METHOD8_(typename, const, , m, __VA_ARGS__)
  667. #define MOCK_CONST_METHOD9_T(m, ...) \
  668. GMOCK_METHOD9_(typename, const, , m, __VA_ARGS__)
  669. #define MOCK_CONST_METHOD10_T(m, ...) \
  670. GMOCK_METHOD10_(typename, const, , m, __VA_ARGS__)
  671. #define MOCK_METHOD0_WITH_CALLTYPE(ct, m, ...) \
  672. GMOCK_METHOD0_(, , ct, m, __VA_ARGS__)
  673. #define MOCK_METHOD1_WITH_CALLTYPE(ct, m, ...) \
  674. GMOCK_METHOD1_(, , ct, m, __VA_ARGS__)
  675. #define MOCK_METHOD2_WITH_CALLTYPE(ct, m, ...) \
  676. GMOCK_METHOD2_(, , ct, m, __VA_ARGS__)
  677. #define MOCK_METHOD3_WITH_CALLTYPE(ct, m, ...) \
  678. GMOCK_METHOD3_(, , ct, m, __VA_ARGS__)
  679. #define MOCK_METHOD4_WITH_CALLTYPE(ct, m, ...) \
  680. GMOCK_METHOD4_(, , ct, m, __VA_ARGS__)
  681. #define MOCK_METHOD5_WITH_CALLTYPE(ct, m, ...) \
  682. GMOCK_METHOD5_(, , ct, m, __VA_ARGS__)
  683. #define MOCK_METHOD6_WITH_CALLTYPE(ct, m, ...) \
  684. GMOCK_METHOD6_(, , ct, m, __VA_ARGS__)
  685. #define MOCK_METHOD7_WITH_CALLTYPE(ct, m, ...) \
  686. GMOCK_METHOD7_(, , ct, m, __VA_ARGS__)
  687. #define MOCK_METHOD8_WITH_CALLTYPE(ct, m, ...) \
  688. GMOCK_METHOD8_(, , ct, m, __VA_ARGS__)
  689. #define MOCK_METHOD9_WITH_CALLTYPE(ct, m, ...) \
  690. GMOCK_METHOD9_(, , ct, m, __VA_ARGS__)
  691. #define MOCK_METHOD10_WITH_CALLTYPE(ct, m, ...) \
  692. GMOCK_METHOD10_(, , ct, m, __VA_ARGS__)
  693. #define MOCK_CONST_METHOD0_WITH_CALLTYPE(ct, m, ...) \
  694. GMOCK_METHOD0_(, const, ct, m, __VA_ARGS__)
  695. #define MOCK_CONST_METHOD1_WITH_CALLTYPE(ct, m, ...) \
  696. GMOCK_METHOD1_(, const, ct, m, __VA_ARGS__)
  697. #define MOCK_CONST_METHOD2_WITH_CALLTYPE(ct, m, ...) \
  698. GMOCK_METHOD2_(, const, ct, m, __VA_ARGS__)
  699. #define MOCK_CONST_METHOD3_WITH_CALLTYPE(ct, m, ...) \
  700. GMOCK_METHOD3_(, const, ct, m, __VA_ARGS__)
  701. #define MOCK_CONST_METHOD4_WITH_CALLTYPE(ct, m, ...) \
  702. GMOCK_METHOD4_(, const, ct, m, __VA_ARGS__)
  703. #define MOCK_CONST_METHOD5_WITH_CALLTYPE(ct, m, ...) \
  704. GMOCK_METHOD5_(, const, ct, m, __VA_ARGS__)
  705. #define MOCK_CONST_METHOD6_WITH_CALLTYPE(ct, m, ...) \
  706. GMOCK_METHOD6_(, const, ct, m, __VA_ARGS__)
  707. #define MOCK_CONST_METHOD7_WITH_CALLTYPE(ct, m, ...) \
  708. GMOCK_METHOD7_(, const, ct, m, __VA_ARGS__)
  709. #define MOCK_CONST_METHOD8_WITH_CALLTYPE(ct, m, ...) \
  710. GMOCK_METHOD8_(, const, ct, m, __VA_ARGS__)
  711. #define MOCK_CONST_METHOD9_WITH_CALLTYPE(ct, m, ...) \
  712. GMOCK_METHOD9_(, const, ct, m, __VA_ARGS__)
  713. #define MOCK_CONST_METHOD10_WITH_CALLTYPE(ct, m, ...) \
  714. GMOCK_METHOD10_(, const, ct, m, __VA_ARGS__)
  715. #define MOCK_METHOD0_T_WITH_CALLTYPE(ct, m, ...) \
  716. GMOCK_METHOD0_(typename, , ct, m, __VA_ARGS__)
  717. #define MOCK_METHOD1_T_WITH_CALLTYPE(ct, m, ...) \
  718. GMOCK_METHOD1_(typename, , ct, m, __VA_ARGS__)
  719. #define MOCK_METHOD2_T_WITH_CALLTYPE(ct, m, ...) \
  720. GMOCK_METHOD2_(typename, , ct, m, __VA_ARGS__)
  721. #define MOCK_METHOD3_T_WITH_CALLTYPE(ct, m, ...) \
  722. GMOCK_METHOD3_(typename, , ct, m, __VA_ARGS__)
  723. #define MOCK_METHOD4_T_WITH_CALLTYPE(ct, m, ...) \
  724. GMOCK_METHOD4_(typename, , ct, m, __VA_ARGS__)
  725. #define MOCK_METHOD5_T_WITH_CALLTYPE(ct, m, ...) \
  726. GMOCK_METHOD5_(typename, , ct, m, __VA_ARGS__)
  727. #define MOCK_METHOD6_T_WITH_CALLTYPE(ct, m, ...) \
  728. GMOCK_METHOD6_(typename, , ct, m, __VA_ARGS__)
  729. #define MOCK_METHOD7_T_WITH_CALLTYPE(ct, m, ...) \
  730. GMOCK_METHOD7_(typename, , ct, m, __VA_ARGS__)
  731. #define MOCK_METHOD8_T_WITH_CALLTYPE(ct, m, ...) \
  732. GMOCK_METHOD8_(typename, , ct, m, __VA_ARGS__)
  733. #define MOCK_METHOD9_T_WITH_CALLTYPE(ct, m, ...) \
  734. GMOCK_METHOD9_(typename, , ct, m, __VA_ARGS__)
  735. #define MOCK_METHOD10_T_WITH_CALLTYPE(ct, m, ...) \
  736. GMOCK_METHOD10_(typename, , ct, m, __VA_ARGS__)
  737. #define MOCK_CONST_METHOD0_T_WITH_CALLTYPE(ct, m, ...) \
  738. GMOCK_METHOD0_(typename, const, ct, m, __VA_ARGS__)
  739. #define MOCK_CONST_METHOD1_T_WITH_CALLTYPE(ct, m, ...) \
  740. GMOCK_METHOD1_(typename, const, ct, m, __VA_ARGS__)
  741. #define MOCK_CONST_METHOD2_T_WITH_CALLTYPE(ct, m, ...) \
  742. GMOCK_METHOD2_(typename, const, ct, m, __VA_ARGS__)
  743. #define MOCK_CONST_METHOD3_T_WITH_CALLTYPE(ct, m, ...) \
  744. GMOCK_METHOD3_(typename, const, ct, m, __VA_ARGS__)
  745. #define MOCK_CONST_METHOD4_T_WITH_CALLTYPE(ct, m, ...) \
  746. GMOCK_METHOD4_(typename, const, ct, m, __VA_ARGS__)
  747. #define MOCK_CONST_METHOD5_T_WITH_CALLTYPE(ct, m, ...) \
  748. GMOCK_METHOD5_(typename, const, ct, m, __VA_ARGS__)
  749. #define MOCK_CONST_METHOD6_T_WITH_CALLTYPE(ct, m, ...) \
  750. GMOCK_METHOD6_(typename, const, ct, m, __VA_ARGS__)
  751. #define MOCK_CONST_METHOD7_T_WITH_CALLTYPE(ct, m, ...) \
  752. GMOCK_METHOD7_(typename, const, ct, m, __VA_ARGS__)
  753. #define MOCK_CONST_METHOD8_T_WITH_CALLTYPE(ct, m, ...) \
  754. GMOCK_METHOD8_(typename, const, ct, m, __VA_ARGS__)
  755. #define MOCK_CONST_METHOD9_T_WITH_CALLTYPE(ct, m, ...) \
  756. GMOCK_METHOD9_(typename, const, ct, m, __VA_ARGS__)
  757. #define MOCK_CONST_METHOD10_T_WITH_CALLTYPE(ct, m, ...) \
  758. GMOCK_METHOD10_(typename, const, ct, m, __VA_ARGS__)
  759. // A MockFunction<F> class has one mock method whose type is F. It is
  760. // useful when you just want your test code to emit some messages and
  761. // have Google Mock verify the right messages are sent (and perhaps at
  762. // the right times). For example, if you are exercising code:
  763. //
  764. // Foo(1);
  765. // Foo(2);
  766. // Foo(3);
  767. //
  768. // and want to verify that Foo(1) and Foo(3) both invoke
  769. // mock.Bar("a"), but Foo(2) doesn't invoke anything, you can write:
  770. //
  771. // TEST(FooTest, InvokesBarCorrectly) {
  772. // MyMock mock;
  773. // MockFunction<void(string check_point_name)> check;
  774. // {
  775. // InSequence s;
  776. //
  777. // EXPECT_CALL(mock, Bar("a"));
  778. // EXPECT_CALL(check, Call("1"));
  779. // EXPECT_CALL(check, Call("2"));
  780. // EXPECT_CALL(mock, Bar("a"));
  781. // }
  782. // Foo(1);
  783. // check.Call("1");
  784. // Foo(2);
  785. // check.Call("2");
  786. // Foo(3);
  787. // }
  788. //
  789. // The expectation spec says that the first Bar("a") must happen
  790. // before check point "1", the second Bar("a") must happen after check
  791. // point "2", and nothing should happen between the two check
  792. // points. The explicit check points make it easy to tell which
  793. // Bar("a") is called by which call to Foo().
  794. //
  795. // MockFunction<F> can also be used to exercise code that accepts
  796. // std::function<F> callbacks. To do so, use AsStdFunction() method
  797. // to create std::function proxy forwarding to original object's Call.
  798. // Example:
  799. //
  800. // TEST(FooTest, RunsCallbackWithBarArgument) {
  801. // MockFunction<int(string)> callback;
  802. // EXPECT_CALL(callback, Call("bar")).WillOnce(Return(1));
  803. // Foo(callback.AsStdFunction());
  804. // }
  805. template <typename F>
  806. class MockFunction;
  807. template <typename R>
  808. class MockFunction<R()> {
  809. public:
  810. MockFunction() {}
  811. MOCK_METHOD0_T(Call, R());
  812. #if GTEST_HAS_STD_FUNCTION_
  813. std::function<R()> AsStdFunction() {
  814. return [this]() -> R {
  815. return this->Call();
  816. };
  817. }
  818. #endif // GTEST_HAS_STD_FUNCTION_
  819. private:
  820. GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
  821. };
  822. template <typename R, typename A0>
  823. class MockFunction<R(A0)> {
  824. public:
  825. MockFunction() {}
  826. MOCK_METHOD1_T(Call, R(A0));
  827. #if GTEST_HAS_STD_FUNCTION_
  828. std::function<R(A0)> AsStdFunction() {
  829. return [this](A0 a0) -> R {
  830. return this->Call(a0);
  831. };
  832. }
  833. #endif // GTEST_HAS_STD_FUNCTION_
  834. private:
  835. GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
  836. };
  837. template <typename R, typename A0, typename A1>
  838. class MockFunction<R(A0, A1)> {
  839. public:
  840. MockFunction() {}
  841. MOCK_METHOD2_T(Call, R(A0, A1));
  842. #if GTEST_HAS_STD_FUNCTION_
  843. std::function<R(A0, A1)> AsStdFunction() {
  844. return [this](A0 a0, A1 a1) -> R {
  845. return this->Call(a0, a1);
  846. };
  847. }
  848. #endif // GTEST_HAS_STD_FUNCTION_
  849. private:
  850. GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
  851. };
  852. template <typename R, typename A0, typename A1, typename A2>
  853. class MockFunction<R(A0, A1, A2)> {
  854. public:
  855. MockFunction() {}
  856. MOCK_METHOD3_T(Call, R(A0, A1, A2));
  857. #if GTEST_HAS_STD_FUNCTION_
  858. std::function<R(A0, A1, A2)> AsStdFunction() {
  859. return [this](A0 a0, A1 a1, A2 a2) -> R {
  860. return this->Call(a0, a1, a2);
  861. };
  862. }
  863. #endif // GTEST_HAS_STD_FUNCTION_
  864. private:
  865. GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
  866. };
  867. template <typename R, typename A0, typename A1, typename A2, typename A3>
  868. class MockFunction<R(A0, A1, A2, A3)> {
  869. public:
  870. MockFunction() {}
  871. MOCK_METHOD4_T(Call, R(A0, A1, A2, A3));
  872. #if GTEST_HAS_STD_FUNCTION_
  873. std::function<R(A0, A1, A2, A3)> AsStdFunction() {
  874. return [this](A0 a0, A1 a1, A2 a2, A3 a3) -> R {
  875. return this->Call(a0, a1, a2, a3);
  876. };
  877. }
  878. #endif // GTEST_HAS_STD_FUNCTION_
  879. private:
  880. GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
  881. };
  882. template <typename R, typename A0, typename A1, typename A2, typename A3,
  883. typename A4>
  884. class MockFunction<R(A0, A1, A2, A3, A4)> {
  885. public:
  886. MockFunction() {}
  887. MOCK_METHOD5_T(Call, R(A0, A1, A2, A3, A4));
  888. #if GTEST_HAS_STD_FUNCTION_
  889. std::function<R(A0, A1, A2, A3, A4)> AsStdFunction() {
  890. return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) -> R {
  891. return this->Call(a0, a1, a2, a3, a4);
  892. };
  893. }
  894. #endif // GTEST_HAS_STD_FUNCTION_
  895. private:
  896. GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
  897. };
  898. template <typename R, typename A0, typename A1, typename A2, typename A3,
  899. typename A4, typename A5>
  900. class MockFunction<R(A0, A1, A2, A3, A4, A5)> {
  901. public:
  902. MockFunction() {}
  903. MOCK_METHOD6_T(Call, R(A0, A1, A2, A3, A4, A5));
  904. #if GTEST_HAS_STD_FUNCTION_
  905. std::function<R(A0, A1, A2, A3, A4, A5)> AsStdFunction() {
  906. return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) -> R {
  907. return this->Call(a0, a1, a2, a3, a4, a5);
  908. };
  909. }
  910. #endif // GTEST_HAS_STD_FUNCTION_
  911. private:
  912. GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
  913. };
  914. template <typename R, typename A0, typename A1, typename A2, typename A3,
  915. typename A4, typename A5, typename A6>
  916. class MockFunction<R(A0, A1, A2, A3, A4, A5, A6)> {
  917. public:
  918. MockFunction() {}
  919. MOCK_METHOD7_T(Call, R(A0, A1, A2, A3, A4, A5, A6));
  920. #if GTEST_HAS_STD_FUNCTION_
  921. std::function<R(A0, A1, A2, A3, A4, A5, A6)> AsStdFunction() {
  922. return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) -> R {
  923. return this->Call(a0, a1, a2, a3, a4, a5, a6);
  924. };
  925. }
  926. #endif // GTEST_HAS_STD_FUNCTION_
  927. private:
  928. GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
  929. };
  930. template <typename R, typename A0, typename A1, typename A2, typename A3,
  931. typename A4, typename A5, typename A6, typename A7>
  932. class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7)> {
  933. public:
  934. MockFunction() {}
  935. MOCK_METHOD8_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7));
  936. #if GTEST_HAS_STD_FUNCTION_
  937. std::function<R(A0, A1, A2, A3, A4, A5, A6, A7)> AsStdFunction() {
  938. return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) -> R {
  939. return this->Call(a0, a1, a2, a3, a4, a5, a6, a7);
  940. };
  941. }
  942. #endif // GTEST_HAS_STD_FUNCTION_
  943. private:
  944. GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
  945. };
  946. template <typename R, typename A0, typename A1, typename A2, typename A3,
  947. typename A4, typename A5, typename A6, typename A7, typename A8>
  948. class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8)> {
  949. public:
  950. MockFunction() {}
  951. MOCK_METHOD9_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8));
  952. #if GTEST_HAS_STD_FUNCTION_
  953. std::function<R(A0, A1, A2, A3, A4, A5, A6, A7, A8)> AsStdFunction() {
  954. return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7,
  955. A8 a8) -> R {
  956. return this->Call(a0, a1, a2, a3, a4, a5, a6, a7, a8);
  957. };
  958. }
  959. #endif // GTEST_HAS_STD_FUNCTION_
  960. private:
  961. GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
  962. };
  963. template <typename R, typename A0, typename A1, typename A2, typename A3,
  964. typename A4, typename A5, typename A6, typename A7, typename A8,
  965. typename A9>
  966. class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
  967. public:
  968. MockFunction() {}
  969. MOCK_METHOD10_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9));
  970. #if GTEST_HAS_STD_FUNCTION_
  971. std::function<R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)> AsStdFunction() {
  972. return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7,
  973. A8 a8, A9 a9) -> R {
  974. return this->Call(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);
  975. };
  976. }
  977. #endif // GTEST_HAS_STD_FUNCTION_
  978. private:
  979. GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
  980. };
  981. } // namespace testing
  982. #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_