gmock-generated-function-mockers.h 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380
  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. // Google Mock - a framework for writing C++ mock classes.
  33. //
  34. // This file implements function mockers of various arities.
  35. // GOOGLETEST_CM0002 DO NOT DELETE
  36. #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
  37. #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
  38. #include "gmock/gmock-spec-builders.h"
  39. #include "gmock/internal/gmock-internal-utils.h"
  40. #if GTEST_HAS_STD_FUNCTION_
  41. # include <functional>
  42. #endif
  43. namespace testing {
  44. namespace internal {
  45. template <typename F>
  46. class FunctionMockerBase;
  47. // Note: class FunctionMocker really belongs to the ::testing
  48. // namespace. However if we define it in ::testing, MSVC will
  49. // complain when classes in ::testing::internal declare it as a
  50. // friend class template. To workaround this compiler bug, we define
  51. // FunctionMocker in ::testing::internal and import it into ::testing.
  52. template <typename F>
  53. class FunctionMocker;
  54. template <typename R>
  55. class FunctionMocker<R()> : public
  56. internal::FunctionMockerBase<R()> {
  57. public:
  58. typedef R F();
  59. typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
  60. MockSpec<F> With() {
  61. return MockSpec<F>(this, ::testing::make_tuple());
  62. }
  63. R Invoke() {
  64. // Even though gcc and MSVC don't enforce it, 'this->' is required
  65. // by the C++ standard [14.6.4] here, as the base class type is
  66. // dependent on the template argument (and thus shouldn't be
  67. // looked into when resolving InvokeWith).
  68. return this->InvokeWith(ArgumentTuple());
  69. }
  70. };
  71. template <typename R, typename A1>
  72. class FunctionMocker<R(A1)> : public
  73. internal::FunctionMockerBase<R(A1)> {
  74. public:
  75. typedef R F(A1);
  76. typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
  77. MockSpec<F> With(const Matcher<A1>& m1) {
  78. return MockSpec<F>(this, ::testing::make_tuple(m1));
  79. }
  80. R Invoke(A1 a1) {
  81. // Even though gcc and MSVC don't enforce it, 'this->' is required
  82. // by the C++ standard [14.6.4] here, as the base class type is
  83. // dependent on the template argument (and thus shouldn't be
  84. // looked into when resolving InvokeWith).
  85. return this->InvokeWith(ArgumentTuple(internal::forward<A1>(a1)));
  86. }
  87. };
  88. template <typename R, typename A1, typename A2>
  89. class FunctionMocker<R(A1, A2)> : public
  90. internal::FunctionMockerBase<R(A1, A2)> {
  91. public:
  92. typedef R F(A1, A2);
  93. typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
  94. MockSpec<F> With(const Matcher<A1>& m1, const Matcher<A2>& m2) {
  95. return MockSpec<F>(this, ::testing::make_tuple(m1, m2));
  96. }
  97. R Invoke(A1 a1, A2 a2) {
  98. // Even though gcc and MSVC don't enforce it, 'this->' is required
  99. // by the C++ standard [14.6.4] here, as the base class type is
  100. // dependent on the template argument (and thus shouldn't be
  101. // looked into when resolving InvokeWith).
  102. return this->InvokeWith(ArgumentTuple(internal::forward<A1>(a1),
  103. internal::forward<A2>(a2)));
  104. }
  105. };
  106. template <typename R, typename A1, typename A2, typename A3>
  107. class FunctionMocker<R(A1, A2, A3)> : public
  108. internal::FunctionMockerBase<R(A1, A2, A3)> {
  109. public:
  110. typedef R F(A1, A2, A3);
  111. typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
  112. MockSpec<F> With(const Matcher<A1>& m1, const Matcher<A2>& m2,
  113. const Matcher<A3>& m3) {
  114. return MockSpec<F>(this, ::testing::make_tuple(m1, m2, m3));
  115. }
  116. R Invoke(A1 a1, A2 a2, A3 a3) {
  117. // Even though gcc and MSVC don't enforce it, 'this->' is required
  118. // by the C++ standard [14.6.4] here, as the base class type is
  119. // dependent on the template argument (and thus shouldn't be
  120. // looked into when resolving InvokeWith).
  121. return this->InvokeWith(ArgumentTuple(internal::forward<A1>(a1),
  122. internal::forward<A2>(a2), internal::forward<A3>(a3)));
  123. }
  124. };
  125. template <typename R, typename A1, typename A2, typename A3, typename A4>
  126. class FunctionMocker<R(A1, A2, A3, A4)> : public
  127. internal::FunctionMockerBase<R(A1, A2, A3, A4)> {
  128. public:
  129. typedef R F(A1, A2, A3, A4);
  130. typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
  131. MockSpec<F> With(const Matcher<A1>& m1, const Matcher<A2>& m2,
  132. const Matcher<A3>& m3, const Matcher<A4>& m4) {
  133. return MockSpec<F>(this, ::testing::make_tuple(m1, m2, m3, m4));
  134. }
  135. R Invoke(A1 a1, A2 a2, A3 a3, A4 a4) {
  136. // Even though gcc and MSVC don't enforce it, 'this->' is required
  137. // by the C++ standard [14.6.4] here, as the base class type is
  138. // dependent on the template argument (and thus shouldn't be
  139. // looked into when resolving InvokeWith).
  140. return this->InvokeWith(ArgumentTuple(internal::forward<A1>(a1),
  141. internal::forward<A2>(a2), internal::forward<A3>(a3),
  142. internal::forward<A4>(a4)));
  143. }
  144. };
  145. template <typename R, typename A1, typename A2, typename A3, typename A4,
  146. typename A5>
  147. class FunctionMocker<R(A1, A2, A3, A4, A5)> : public
  148. internal::FunctionMockerBase<R(A1, A2, A3, A4, A5)> {
  149. public:
  150. typedef R F(A1, A2, A3, A4, A5);
  151. typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
  152. MockSpec<F> With(const Matcher<A1>& m1, const Matcher<A2>& m2,
  153. const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5) {
  154. return MockSpec<F>(this, ::testing::make_tuple(m1, m2, m3, m4, m5));
  155. }
  156. R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {
  157. // Even though gcc and MSVC don't enforce it, 'this->' is required
  158. // by the C++ standard [14.6.4] here, as the base class type is
  159. // dependent on the template argument (and thus shouldn't be
  160. // looked into when resolving InvokeWith).
  161. return this->InvokeWith(ArgumentTuple(internal::forward<A1>(a1),
  162. internal::forward<A2>(a2), internal::forward<A3>(a3),
  163. internal::forward<A4>(a4), internal::forward<A5>(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. return MockSpec<F>(this, ::testing::make_tuple(m1, m2, m3, m4, m5, m6));
  177. }
  178. R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) {
  179. // Even though gcc and MSVC don't enforce it, 'this->' is required
  180. // by the C++ standard [14.6.4] here, as the base class type is
  181. // dependent on the template argument (and thus shouldn't be
  182. // looked into when resolving InvokeWith).
  183. return this->InvokeWith(ArgumentTuple(internal::forward<A1>(a1),
  184. internal::forward<A2>(a2), internal::forward<A3>(a3),
  185. internal::forward<A4>(a4), internal::forward<A5>(a5),
  186. internal::forward<A6>(a6)));
  187. }
  188. };
  189. template <typename R, typename A1, typename A2, typename A3, typename A4,
  190. typename A5, typename A6, typename A7>
  191. class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7)> : public
  192. internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7)> {
  193. public:
  194. typedef R F(A1, A2, A3, A4, A5, A6, A7);
  195. typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
  196. MockSpec<F> With(const Matcher<A1>& m1, const Matcher<A2>& m2,
  197. const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
  198. const Matcher<A6>& m6, const Matcher<A7>& m7) {
  199. return MockSpec<F>(this, ::testing::make_tuple(m1, m2, m3, m4, m5, m6, m7));
  200. }
  201. R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) {
  202. // Even though gcc and MSVC don't enforce it, 'this->' is required
  203. // by the C++ standard [14.6.4] here, as the base class type is
  204. // dependent on the template argument (and thus shouldn't be
  205. // looked into when resolving InvokeWith).
  206. return this->InvokeWith(ArgumentTuple(internal::forward<A1>(a1),
  207. internal::forward<A2>(a2), internal::forward<A3>(a3),
  208. internal::forward<A4>(a4), internal::forward<A5>(a5),
  209. internal::forward<A6>(a6), internal::forward<A7>(a7)));
  210. }
  211. };
  212. template <typename R, typename A1, typename A2, typename A3, typename A4,
  213. typename A5, typename A6, typename A7, typename A8>
  214. class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8)> : public
  215. internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8)> {
  216. public:
  217. typedef R F(A1, A2, A3, A4, A5, A6, A7, A8);
  218. typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
  219. MockSpec<F> With(const Matcher<A1>& m1, const Matcher<A2>& m2,
  220. const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
  221. const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8) {
  222. return MockSpec<F>(this, ::testing::make_tuple(m1, m2, m3, m4, m5, m6, m7,
  223. m8));
  224. }
  225. R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) {
  226. // Even though gcc and MSVC don't enforce it, 'this->' is required
  227. // by the C++ standard [14.6.4] here, as the base class type is
  228. // dependent on the template argument (and thus shouldn't be
  229. // looked into when resolving InvokeWith).
  230. return this->InvokeWith(ArgumentTuple(internal::forward<A1>(a1),
  231. internal::forward<A2>(a2), internal::forward<A3>(a3),
  232. internal::forward<A4>(a4), internal::forward<A5>(a5),
  233. internal::forward<A6>(a6), internal::forward<A7>(a7),
  234. internal::forward<A8>(a8)));
  235. }
  236. };
  237. template <typename R, typename A1, typename A2, typename A3, typename A4,
  238. typename A5, typename A6, typename A7, typename A8, typename A9>
  239. class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> : public
  240. internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
  241. public:
  242. typedef R F(A1, A2, A3, A4, A5, A6, A7, A8, A9);
  243. typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
  244. MockSpec<F> With(const Matcher<A1>& m1, const Matcher<A2>& m2,
  245. const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
  246. const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8,
  247. const Matcher<A9>& m9) {
  248. return MockSpec<F>(this, ::testing::make_tuple(m1, m2, m3, m4, m5, m6, m7,
  249. m8, m9));
  250. }
  251. R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) {
  252. // Even though gcc and MSVC don't enforce it, 'this->' is required
  253. // by the C++ standard [14.6.4] here, as the base class type is
  254. // dependent on the template argument (and thus shouldn't be
  255. // looked into when resolving InvokeWith).
  256. return this->InvokeWith(ArgumentTuple(internal::forward<A1>(a1),
  257. internal::forward<A2>(a2), internal::forward<A3>(a3),
  258. internal::forward<A4>(a4), internal::forward<A5>(a5),
  259. internal::forward<A6>(a6), internal::forward<A7>(a7),
  260. internal::forward<A8>(a8), internal::forward<A9>(a9)));
  261. }
  262. };
  263. template <typename R, typename A1, typename A2, typename A3, typename A4,
  264. typename A5, typename A6, typename A7, typename A8, typename A9,
  265. typename A10>
  266. class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> : public
  267. internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> {
  268. public:
  269. typedef R F(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
  270. typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
  271. MockSpec<F> With(const Matcher<A1>& m1, const Matcher<A2>& m2,
  272. const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
  273. const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8,
  274. const Matcher<A9>& m9, const Matcher<A10>& m10) {
  275. return MockSpec<F>(this, ::testing::make_tuple(m1, m2, m3, m4, m5, m6, m7,
  276. m8, m9, m10));
  277. }
  278. R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9,
  279. A10 a10) {
  280. // Even though gcc and MSVC don't enforce it, 'this->' is required
  281. // by the C++ standard [14.6.4] here, as the base class type is
  282. // dependent on the template argument (and thus shouldn't be
  283. // looked into when resolving InvokeWith).
  284. return this->InvokeWith(ArgumentTuple(internal::forward<A1>(a1),
  285. internal::forward<A2>(a2), internal::forward<A3>(a3),
  286. internal::forward<A4>(a4), internal::forward<A5>(a5),
  287. internal::forward<A6>(a6), internal::forward<A7>(a7),
  288. internal::forward<A8>(a8), internal::forward<A9>(a9),
  289. internal::forward<A10>(a10)));
  290. }
  291. };
  292. // Removes the given pointer; this is a helper for the expectation setter method
  293. // for parameterless matchers.
  294. //
  295. // We want to make sure that the user cannot set a parameterless expectation on
  296. // overloaded methods, including methods which are overloaded on const. Example:
  297. //
  298. // class MockClass {
  299. // MOCK_METHOD0(GetName, string&());
  300. // MOCK_CONST_METHOD0(GetName, const string&());
  301. // };
  302. //
  303. // TEST() {
  304. // // This should be an error, as it's not clear which overload is expected.
  305. // EXPECT_CALL(mock, GetName).WillOnce(ReturnRef(value));
  306. // }
  307. //
  308. // Here are the generated expectation-setter methods:
  309. //
  310. // class MockClass {
  311. // // Overload 1
  312. // MockSpec<string&()> gmock_GetName() { ... }
  313. // // Overload 2. Declared const so that the compiler will generate an
  314. // // error when trying to resolve between this and overload 4 in
  315. // // 'gmock_GetName(WithoutMatchers(), nullptr)'.
  316. // MockSpec<string&()> gmock_GetName(
  317. // const WithoutMatchers&, const Function<string&()>*) const {
  318. // // Removes const from this, calls overload 1
  319. // return AdjustConstness_(this)->gmock_GetName();
  320. // }
  321. //
  322. // // Overload 3
  323. // const string& gmock_GetName() const { ... }
  324. // // Overload 4
  325. // MockSpec<const string&()> gmock_GetName(
  326. // const WithoutMatchers&, const Function<const string&()>*) const {
  327. // // Does not remove const, calls overload 3
  328. // return AdjustConstness_const(this)->gmock_GetName();
  329. // }
  330. // }
  331. //
  332. template <typename MockType>
  333. const MockType* AdjustConstness_const(const MockType* mock) {
  334. return mock;
  335. }
  336. // Removes const from and returns the given pointer; this is a helper for the
  337. // expectation setter method for parameterless matchers.
  338. template <typename MockType>
  339. MockType* AdjustConstness_(const MockType* mock) {
  340. return const_cast<MockType*>(mock);
  341. }
  342. } // namespace internal
  343. // The style guide prohibits "using" statements in a namespace scope
  344. // inside a header file. However, the FunctionMocker class template
  345. // is meant to be defined in the ::testing namespace. The following
  346. // line is just a trick for working around a bug in MSVC 8.0, which
  347. // cannot handle it if we define FunctionMocker in ::testing.
  348. using internal::FunctionMocker;
  349. // GMOCK_RESULT_(tn, F) expands to the result type of function type F.
  350. // We define this as a variadic macro in case F contains unprotected
  351. // commas (the same reason that we use variadic macros in other places
  352. // in this file).
  353. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  354. #define GMOCK_RESULT_(tn, ...) \
  355. tn ::testing::internal::Function<__VA_ARGS__>::Result
  356. // The type of argument N of the given function type.
  357. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  358. #define GMOCK_ARG_(tn, N, ...) \
  359. tn ::testing::internal::Function<__VA_ARGS__>::Argument##N
  360. // The matcher type for argument N of the given function type.
  361. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  362. #define GMOCK_MATCHER_(tn, N, ...) \
  363. const ::testing::Matcher<GMOCK_ARG_(tn, N, __VA_ARGS__)>&
  364. // The variable for mocking the given method.
  365. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  366. #define GMOCK_MOCKER_(arity, constness, Method) \
  367. GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__)
  368. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  369. #define GMOCK_METHOD0_(tn, constness, ct, Method, ...) \
  370. GMOCK_RESULT_(tn, __VA_ARGS__) ct Method() constness { \
  371. GTEST_COMPILE_ASSERT_( \
  372. (::testing::tuple_size<tn ::testing::internal::Function< \
  373. __VA_ARGS__>::ArgumentTuple>::value == 0), \
  374. this_method_does_not_take_0_arguments); \
  375. GMOCK_MOCKER_(0, constness, Method).SetOwnerAndName(this, #Method); \
  376. return GMOCK_MOCKER_(0, constness, Method).Invoke(); \
  377. } \
  378. ::testing::MockSpec<__VA_ARGS__> gmock_##Method() constness { \
  379. GMOCK_MOCKER_(0, constness, Method).RegisterOwner(this); \
  380. return GMOCK_MOCKER_(0, constness, Method).With(); \
  381. } \
  382. ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
  383. const ::testing::internal::WithoutMatchers&, \
  384. constness ::testing::internal::Function<__VA_ARGS__>*) const { \
  385. return ::testing::internal::AdjustConstness_##constness(this) \
  386. ->gmock_##Method(); \
  387. } \
  388. mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(0, constness, \
  389. Method)
  390. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  391. #define GMOCK_METHOD1_(tn, constness, ct, Method, ...) \
  392. GMOCK_RESULT_(tn, __VA_ARGS__) \
  393. ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1) constness { \
  394. GTEST_COMPILE_ASSERT_( \
  395. (::testing::tuple_size<tn ::testing::internal::Function< \
  396. __VA_ARGS__>::ArgumentTuple>::value == 1), \
  397. this_method_does_not_take_1_argument); \
  398. GMOCK_MOCKER_(1, constness, Method).SetOwnerAndName(this, #Method); \
  399. return GMOCK_MOCKER_(1, constness, Method) \
  400. .Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
  401. gmock_a1)); \
  402. } \
  403. ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
  404. GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1) constness { \
  405. GMOCK_MOCKER_(1, constness, Method).RegisterOwner(this); \
  406. return GMOCK_MOCKER_(1, constness, Method).With(gmock_a1); \
  407. } \
  408. ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
  409. const ::testing::internal::WithoutMatchers&, \
  410. constness ::testing::internal::Function<__VA_ARGS__>*) const { \
  411. return ::testing::internal::AdjustConstness_##constness(this) \
  412. ->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>()); \
  413. } \
  414. mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(1, constness, \
  415. Method)
  416. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  417. #define GMOCK_METHOD2_(tn, constness, ct, Method, ...) \
  418. GMOCK_RESULT_(tn, __VA_ARGS__) \
  419. ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
  420. GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2) constness { \
  421. GTEST_COMPILE_ASSERT_( \
  422. (::testing::tuple_size<tn ::testing::internal::Function< \
  423. __VA_ARGS__>::ArgumentTuple>::value == 2), \
  424. this_method_does_not_take_2_arguments); \
  425. GMOCK_MOCKER_(2, constness, Method).SetOwnerAndName(this, #Method); \
  426. return GMOCK_MOCKER_(2, constness, Method) \
  427. .Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
  428. gmock_a1), \
  429. ::testing::internal::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>( \
  430. gmock_a2)); \
  431. } \
  432. ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
  433. GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
  434. GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2) constness { \
  435. GMOCK_MOCKER_(2, constness, Method).RegisterOwner(this); \
  436. return GMOCK_MOCKER_(2, constness, Method).With(gmock_a1, gmock_a2); \
  437. } \
  438. ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
  439. const ::testing::internal::WithoutMatchers&, \
  440. constness ::testing::internal::Function<__VA_ARGS__>*) const { \
  441. return ::testing::internal::AdjustConstness_##constness(this) \
  442. ->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
  443. ::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>()); \
  444. } \
  445. mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(2, constness, \
  446. Method)
  447. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  448. #define GMOCK_METHOD3_(tn, constness, ct, Method, ...) \
  449. GMOCK_RESULT_(tn, __VA_ARGS__) \
  450. ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
  451. GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
  452. GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3) constness { \
  453. GTEST_COMPILE_ASSERT_( \
  454. (::testing::tuple_size<tn ::testing::internal::Function< \
  455. __VA_ARGS__>::ArgumentTuple>::value == 3), \
  456. this_method_does_not_take_3_arguments); \
  457. GMOCK_MOCKER_(3, constness, Method).SetOwnerAndName(this, #Method); \
  458. return GMOCK_MOCKER_(3, constness, Method) \
  459. .Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
  460. gmock_a1), \
  461. ::testing::internal::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>( \
  462. gmock_a2), \
  463. ::testing::internal::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>( \
  464. gmock_a3)); \
  465. } \
  466. ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
  467. GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
  468. GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
  469. GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3) constness { \
  470. GMOCK_MOCKER_(3, constness, Method).RegisterOwner(this); \
  471. return GMOCK_MOCKER_(3, constness, Method) \
  472. .With(gmock_a1, gmock_a2, gmock_a3); \
  473. } \
  474. ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
  475. const ::testing::internal::WithoutMatchers&, \
  476. constness ::testing::internal::Function<__VA_ARGS__>*) const { \
  477. return ::testing::internal::AdjustConstness_##constness(this) \
  478. ->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
  479. ::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
  480. ::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>()); \
  481. } \
  482. mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(3, constness, \
  483. Method)
  484. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  485. #define GMOCK_METHOD4_(tn, constness, ct, Method, ...) \
  486. GMOCK_RESULT_(tn, __VA_ARGS__) \
  487. ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
  488. GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
  489. GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
  490. GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4) constness { \
  491. GTEST_COMPILE_ASSERT_( \
  492. (::testing::tuple_size<tn ::testing::internal::Function< \
  493. __VA_ARGS__>::ArgumentTuple>::value == 4), \
  494. this_method_does_not_take_4_arguments); \
  495. GMOCK_MOCKER_(4, constness, Method).SetOwnerAndName(this, #Method); \
  496. return GMOCK_MOCKER_(4, constness, Method) \
  497. .Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
  498. gmock_a1), \
  499. ::testing::internal::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>( \
  500. gmock_a2), \
  501. ::testing::internal::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>( \
  502. gmock_a3), \
  503. ::testing::internal::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>( \
  504. gmock_a4)); \
  505. } \
  506. ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
  507. GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
  508. GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
  509. GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
  510. GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4) constness { \
  511. GMOCK_MOCKER_(4, constness, Method).RegisterOwner(this); \
  512. return GMOCK_MOCKER_(4, constness, Method) \
  513. .With(gmock_a1, gmock_a2, gmock_a3, gmock_a4); \
  514. } \
  515. ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
  516. const ::testing::internal::WithoutMatchers&, \
  517. constness ::testing::internal::Function<__VA_ARGS__>*) const { \
  518. return ::testing::internal::AdjustConstness_##constness(this) \
  519. ->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
  520. ::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
  521. ::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
  522. ::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>()); \
  523. } \
  524. mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(4, constness, \
  525. Method)
  526. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  527. #define GMOCK_METHOD5_(tn, constness, ct, Method, ...) \
  528. GMOCK_RESULT_(tn, __VA_ARGS__) \
  529. ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
  530. GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
  531. GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
  532. GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
  533. GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5) constness { \
  534. GTEST_COMPILE_ASSERT_( \
  535. (::testing::tuple_size<tn ::testing::internal::Function< \
  536. __VA_ARGS__>::ArgumentTuple>::value == 5), \
  537. this_method_does_not_take_5_arguments); \
  538. GMOCK_MOCKER_(5, constness, Method).SetOwnerAndName(this, #Method); \
  539. return GMOCK_MOCKER_(5, constness, Method) \
  540. .Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
  541. gmock_a1), \
  542. ::testing::internal::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>( \
  543. gmock_a2), \
  544. ::testing::internal::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>( \
  545. gmock_a3), \
  546. ::testing::internal::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>( \
  547. gmock_a4), \
  548. ::testing::internal::forward<GMOCK_ARG_(tn, 5, __VA_ARGS__)>( \
  549. gmock_a5)); \
  550. } \
  551. ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
  552. GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
  553. GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
  554. GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
  555. GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
  556. GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5) constness { \
  557. GMOCK_MOCKER_(5, constness, Method).RegisterOwner(this); \
  558. return GMOCK_MOCKER_(5, constness, Method) \
  559. .With(gmock_a1, gmock_a2, gmock_a3, gmock_a4, gmock_a5); \
  560. } \
  561. ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
  562. const ::testing::internal::WithoutMatchers&, \
  563. constness ::testing::internal::Function<__VA_ARGS__>*) const { \
  564. return ::testing::internal::AdjustConstness_##constness(this) \
  565. ->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
  566. ::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
  567. ::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
  568. ::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(), \
  569. ::testing::A<GMOCK_ARG_(tn, 5, __VA_ARGS__)>()); \
  570. } \
  571. mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(5, constness, \
  572. Method)
  573. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  574. #define GMOCK_METHOD6_(tn, constness, ct, Method, ...) \
  575. GMOCK_RESULT_(tn, __VA_ARGS__) \
  576. ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
  577. GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
  578. GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
  579. GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
  580. GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
  581. GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6) constness { \
  582. GTEST_COMPILE_ASSERT_( \
  583. (::testing::tuple_size<tn ::testing::internal::Function< \
  584. __VA_ARGS__>::ArgumentTuple>::value == 6), \
  585. this_method_does_not_take_6_arguments); \
  586. GMOCK_MOCKER_(6, constness, Method).SetOwnerAndName(this, #Method); \
  587. return GMOCK_MOCKER_(6, constness, Method) \
  588. .Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
  589. gmock_a1), \
  590. ::testing::internal::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>( \
  591. gmock_a2), \
  592. ::testing::internal::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>( \
  593. gmock_a3), \
  594. ::testing::internal::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>( \
  595. gmock_a4), \
  596. ::testing::internal::forward<GMOCK_ARG_(tn, 5, __VA_ARGS__)>( \
  597. gmock_a5), \
  598. ::testing::internal::forward<GMOCK_ARG_(tn, 6, __VA_ARGS__)>( \
  599. gmock_a6)); \
  600. } \
  601. ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
  602. GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
  603. GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
  604. GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
  605. GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
  606. GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
  607. GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6) constness { \
  608. GMOCK_MOCKER_(6, constness, Method).RegisterOwner(this); \
  609. return GMOCK_MOCKER_(6, constness, Method) \
  610. .With(gmock_a1, gmock_a2, gmock_a3, gmock_a4, gmock_a5, gmock_a6); \
  611. } \
  612. ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
  613. const ::testing::internal::WithoutMatchers&, \
  614. constness ::testing::internal::Function<__VA_ARGS__>*) const { \
  615. return ::testing::internal::AdjustConstness_##constness(this) \
  616. ->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
  617. ::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
  618. ::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
  619. ::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(), \
  620. ::testing::A<GMOCK_ARG_(tn, 5, __VA_ARGS__)>(), \
  621. ::testing::A<GMOCK_ARG_(tn, 6, __VA_ARGS__)>()); \
  622. } \
  623. mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(6, constness, \
  624. Method)
  625. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  626. #define GMOCK_METHOD7_(tn, constness, ct, Method, ...) \
  627. GMOCK_RESULT_(tn, __VA_ARGS__) \
  628. ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
  629. GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
  630. GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
  631. GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
  632. GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
  633. GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
  634. GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7) constness { \
  635. GTEST_COMPILE_ASSERT_( \
  636. (::testing::tuple_size<tn ::testing::internal::Function< \
  637. __VA_ARGS__>::ArgumentTuple>::value == 7), \
  638. this_method_does_not_take_7_arguments); \
  639. GMOCK_MOCKER_(7, constness, Method).SetOwnerAndName(this, #Method); \
  640. return GMOCK_MOCKER_(7, constness, Method) \
  641. .Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
  642. gmock_a1), \
  643. ::testing::internal::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>( \
  644. gmock_a2), \
  645. ::testing::internal::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>( \
  646. gmock_a3), \
  647. ::testing::internal::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>( \
  648. gmock_a4), \
  649. ::testing::internal::forward<GMOCK_ARG_(tn, 5, __VA_ARGS__)>( \
  650. gmock_a5), \
  651. ::testing::internal::forward<GMOCK_ARG_(tn, 6, __VA_ARGS__)>( \
  652. gmock_a6), \
  653. ::testing::internal::forward<GMOCK_ARG_(tn, 7, __VA_ARGS__)>( \
  654. gmock_a7)); \
  655. } \
  656. ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
  657. GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
  658. GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
  659. GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
  660. GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
  661. GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
  662. GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
  663. GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7) constness { \
  664. GMOCK_MOCKER_(7, constness, Method).RegisterOwner(this); \
  665. return GMOCK_MOCKER_(7, constness, Method) \
  666. .With(gmock_a1, gmock_a2, gmock_a3, gmock_a4, gmock_a5, gmock_a6, \
  667. gmock_a7); \
  668. } \
  669. ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
  670. const ::testing::internal::WithoutMatchers&, \
  671. constness ::testing::internal::Function<__VA_ARGS__>*) const { \
  672. return ::testing::internal::AdjustConstness_##constness(this) \
  673. ->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
  674. ::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
  675. ::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
  676. ::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(), \
  677. ::testing::A<GMOCK_ARG_(tn, 5, __VA_ARGS__)>(), \
  678. ::testing::A<GMOCK_ARG_(tn, 6, __VA_ARGS__)>(), \
  679. ::testing::A<GMOCK_ARG_(tn, 7, __VA_ARGS__)>()); \
  680. } \
  681. mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(7, constness, \
  682. Method)
  683. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  684. #define GMOCK_METHOD8_(tn, constness, ct, Method, ...) \
  685. GMOCK_RESULT_(tn, __VA_ARGS__) \
  686. ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
  687. GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
  688. GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
  689. GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
  690. GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
  691. GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
  692. GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \
  693. GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8) constness { \
  694. GTEST_COMPILE_ASSERT_( \
  695. (::testing::tuple_size<tn ::testing::internal::Function< \
  696. __VA_ARGS__>::ArgumentTuple>::value == 8), \
  697. this_method_does_not_take_8_arguments); \
  698. GMOCK_MOCKER_(8, constness, Method).SetOwnerAndName(this, #Method); \
  699. return GMOCK_MOCKER_(8, constness, Method) \
  700. .Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
  701. gmock_a1), \
  702. ::testing::internal::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>( \
  703. gmock_a2), \
  704. ::testing::internal::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>( \
  705. gmock_a3), \
  706. ::testing::internal::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>( \
  707. gmock_a4), \
  708. ::testing::internal::forward<GMOCK_ARG_(tn, 5, __VA_ARGS__)>( \
  709. gmock_a5), \
  710. ::testing::internal::forward<GMOCK_ARG_(tn, 6, __VA_ARGS__)>( \
  711. gmock_a6), \
  712. ::testing::internal::forward<GMOCK_ARG_(tn, 7, __VA_ARGS__)>( \
  713. gmock_a7), \
  714. ::testing::internal::forward<GMOCK_ARG_(tn, 8, __VA_ARGS__)>( \
  715. gmock_a8)); \
  716. } \
  717. ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
  718. GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
  719. GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
  720. GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
  721. GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
  722. GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
  723. GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
  724. GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \
  725. GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8) constness { \
  726. GMOCK_MOCKER_(8, constness, Method).RegisterOwner(this); \
  727. return GMOCK_MOCKER_(8, constness, Method) \
  728. .With(gmock_a1, gmock_a2, gmock_a3, gmock_a4, gmock_a5, gmock_a6, \
  729. gmock_a7, gmock_a8); \
  730. } \
  731. ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
  732. const ::testing::internal::WithoutMatchers&, \
  733. constness ::testing::internal::Function<__VA_ARGS__>*) const { \
  734. return ::testing::internal::AdjustConstness_##constness(this) \
  735. ->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
  736. ::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
  737. ::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
  738. ::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(), \
  739. ::testing::A<GMOCK_ARG_(tn, 5, __VA_ARGS__)>(), \
  740. ::testing::A<GMOCK_ARG_(tn, 6, __VA_ARGS__)>(), \
  741. ::testing::A<GMOCK_ARG_(tn, 7, __VA_ARGS__)>(), \
  742. ::testing::A<GMOCK_ARG_(tn, 8, __VA_ARGS__)>()); \
  743. } \
  744. mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(8, constness, \
  745. Method)
  746. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  747. #define GMOCK_METHOD9_(tn, constness, ct, Method, ...) \
  748. GMOCK_RESULT_(tn, __VA_ARGS__) \
  749. ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
  750. GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
  751. GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
  752. GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
  753. GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
  754. GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
  755. GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \
  756. GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8, \
  757. GMOCK_ARG_(tn, 9, __VA_ARGS__) gmock_a9) constness { \
  758. GTEST_COMPILE_ASSERT_( \
  759. (::testing::tuple_size<tn ::testing::internal::Function< \
  760. __VA_ARGS__>::ArgumentTuple>::value == 9), \
  761. this_method_does_not_take_9_arguments); \
  762. GMOCK_MOCKER_(9, constness, Method).SetOwnerAndName(this, #Method); \
  763. return GMOCK_MOCKER_(9, constness, Method) \
  764. .Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
  765. gmock_a1), \
  766. ::testing::internal::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>( \
  767. gmock_a2), \
  768. ::testing::internal::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>( \
  769. gmock_a3), \
  770. ::testing::internal::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>( \
  771. gmock_a4), \
  772. ::testing::internal::forward<GMOCK_ARG_(tn, 5, __VA_ARGS__)>( \
  773. gmock_a5), \
  774. ::testing::internal::forward<GMOCK_ARG_(tn, 6, __VA_ARGS__)>( \
  775. gmock_a6), \
  776. ::testing::internal::forward<GMOCK_ARG_(tn, 7, __VA_ARGS__)>( \
  777. gmock_a7), \
  778. ::testing::internal::forward<GMOCK_ARG_(tn, 8, __VA_ARGS__)>( \
  779. gmock_a8), \
  780. ::testing::internal::forward<GMOCK_ARG_(tn, 9, __VA_ARGS__)>( \
  781. gmock_a9)); \
  782. } \
  783. ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
  784. GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
  785. GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
  786. GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
  787. GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
  788. GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
  789. GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
  790. GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \
  791. GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8, \
  792. GMOCK_MATCHER_(tn, 9, __VA_ARGS__) gmock_a9) constness { \
  793. GMOCK_MOCKER_(9, constness, Method).RegisterOwner(this); \
  794. return GMOCK_MOCKER_(9, constness, Method) \
  795. .With(gmock_a1, gmock_a2, gmock_a3, gmock_a4, gmock_a5, gmock_a6, \
  796. gmock_a7, gmock_a8, gmock_a9); \
  797. } \
  798. ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
  799. const ::testing::internal::WithoutMatchers&, \
  800. constness ::testing::internal::Function<__VA_ARGS__>*) const { \
  801. return ::testing::internal::AdjustConstness_##constness(this) \
  802. ->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
  803. ::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
  804. ::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
  805. ::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(), \
  806. ::testing::A<GMOCK_ARG_(tn, 5, __VA_ARGS__)>(), \
  807. ::testing::A<GMOCK_ARG_(tn, 6, __VA_ARGS__)>(), \
  808. ::testing::A<GMOCK_ARG_(tn, 7, __VA_ARGS__)>(), \
  809. ::testing::A<GMOCK_ARG_(tn, 8, __VA_ARGS__)>(), \
  810. ::testing::A<GMOCK_ARG_(tn, 9, __VA_ARGS__)>()); \
  811. } \
  812. mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(9, constness, \
  813. Method)
  814. // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
  815. #define GMOCK_METHOD10_(tn, constness, ct, Method, ...) \
  816. GMOCK_RESULT_(tn, __VA_ARGS__) \
  817. ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
  818. GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
  819. GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
  820. GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
  821. GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
  822. GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
  823. GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \
  824. GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8, \
  825. GMOCK_ARG_(tn, 9, __VA_ARGS__) gmock_a9, \
  826. GMOCK_ARG_(tn, 10, __VA_ARGS__) gmock_a10) constness { \
  827. GTEST_COMPILE_ASSERT_( \
  828. (::testing::tuple_size<tn ::testing::internal::Function< \
  829. __VA_ARGS__>::ArgumentTuple>::value == 10), \
  830. this_method_does_not_take_10_arguments); \
  831. GMOCK_MOCKER_(10, constness, Method).SetOwnerAndName(this, #Method); \
  832. return GMOCK_MOCKER_(10, constness, Method) \
  833. .Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
  834. gmock_a1), \
  835. ::testing::internal::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>( \
  836. gmock_a2), \
  837. ::testing::internal::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>( \
  838. gmock_a3), \
  839. ::testing::internal::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>( \
  840. gmock_a4), \
  841. ::testing::internal::forward<GMOCK_ARG_(tn, 5, __VA_ARGS__)>( \
  842. gmock_a5), \
  843. ::testing::internal::forward<GMOCK_ARG_(tn, 6, __VA_ARGS__)>( \
  844. gmock_a6), \
  845. ::testing::internal::forward<GMOCK_ARG_(tn, 7, __VA_ARGS__)>( \
  846. gmock_a7), \
  847. ::testing::internal::forward<GMOCK_ARG_(tn, 8, __VA_ARGS__)>( \
  848. gmock_a8), \
  849. ::testing::internal::forward<GMOCK_ARG_(tn, 9, __VA_ARGS__)>( \
  850. gmock_a9), \
  851. ::testing::internal::forward<GMOCK_ARG_(tn, 10, __VA_ARGS__)>( \
  852. gmock_a10)); \
  853. } \
  854. ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
  855. GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
  856. GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
  857. GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
  858. GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
  859. GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
  860. GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
  861. GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \
  862. GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8, \
  863. GMOCK_MATCHER_(tn, 9, __VA_ARGS__) gmock_a9, \
  864. GMOCK_MATCHER_(tn, 10, __VA_ARGS__) gmock_a10) constness { \
  865. GMOCK_MOCKER_(10, constness, Method).RegisterOwner(this); \
  866. return GMOCK_MOCKER_(10, constness, Method) \
  867. .With(gmock_a1, gmock_a2, gmock_a3, gmock_a4, gmock_a5, gmock_a6, \
  868. gmock_a7, gmock_a8, gmock_a9, gmock_a10); \
  869. } \
  870. ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
  871. const ::testing::internal::WithoutMatchers&, \
  872. constness ::testing::internal::Function<__VA_ARGS__>*) const { \
  873. return ::testing::internal::AdjustConstness_##constness(this) \
  874. ->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
  875. ::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
  876. ::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
  877. ::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(), \
  878. ::testing::A<GMOCK_ARG_(tn, 5, __VA_ARGS__)>(), \
  879. ::testing::A<GMOCK_ARG_(tn, 6, __VA_ARGS__)>(), \
  880. ::testing::A<GMOCK_ARG_(tn, 7, __VA_ARGS__)>(), \
  881. ::testing::A<GMOCK_ARG_(tn, 8, __VA_ARGS__)>(), \
  882. ::testing::A<GMOCK_ARG_(tn, 9, __VA_ARGS__)>(), \
  883. ::testing::A<GMOCK_ARG_(tn, 10, __VA_ARGS__)>()); \
  884. } \
  885. mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(10, constness, \
  886. Method)
  887. #define MOCK_METHOD0(m, ...) GMOCK_METHOD0_(, , , m, __VA_ARGS__)
  888. #define MOCK_METHOD1(m, ...) GMOCK_METHOD1_(, , , m, __VA_ARGS__)
  889. #define MOCK_METHOD2(m, ...) GMOCK_METHOD2_(, , , m, __VA_ARGS__)
  890. #define MOCK_METHOD3(m, ...) GMOCK_METHOD3_(, , , m, __VA_ARGS__)
  891. #define MOCK_METHOD4(m, ...) GMOCK_METHOD4_(, , , m, __VA_ARGS__)
  892. #define MOCK_METHOD5(m, ...) GMOCK_METHOD5_(, , , m, __VA_ARGS__)
  893. #define MOCK_METHOD6(m, ...) GMOCK_METHOD6_(, , , m, __VA_ARGS__)
  894. #define MOCK_METHOD7(m, ...) GMOCK_METHOD7_(, , , m, __VA_ARGS__)
  895. #define MOCK_METHOD8(m, ...) GMOCK_METHOD8_(, , , m, __VA_ARGS__)
  896. #define MOCK_METHOD9(m, ...) GMOCK_METHOD9_(, , , m, __VA_ARGS__)
  897. #define MOCK_METHOD10(m, ...) GMOCK_METHOD10_(, , , m, __VA_ARGS__)
  898. #define MOCK_CONST_METHOD0(m, ...) GMOCK_METHOD0_(, const, , m, __VA_ARGS__)
  899. #define MOCK_CONST_METHOD1(m, ...) GMOCK_METHOD1_(, const, , m, __VA_ARGS__)
  900. #define MOCK_CONST_METHOD2(m, ...) GMOCK_METHOD2_(, const, , m, __VA_ARGS__)
  901. #define MOCK_CONST_METHOD3(m, ...) GMOCK_METHOD3_(, const, , m, __VA_ARGS__)
  902. #define MOCK_CONST_METHOD4(m, ...) GMOCK_METHOD4_(, const, , m, __VA_ARGS__)
  903. #define MOCK_CONST_METHOD5(m, ...) GMOCK_METHOD5_(, const, , m, __VA_ARGS__)
  904. #define MOCK_CONST_METHOD6(m, ...) GMOCK_METHOD6_(, const, , m, __VA_ARGS__)
  905. #define MOCK_CONST_METHOD7(m, ...) GMOCK_METHOD7_(, const, , m, __VA_ARGS__)
  906. #define MOCK_CONST_METHOD8(m, ...) GMOCK_METHOD8_(, const, , m, __VA_ARGS__)
  907. #define MOCK_CONST_METHOD9(m, ...) GMOCK_METHOD9_(, const, , m, __VA_ARGS__)
  908. #define MOCK_CONST_METHOD10(m, ...) GMOCK_METHOD10_(, const, , m, __VA_ARGS__)
  909. #define MOCK_METHOD0_T(m, ...) GMOCK_METHOD0_(typename, , , m, __VA_ARGS__)
  910. #define MOCK_METHOD1_T(m, ...) GMOCK_METHOD1_(typename, , , m, __VA_ARGS__)
  911. #define MOCK_METHOD2_T(m, ...) GMOCK_METHOD2_(typename, , , m, __VA_ARGS__)
  912. #define MOCK_METHOD3_T(m, ...) GMOCK_METHOD3_(typename, , , m, __VA_ARGS__)
  913. #define MOCK_METHOD4_T(m, ...) GMOCK_METHOD4_(typename, , , m, __VA_ARGS__)
  914. #define MOCK_METHOD5_T(m, ...) GMOCK_METHOD5_(typename, , , m, __VA_ARGS__)
  915. #define MOCK_METHOD6_T(m, ...) GMOCK_METHOD6_(typename, , , m, __VA_ARGS__)
  916. #define MOCK_METHOD7_T(m, ...) GMOCK_METHOD7_(typename, , , m, __VA_ARGS__)
  917. #define MOCK_METHOD8_T(m, ...) GMOCK_METHOD8_(typename, , , m, __VA_ARGS__)
  918. #define MOCK_METHOD9_T(m, ...) GMOCK_METHOD9_(typename, , , m, __VA_ARGS__)
  919. #define MOCK_METHOD10_T(m, ...) GMOCK_METHOD10_(typename, , , m, __VA_ARGS__)
  920. #define MOCK_CONST_METHOD0_T(m, ...) \
  921. GMOCK_METHOD0_(typename, const, , m, __VA_ARGS__)
  922. #define MOCK_CONST_METHOD1_T(m, ...) \
  923. GMOCK_METHOD1_(typename, const, , m, __VA_ARGS__)
  924. #define MOCK_CONST_METHOD2_T(m, ...) \
  925. GMOCK_METHOD2_(typename, const, , m, __VA_ARGS__)
  926. #define MOCK_CONST_METHOD3_T(m, ...) \
  927. GMOCK_METHOD3_(typename, const, , m, __VA_ARGS__)
  928. #define MOCK_CONST_METHOD4_T(m, ...) \
  929. GMOCK_METHOD4_(typename, const, , m, __VA_ARGS__)
  930. #define MOCK_CONST_METHOD5_T(m, ...) \
  931. GMOCK_METHOD5_(typename, const, , m, __VA_ARGS__)
  932. #define MOCK_CONST_METHOD6_T(m, ...) \
  933. GMOCK_METHOD6_(typename, const, , m, __VA_ARGS__)
  934. #define MOCK_CONST_METHOD7_T(m, ...) \
  935. GMOCK_METHOD7_(typename, const, , m, __VA_ARGS__)
  936. #define MOCK_CONST_METHOD8_T(m, ...) \
  937. GMOCK_METHOD8_(typename, const, , m, __VA_ARGS__)
  938. #define MOCK_CONST_METHOD9_T(m, ...) \
  939. GMOCK_METHOD9_(typename, const, , m, __VA_ARGS__)
  940. #define MOCK_CONST_METHOD10_T(m, ...) \
  941. GMOCK_METHOD10_(typename, const, , m, __VA_ARGS__)
  942. #define MOCK_METHOD0_WITH_CALLTYPE(ct, m, ...) \
  943. GMOCK_METHOD0_(, , ct, m, __VA_ARGS__)
  944. #define MOCK_METHOD1_WITH_CALLTYPE(ct, m, ...) \
  945. GMOCK_METHOD1_(, , ct, m, __VA_ARGS__)
  946. #define MOCK_METHOD2_WITH_CALLTYPE(ct, m, ...) \
  947. GMOCK_METHOD2_(, , ct, m, __VA_ARGS__)
  948. #define MOCK_METHOD3_WITH_CALLTYPE(ct, m, ...) \
  949. GMOCK_METHOD3_(, , ct, m, __VA_ARGS__)
  950. #define MOCK_METHOD4_WITH_CALLTYPE(ct, m, ...) \
  951. GMOCK_METHOD4_(, , ct, m, __VA_ARGS__)
  952. #define MOCK_METHOD5_WITH_CALLTYPE(ct, m, ...) \
  953. GMOCK_METHOD5_(, , ct, m, __VA_ARGS__)
  954. #define MOCK_METHOD6_WITH_CALLTYPE(ct, m, ...) \
  955. GMOCK_METHOD6_(, , ct, m, __VA_ARGS__)
  956. #define MOCK_METHOD7_WITH_CALLTYPE(ct, m, ...) \
  957. GMOCK_METHOD7_(, , ct, m, __VA_ARGS__)
  958. #define MOCK_METHOD8_WITH_CALLTYPE(ct, m, ...) \
  959. GMOCK_METHOD8_(, , ct, m, __VA_ARGS__)
  960. #define MOCK_METHOD9_WITH_CALLTYPE(ct, m, ...) \
  961. GMOCK_METHOD9_(, , ct, m, __VA_ARGS__)
  962. #define MOCK_METHOD10_WITH_CALLTYPE(ct, m, ...) \
  963. GMOCK_METHOD10_(, , ct, m, __VA_ARGS__)
  964. #define MOCK_CONST_METHOD0_WITH_CALLTYPE(ct, m, ...) \
  965. GMOCK_METHOD0_(, const, ct, m, __VA_ARGS__)
  966. #define MOCK_CONST_METHOD1_WITH_CALLTYPE(ct, m, ...) \
  967. GMOCK_METHOD1_(, const, ct, m, __VA_ARGS__)
  968. #define MOCK_CONST_METHOD2_WITH_CALLTYPE(ct, m, ...) \
  969. GMOCK_METHOD2_(, const, ct, m, __VA_ARGS__)
  970. #define MOCK_CONST_METHOD3_WITH_CALLTYPE(ct, m, ...) \
  971. GMOCK_METHOD3_(, const, ct, m, __VA_ARGS__)
  972. #define MOCK_CONST_METHOD4_WITH_CALLTYPE(ct, m, ...) \
  973. GMOCK_METHOD4_(, const, ct, m, __VA_ARGS__)
  974. #define MOCK_CONST_METHOD5_WITH_CALLTYPE(ct, m, ...) \
  975. GMOCK_METHOD5_(, const, ct, m, __VA_ARGS__)
  976. #define MOCK_CONST_METHOD6_WITH_CALLTYPE(ct, m, ...) \
  977. GMOCK_METHOD6_(, const, ct, m, __VA_ARGS__)
  978. #define MOCK_CONST_METHOD7_WITH_CALLTYPE(ct, m, ...) \
  979. GMOCK_METHOD7_(, const, ct, m, __VA_ARGS__)
  980. #define MOCK_CONST_METHOD8_WITH_CALLTYPE(ct, m, ...) \
  981. GMOCK_METHOD8_(, const, ct, m, __VA_ARGS__)
  982. #define MOCK_CONST_METHOD9_WITH_CALLTYPE(ct, m, ...) \
  983. GMOCK_METHOD9_(, const, ct, m, __VA_ARGS__)
  984. #define MOCK_CONST_METHOD10_WITH_CALLTYPE(ct, m, ...) \
  985. GMOCK_METHOD10_(, const, ct, m, __VA_ARGS__)
  986. #define MOCK_METHOD0_T_WITH_CALLTYPE(ct, m, ...) \
  987. GMOCK_METHOD0_(typename, , ct, m, __VA_ARGS__)
  988. #define MOCK_METHOD1_T_WITH_CALLTYPE(ct, m, ...) \
  989. GMOCK_METHOD1_(typename, , ct, m, __VA_ARGS__)
  990. #define MOCK_METHOD2_T_WITH_CALLTYPE(ct, m, ...) \
  991. GMOCK_METHOD2_(typename, , ct, m, __VA_ARGS__)
  992. #define MOCK_METHOD3_T_WITH_CALLTYPE(ct, m, ...) \
  993. GMOCK_METHOD3_(typename, , ct, m, __VA_ARGS__)
  994. #define MOCK_METHOD4_T_WITH_CALLTYPE(ct, m, ...) \
  995. GMOCK_METHOD4_(typename, , ct, m, __VA_ARGS__)
  996. #define MOCK_METHOD5_T_WITH_CALLTYPE(ct, m, ...) \
  997. GMOCK_METHOD5_(typename, , ct, m, __VA_ARGS__)
  998. #define MOCK_METHOD6_T_WITH_CALLTYPE(ct, m, ...) \
  999. GMOCK_METHOD6_(typename, , ct, m, __VA_ARGS__)
  1000. #define MOCK_METHOD7_T_WITH_CALLTYPE(ct, m, ...) \
  1001. GMOCK_METHOD7_(typename, , ct, m, __VA_ARGS__)
  1002. #define MOCK_METHOD8_T_WITH_CALLTYPE(ct, m, ...) \
  1003. GMOCK_METHOD8_(typename, , ct, m, __VA_ARGS__)
  1004. #define MOCK_METHOD9_T_WITH_CALLTYPE(ct, m, ...) \
  1005. GMOCK_METHOD9_(typename, , ct, m, __VA_ARGS__)
  1006. #define MOCK_METHOD10_T_WITH_CALLTYPE(ct, m, ...) \
  1007. GMOCK_METHOD10_(typename, , ct, m, __VA_ARGS__)
  1008. #define MOCK_CONST_METHOD0_T_WITH_CALLTYPE(ct, m, ...) \
  1009. GMOCK_METHOD0_(typename, const, ct, m, __VA_ARGS__)
  1010. #define MOCK_CONST_METHOD1_T_WITH_CALLTYPE(ct, m, ...) \
  1011. GMOCK_METHOD1_(typename, const, ct, m, __VA_ARGS__)
  1012. #define MOCK_CONST_METHOD2_T_WITH_CALLTYPE(ct, m, ...) \
  1013. GMOCK_METHOD2_(typename, const, ct, m, __VA_ARGS__)
  1014. #define MOCK_CONST_METHOD3_T_WITH_CALLTYPE(ct, m, ...) \
  1015. GMOCK_METHOD3_(typename, const, ct, m, __VA_ARGS__)
  1016. #define MOCK_CONST_METHOD4_T_WITH_CALLTYPE(ct, m, ...) \
  1017. GMOCK_METHOD4_(typename, const, ct, m, __VA_ARGS__)
  1018. #define MOCK_CONST_METHOD5_T_WITH_CALLTYPE(ct, m, ...) \
  1019. GMOCK_METHOD5_(typename, const, ct, m, __VA_ARGS__)
  1020. #define MOCK_CONST_METHOD6_T_WITH_CALLTYPE(ct, m, ...) \
  1021. GMOCK_METHOD6_(typename, const, ct, m, __VA_ARGS__)
  1022. #define MOCK_CONST_METHOD7_T_WITH_CALLTYPE(ct, m, ...) \
  1023. GMOCK_METHOD7_(typename, const, ct, m, __VA_ARGS__)
  1024. #define MOCK_CONST_METHOD8_T_WITH_CALLTYPE(ct, m, ...) \
  1025. GMOCK_METHOD8_(typename, const, ct, m, __VA_ARGS__)
  1026. #define MOCK_CONST_METHOD9_T_WITH_CALLTYPE(ct, m, ...) \
  1027. GMOCK_METHOD9_(typename, const, ct, m, __VA_ARGS__)
  1028. #define MOCK_CONST_METHOD10_T_WITH_CALLTYPE(ct, m, ...) \
  1029. GMOCK_METHOD10_(typename, const, ct, m, __VA_ARGS__)
  1030. // A MockFunction<F> class has one mock method whose type is F. It is
  1031. // useful when you just want your test code to emit some messages and
  1032. // have Google Mock verify the right messages are sent (and perhaps at
  1033. // the right times). For example, if you are exercising code:
  1034. //
  1035. // Foo(1);
  1036. // Foo(2);
  1037. // Foo(3);
  1038. //
  1039. // and want to verify that Foo(1) and Foo(3) both invoke
  1040. // mock.Bar("a"), but Foo(2) doesn't invoke anything, you can write:
  1041. //
  1042. // TEST(FooTest, InvokesBarCorrectly) {
  1043. // MyMock mock;
  1044. // MockFunction<void(string check_point_name)> check;
  1045. // {
  1046. // InSequence s;
  1047. //
  1048. // EXPECT_CALL(mock, Bar("a"));
  1049. // EXPECT_CALL(check, Call("1"));
  1050. // EXPECT_CALL(check, Call("2"));
  1051. // EXPECT_CALL(mock, Bar("a"));
  1052. // }
  1053. // Foo(1);
  1054. // check.Call("1");
  1055. // Foo(2);
  1056. // check.Call("2");
  1057. // Foo(3);
  1058. // }
  1059. //
  1060. // The expectation spec says that the first Bar("a") must happen
  1061. // before check point "1", the second Bar("a") must happen after check
  1062. // point "2", and nothing should happen between the two check
  1063. // points. The explicit check points make it easy to tell which
  1064. // Bar("a") is called by which call to Foo().
  1065. //
  1066. // MockFunction<F> can also be used to exercise code that accepts
  1067. // std::function<F> callbacks. To do so, use AsStdFunction() method
  1068. // to create std::function proxy forwarding to original object's Call.
  1069. // Example:
  1070. //
  1071. // TEST(FooTest, RunsCallbackWithBarArgument) {
  1072. // MockFunction<int(string)> callback;
  1073. // EXPECT_CALL(callback, Call("bar")).WillOnce(Return(1));
  1074. // Foo(callback.AsStdFunction());
  1075. // }
  1076. template <typename F>
  1077. class MockFunction;
  1078. template <typename R>
  1079. class MockFunction<R()> {
  1080. public:
  1081. MockFunction() {}
  1082. MOCK_METHOD0_T(Call, R());
  1083. #if GTEST_HAS_STD_FUNCTION_
  1084. ::std::function<R()> AsStdFunction() {
  1085. return [this]() -> R {
  1086. return this->Call();
  1087. };
  1088. }
  1089. #endif // GTEST_HAS_STD_FUNCTION_
  1090. private:
  1091. GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
  1092. };
  1093. template <typename R, typename A0>
  1094. class MockFunction<R(A0)> {
  1095. public:
  1096. MockFunction() {}
  1097. MOCK_METHOD1_T(Call, R(A0));
  1098. #if GTEST_HAS_STD_FUNCTION_
  1099. ::std::function<R(A0)> AsStdFunction() {
  1100. return [this](A0 a0) -> R {
  1101. return this->Call(::std::move(a0));
  1102. };
  1103. }
  1104. #endif // GTEST_HAS_STD_FUNCTION_
  1105. private:
  1106. GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
  1107. };
  1108. template <typename R, typename A0, typename A1>
  1109. class MockFunction<R(A0, A1)> {
  1110. public:
  1111. MockFunction() {}
  1112. MOCK_METHOD2_T(Call, R(A0, A1));
  1113. #if GTEST_HAS_STD_FUNCTION_
  1114. ::std::function<R(A0, A1)> AsStdFunction() {
  1115. return [this](A0 a0, A1 a1) -> R {
  1116. return this->Call(::std::move(a0), ::std::move(a1));
  1117. };
  1118. }
  1119. #endif // GTEST_HAS_STD_FUNCTION_
  1120. private:
  1121. GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
  1122. };
  1123. template <typename R, typename A0, typename A1, typename A2>
  1124. class MockFunction<R(A0, A1, A2)> {
  1125. public:
  1126. MockFunction() {}
  1127. MOCK_METHOD3_T(Call, R(A0, A1, A2));
  1128. #if GTEST_HAS_STD_FUNCTION_
  1129. ::std::function<R(A0, A1, A2)> AsStdFunction() {
  1130. return [this](A0 a0, A1 a1, A2 a2) -> R {
  1131. return this->Call(::std::move(a0), ::std::move(a1), ::std::move(a2));
  1132. };
  1133. }
  1134. #endif // GTEST_HAS_STD_FUNCTION_
  1135. private:
  1136. GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
  1137. };
  1138. template <typename R, typename A0, typename A1, typename A2, typename A3>
  1139. class MockFunction<R(A0, A1, A2, A3)> {
  1140. public:
  1141. MockFunction() {}
  1142. MOCK_METHOD4_T(Call, R(A0, A1, A2, A3));
  1143. #if GTEST_HAS_STD_FUNCTION_
  1144. ::std::function<R(A0, A1, A2, A3)> AsStdFunction() {
  1145. return [this](A0 a0, A1 a1, A2 a2, A3 a3) -> R {
  1146. return this->Call(::std::move(a0), ::std::move(a1), ::std::move(a2),
  1147. ::std::move(a3));
  1148. };
  1149. }
  1150. #endif // GTEST_HAS_STD_FUNCTION_
  1151. private:
  1152. GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
  1153. };
  1154. template <typename R, typename A0, typename A1, typename A2, typename A3,
  1155. typename A4>
  1156. class MockFunction<R(A0, A1, A2, A3, A4)> {
  1157. public:
  1158. MockFunction() {}
  1159. MOCK_METHOD5_T(Call, R(A0, A1, A2, A3, A4));
  1160. #if GTEST_HAS_STD_FUNCTION_
  1161. ::std::function<R(A0, A1, A2, A3, A4)> AsStdFunction() {
  1162. return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) -> R {
  1163. return this->Call(::std::move(a0), ::std::move(a1), ::std::move(a2),
  1164. ::std::move(a3), ::std::move(a4));
  1165. };
  1166. }
  1167. #endif // GTEST_HAS_STD_FUNCTION_
  1168. private:
  1169. GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
  1170. };
  1171. template <typename R, typename A0, typename A1, typename A2, typename A3,
  1172. typename A4, typename A5>
  1173. class MockFunction<R(A0, A1, A2, A3, A4, A5)> {
  1174. public:
  1175. MockFunction() {}
  1176. MOCK_METHOD6_T(Call, R(A0, A1, A2, A3, A4, A5));
  1177. #if GTEST_HAS_STD_FUNCTION_
  1178. ::std::function<R(A0, A1, A2, A3, A4, A5)> AsStdFunction() {
  1179. return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) -> R {
  1180. return this->Call(::std::move(a0), ::std::move(a1), ::std::move(a2),
  1181. ::std::move(a3), ::std::move(a4), ::std::move(a5));
  1182. };
  1183. }
  1184. #endif // GTEST_HAS_STD_FUNCTION_
  1185. private:
  1186. GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
  1187. };
  1188. template <typename R, typename A0, typename A1, typename A2, typename A3,
  1189. typename A4, typename A5, typename A6>
  1190. class MockFunction<R(A0, A1, A2, A3, A4, A5, A6)> {
  1191. public:
  1192. MockFunction() {}
  1193. MOCK_METHOD7_T(Call, R(A0, A1, A2, A3, A4, A5, A6));
  1194. #if GTEST_HAS_STD_FUNCTION_
  1195. ::std::function<R(A0, A1, A2, A3, A4, A5, A6)> AsStdFunction() {
  1196. return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) -> R {
  1197. return this->Call(::std::move(a0), ::std::move(a1), ::std::move(a2),
  1198. ::std::move(a3), ::std::move(a4), ::std::move(a5), ::std::move(a6));
  1199. };
  1200. }
  1201. #endif // GTEST_HAS_STD_FUNCTION_
  1202. private:
  1203. GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
  1204. };
  1205. template <typename R, typename A0, typename A1, typename A2, typename A3,
  1206. typename A4, typename A5, typename A6, typename A7>
  1207. class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7)> {
  1208. public:
  1209. MockFunction() {}
  1210. MOCK_METHOD8_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7));
  1211. #if GTEST_HAS_STD_FUNCTION_
  1212. ::std::function<R(A0, A1, A2, A3, A4, A5, A6, A7)> AsStdFunction() {
  1213. return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) -> R {
  1214. return this->Call(::std::move(a0), ::std::move(a1), ::std::move(a2),
  1215. ::std::move(a3), ::std::move(a4), ::std::move(a5), ::std::move(a6),
  1216. ::std::move(a7));
  1217. };
  1218. }
  1219. #endif // GTEST_HAS_STD_FUNCTION_
  1220. private:
  1221. GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
  1222. };
  1223. template <typename R, typename A0, typename A1, typename A2, typename A3,
  1224. typename A4, typename A5, typename A6, typename A7, typename A8>
  1225. class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8)> {
  1226. public:
  1227. MockFunction() {}
  1228. MOCK_METHOD9_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8));
  1229. #if GTEST_HAS_STD_FUNCTION_
  1230. ::std::function<R(A0, A1, A2, A3, A4, A5, A6, A7, A8)> AsStdFunction() {
  1231. return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7,
  1232. A8 a8) -> R {
  1233. return this->Call(::std::move(a0), ::std::move(a1), ::std::move(a2),
  1234. ::std::move(a3), ::std::move(a4), ::std::move(a5), ::std::move(a6),
  1235. ::std::move(a7), ::std::move(a8));
  1236. };
  1237. }
  1238. #endif // GTEST_HAS_STD_FUNCTION_
  1239. private:
  1240. GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
  1241. };
  1242. template <typename R, typename A0, typename A1, typename A2, typename A3,
  1243. typename A4, typename A5, typename A6, typename A7, typename A8,
  1244. typename A9>
  1245. class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
  1246. public:
  1247. MockFunction() {}
  1248. MOCK_METHOD10_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9));
  1249. #if GTEST_HAS_STD_FUNCTION_
  1250. ::std::function<R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)> AsStdFunction() {
  1251. return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7,
  1252. A8 a8, A9 a9) -> R {
  1253. return this->Call(::std::move(a0), ::std::move(a1), ::std::move(a2),
  1254. ::std::move(a3), ::std::move(a4), ::std::move(a5), ::std::move(a6),
  1255. ::std::move(a7), ::std::move(a8), ::std::move(a9));
  1256. };
  1257. }
  1258. #endif // GTEST_HAS_STD_FUNCTION_
  1259. private:
  1260. GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
  1261. };
  1262. } // namespace testing
  1263. #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_