1 | // Copyright 2007, Google Inc. |
2 | // All rights reserved. |
3 | // |
4 | // Redistribution and use in source and binary forms, with or without |
5 | // modification, are permitted provided that the following conditions are |
6 | // met: |
7 | // |
8 | // * Redistributions of source code must retain the above copyright |
9 | // notice, this list of conditions and the following disclaimer. |
10 | // * Redistributions in binary form must reproduce the above |
11 | // copyright notice, this list of conditions and the following disclaimer |
12 | // in the documentation and/or other materials provided with the |
13 | // distribution. |
14 | // * Neither the name of Google Inc. nor the names of its |
15 | // contributors may be used to endorse or promote products derived from |
16 | // this software without specific prior written permission. |
17 | // |
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | |
30 | // Google Mock - a framework for writing C++ mock classes. |
31 | // |
32 | // This file implements MOCK_METHOD. |
33 | |
34 | // IWYU pragma: private, include "gmock/gmock.h" |
35 | // IWYU pragma: friend gmock/.* |
36 | |
37 | #ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_FUNCTION_MOCKER_H_ |
38 | #define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_FUNCTION_MOCKER_H_ |
39 | |
40 | #include <type_traits> // IWYU pragma: keep |
41 | #include <utility> // IWYU pragma: keep |
42 | |
43 | #include "gmock/gmock-spec-builders.h" |
44 | #include "gmock/internal/gmock-internal-utils.h" |
45 | #include "gmock/internal/gmock-pp.h" |
46 | |
47 | namespace testing { |
48 | namespace internal { |
49 | template <typename T> |
50 | using identity_t = T; |
51 | |
52 | template <typename Pattern> |
53 | struct ThisRefAdjuster { |
54 | template <typename T> |
55 | using AdjustT = typename std::conditional< |
56 | std::is_const<typename std::remove_reference<Pattern>::type>::value, |
57 | typename std::conditional<std::is_lvalue_reference<Pattern>::value, |
58 | const T&, const T&&>::type, |
59 | typename std::conditional<std::is_lvalue_reference<Pattern>::value, T&, |
60 | T&&>::type>::type; |
61 | |
62 | template <typename MockType> |
63 | static AdjustT<MockType> Adjust(const MockType& mock) { |
64 | return static_cast<AdjustT<MockType>>(const_cast<MockType&>(mock)); |
65 | } |
66 | }; |
67 | |
68 | constexpr bool PrefixOf(const char* a, const char* b) { |
69 | return *a == 0 || (*a == *b && internal::PrefixOf(a: a + 1, b: b + 1)); |
70 | } |
71 | |
72 | template <int N, int M> |
73 | constexpr bool StartsWith(const char (&prefix)[N], const char (&str)[M]) { |
74 | return N <= M && internal::PrefixOf(a: prefix, b: str); |
75 | } |
76 | |
77 | template <int N, int M> |
78 | constexpr bool EndsWith(const char (&suffix)[N], const char (&str)[M]) { |
79 | return N <= M && internal::PrefixOf(a: suffix, b: str + M - N); |
80 | } |
81 | |
82 | template <int N, int M> |
83 | constexpr bool Equals(const char (&a)[N], const char (&b)[M]) { |
84 | return N == M && internal::PrefixOf(a, b); |
85 | } |
86 | |
87 | template <int N> |
88 | constexpr bool ValidateSpec(const char (&spec)[N]) { |
89 | return internal::Equals("const" , spec) || |
90 | internal::Equals("override" , spec) || |
91 | internal::Equals("final" , spec) || |
92 | internal::Equals("noexcept" , spec) || |
93 | (internal::StartsWith("noexcept(" , spec) && |
94 | internal::EndsWith(")" , spec)) || |
95 | internal::Equals("ref(&)" , spec) || |
96 | internal::Equals("ref(&&)" , spec) || |
97 | (internal::StartsWith("Calltype(" , spec) && |
98 | internal::EndsWith(")" , spec)); |
99 | } |
100 | |
101 | } // namespace internal |
102 | |
103 | // The style guide prohibits "using" statements in a namespace scope |
104 | // inside a header file. However, the FunctionMocker class template |
105 | // is meant to be defined in the ::testing namespace. The following |
106 | // line is just a trick for working around a bug in MSVC 8.0, which |
107 | // cannot handle it if we define FunctionMocker in ::testing. |
108 | using internal::FunctionMocker; |
109 | } // namespace testing |
110 | |
111 | #define MOCK_METHOD(...) \ |
112 | GMOCK_INTERNAL_WARNING_PUSH() \ |
113 | GMOCK_INTERNAL_WARNING_CLANG(ignored, "-Wunused-member-function") \ |
114 | GMOCK_PP_VARIADIC_CALL(GMOCK_INTERNAL_MOCK_METHOD_ARG_, __VA_ARGS__) \ |
115 | GMOCK_INTERNAL_WARNING_POP() |
116 | |
117 | #define GMOCK_INTERNAL_MOCK_METHOD_ARG_1(...) \ |
118 | GMOCK_INTERNAL_WRONG_ARITY(__VA_ARGS__) |
119 | |
120 | #define GMOCK_INTERNAL_MOCK_METHOD_ARG_2(...) \ |
121 | GMOCK_INTERNAL_WRONG_ARITY(__VA_ARGS__) |
122 | |
123 | #define GMOCK_INTERNAL_MOCK_METHOD_ARG_3(_Ret, _MethodName, _Args) \ |
124 | GMOCK_INTERNAL_MOCK_METHOD_ARG_4(_Ret, _MethodName, _Args, ()) |
125 | |
126 | #define GMOCK_INTERNAL_MOCK_METHOD_ARG_4(_Ret, _MethodName, _Args, _Spec) \ |
127 | GMOCK_INTERNAL_ASSERT_PARENTHESIS(_Args); \ |
128 | GMOCK_INTERNAL_ASSERT_PARENTHESIS(_Spec); \ |
129 | GMOCK_INTERNAL_ASSERT_VALID_SIGNATURE( \ |
130 | GMOCK_PP_NARG0 _Args, GMOCK_INTERNAL_SIGNATURE(_Ret, _Args)); \ |
131 | GMOCK_INTERNAL_ASSERT_VALID_SPEC(_Spec) \ |
132 | GMOCK_INTERNAL_MOCK_METHOD_IMPL( \ |
133 | GMOCK_PP_NARG0 _Args, _MethodName, GMOCK_INTERNAL_HAS_CONST(_Spec), \ |
134 | GMOCK_INTERNAL_HAS_OVERRIDE(_Spec), GMOCK_INTERNAL_HAS_FINAL(_Spec), \ |
135 | GMOCK_INTERNAL_GET_NOEXCEPT_SPEC(_Spec), \ |
136 | GMOCK_INTERNAL_GET_CALLTYPE_SPEC(_Spec), \ |
137 | GMOCK_INTERNAL_GET_REF_SPEC(_Spec), \ |
138 | (GMOCK_INTERNAL_SIGNATURE(_Ret, _Args))) |
139 | |
140 | #define GMOCK_INTERNAL_MOCK_METHOD_ARG_5(...) \ |
141 | GMOCK_INTERNAL_WRONG_ARITY(__VA_ARGS__) |
142 | |
143 | #define GMOCK_INTERNAL_MOCK_METHOD_ARG_6(...) \ |
144 | GMOCK_INTERNAL_WRONG_ARITY(__VA_ARGS__) |
145 | |
146 | #define GMOCK_INTERNAL_MOCK_METHOD_ARG_7(...) \ |
147 | GMOCK_INTERNAL_WRONG_ARITY(__VA_ARGS__) |
148 | |
149 | #define GMOCK_INTERNAL_WRONG_ARITY(...) \ |
150 | static_assert( \ |
151 | false, \ |
152 | "MOCK_METHOD must be called with 3 or 4 arguments. _Ret, " \ |
153 | "_MethodName, _Args and optionally _Spec. _Args and _Spec must be " \ |
154 | "enclosed in parentheses. If _Ret is a type with unprotected commas, " \ |
155 | "it must also be enclosed in parentheses.") |
156 | |
157 | #define GMOCK_INTERNAL_ASSERT_PARENTHESIS(_Tuple) \ |
158 | static_assert( \ |
159 | GMOCK_PP_IS_ENCLOSED_PARENS(_Tuple), \ |
160 | GMOCK_PP_STRINGIZE(_Tuple) " should be enclosed in parentheses.") |
161 | |
162 | #define GMOCK_INTERNAL_ASSERT_VALID_SIGNATURE(_N, ...) \ |
163 | static_assert( \ |
164 | std::is_function<__VA_ARGS__>::value, \ |
165 | "Signature must be a function type, maybe return type contains " \ |
166 | "unprotected comma."); \ |
167 | static_assert( \ |
168 | ::testing::tuple_size<typename ::testing::internal::Function< \ |
169 | __VA_ARGS__>::ArgumentTuple>::value == _N, \ |
170 | "This method does not take " GMOCK_PP_STRINGIZE( \ |
171 | _N) " arguments. Parenthesize all types with unprotected commas.") |
172 | |
173 | #define GMOCK_INTERNAL_ASSERT_VALID_SPEC(_Spec) \ |
174 | GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_ASSERT_VALID_SPEC_ELEMENT, ~, _Spec) |
175 | |
176 | #define GMOCK_INTERNAL_MOCK_METHOD_IMPL(_N, _MethodName, _Constness, \ |
177 | _Override, _Final, _NoexceptSpec, \ |
178 | _CallType, _RefSpec, _Signature) \ |
179 | typename ::testing::internal::Function<GMOCK_PP_REMOVE_PARENS( \ |
180 | _Signature)>::Result \ |
181 | GMOCK_INTERNAL_EXPAND(_CallType) \ |
182 | _MethodName(GMOCK_PP_REPEAT(GMOCK_INTERNAL_PARAMETER, _Signature, _N)) \ |
183 | GMOCK_PP_IF(_Constness, const, ) \ |
184 | _RefSpec _NoexceptSpec GMOCK_PP_IF(_Override, override, ) \ |
185 | GMOCK_PP_IF(_Final, final, ) { \ |
186 | GMOCK_MOCKER_(_N, _Constness, _MethodName) \ |
187 | .SetOwnerAndName(this, #_MethodName); \ |
188 | return GMOCK_MOCKER_(_N, _Constness, _MethodName) \ |
189 | .Invoke(GMOCK_PP_REPEAT(GMOCK_INTERNAL_FORWARD_ARG, _Signature, _N)); \ |
190 | } \ |
191 | ::testing::MockSpec<GMOCK_PP_REMOVE_PARENS(_Signature)> gmock_##_MethodName( \ |
192 | GMOCK_PP_REPEAT(GMOCK_INTERNAL_MATCHER_PARAMETER, _Signature, _N)) \ |
193 | GMOCK_PP_IF(_Constness, const, ) _RefSpec { \ |
194 | GMOCK_MOCKER_(_N, _Constness, _MethodName).RegisterOwner(this); \ |
195 | return GMOCK_MOCKER_(_N, _Constness, _MethodName) \ |
196 | .With(GMOCK_PP_REPEAT(GMOCK_INTERNAL_MATCHER_ARGUMENT, , _N)); \ |
197 | } \ |
198 | ::testing::MockSpec<GMOCK_PP_REMOVE_PARENS(_Signature)> gmock_##_MethodName( \ |
199 | const ::testing::internal::WithoutMatchers&, \ |
200 | GMOCK_PP_IF(_Constness, const, )::testing::internal::Function< \ |
201 | GMOCK_PP_REMOVE_PARENS(_Signature)>*) const _RefSpec _NoexceptSpec { \ |
202 | return ::testing::internal::ThisRefAdjuster<GMOCK_PP_IF( \ |
203 | _Constness, const, ) int _RefSpec>::Adjust(*this) \ |
204 | .gmock_##_MethodName(GMOCK_PP_REPEAT( \ |
205 | GMOCK_INTERNAL_A_MATCHER_ARGUMENT, _Signature, _N)); \ |
206 | } \ |
207 | mutable ::testing::FunctionMocker<GMOCK_PP_REMOVE_PARENS(_Signature)> \ |
208 | GMOCK_MOCKER_(_N, _Constness, _MethodName) |
209 | |
210 | #define GMOCK_INTERNAL_EXPAND(...) __VA_ARGS__ |
211 | |
212 | // Valid modifiers. |
213 | #define GMOCK_INTERNAL_HAS_CONST(_Tuple) \ |
214 | GMOCK_PP_HAS_COMMA(GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_DETECT_CONST, ~, _Tuple)) |
215 | |
216 | #define GMOCK_INTERNAL_HAS_OVERRIDE(_Tuple) \ |
217 | GMOCK_PP_HAS_COMMA( \ |
218 | GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_DETECT_OVERRIDE, ~, _Tuple)) |
219 | |
220 | #define GMOCK_INTERNAL_HAS_FINAL(_Tuple) \ |
221 | GMOCK_PP_HAS_COMMA(GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_DETECT_FINAL, ~, _Tuple)) |
222 | |
223 | #define GMOCK_INTERNAL_GET_NOEXCEPT_SPEC(_Tuple) \ |
224 | GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_NOEXCEPT_SPEC_IF_NOEXCEPT, ~, _Tuple) |
225 | |
226 | #define GMOCK_INTERNAL_NOEXCEPT_SPEC_IF_NOEXCEPT(_i, _, _elem) \ |
227 | GMOCK_PP_IF( \ |
228 | GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_NOEXCEPT(_i, _, _elem)), \ |
229 | _elem, ) |
230 | |
231 | #define GMOCK_INTERNAL_GET_CALLTYPE_SPEC(_Tuple) \ |
232 | GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_CALLTYPE_SPEC_IF_CALLTYPE, ~, _Tuple) |
233 | |
234 | #define GMOCK_INTERNAL_CALLTYPE_SPEC_IF_CALLTYPE(_i, _, _elem) \ |
235 | GMOCK_PP_IF( \ |
236 | GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_CALLTYPE(_i, _, _elem)), \ |
237 | GMOCK_PP_CAT(GMOCK_INTERNAL_UNPACK_, _elem), ) |
238 | |
239 | #define GMOCK_INTERNAL_GET_REF_SPEC(_Tuple) \ |
240 | GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_REF_SPEC_IF_REF, ~, _Tuple) |
241 | |
242 | #define GMOCK_INTERNAL_REF_SPEC_IF_REF(_i, _, _elem) \ |
243 | GMOCK_PP_IF(GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_REF(_i, _, _elem)), \ |
244 | GMOCK_PP_CAT(GMOCK_INTERNAL_UNPACK_, _elem), ) |
245 | |
246 | #ifdef GMOCK_INTERNAL_STRICT_SPEC_ASSERT |
247 | #define GMOCK_INTERNAL_ASSERT_VALID_SPEC_ELEMENT(_i, _, _elem) \ |
248 | static_assert( \ |
249 | ::testing::internal::ValidateSpec(GMOCK_PP_STRINGIZE(_elem)), \ |
250 | "Token \'" GMOCK_PP_STRINGIZE( \ |
251 | _elem) "\' cannot be recognized as a valid specification " \ |
252 | "modifier. Is a ',' missing?"); |
253 | #else |
254 | #define GMOCK_INTERNAL_ASSERT_VALID_SPEC_ELEMENT(_i, _, _elem) \ |
255 | static_assert( \ |
256 | (GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_CONST(_i, _, _elem)) + \ |
257 | GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_OVERRIDE(_i, _, _elem)) + \ |
258 | GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_FINAL(_i, _, _elem)) + \ |
259 | GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_NOEXCEPT(_i, _, _elem)) + \ |
260 | GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_REF(_i, _, _elem)) + \ |
261 | GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_CALLTYPE(_i, _, _elem))) == 1, \ |
262 | GMOCK_PP_STRINGIZE( \ |
263 | _elem) " cannot be recognized as a valid specification modifier."); |
264 | #endif // GMOCK_INTERNAL_STRICT_SPEC_ASSERT |
265 | |
266 | // Modifiers implementation. |
267 | #define GMOCK_INTERNAL_DETECT_CONST(_i, _, _elem) \ |
268 | GMOCK_PP_CAT(GMOCK_INTERNAL_DETECT_CONST_I_, _elem) |
269 | |
270 | #define GMOCK_INTERNAL_DETECT_CONST_I_const , |
271 | |
272 | #define GMOCK_INTERNAL_DETECT_OVERRIDE(_i, _, _elem) \ |
273 | GMOCK_PP_CAT(GMOCK_INTERNAL_DETECT_OVERRIDE_I_, _elem) |
274 | |
275 | #define GMOCK_INTERNAL_DETECT_OVERRIDE_I_override , |
276 | |
277 | #define GMOCK_INTERNAL_DETECT_FINAL(_i, _, _elem) \ |
278 | GMOCK_PP_CAT(GMOCK_INTERNAL_DETECT_FINAL_I_, _elem) |
279 | |
280 | #define GMOCK_INTERNAL_DETECT_FINAL_I_final , |
281 | |
282 | #define GMOCK_INTERNAL_DETECT_NOEXCEPT(_i, _, _elem) \ |
283 | GMOCK_PP_CAT(GMOCK_INTERNAL_DETECT_NOEXCEPT_I_, _elem) |
284 | |
285 | #define GMOCK_INTERNAL_DETECT_NOEXCEPT_I_noexcept , |
286 | |
287 | #define GMOCK_INTERNAL_DETECT_REF(_i, _, _elem) \ |
288 | GMOCK_PP_CAT(GMOCK_INTERNAL_DETECT_REF_I_, _elem) |
289 | |
290 | #define GMOCK_INTERNAL_DETECT_REF_I_ref , |
291 | |
292 | #define GMOCK_INTERNAL_UNPACK_ref(x) x |
293 | |
294 | #define GMOCK_INTERNAL_DETECT_CALLTYPE(_i, _, _elem) \ |
295 | GMOCK_PP_CAT(GMOCK_INTERNAL_DETECT_CALLTYPE_I_, _elem) |
296 | |
297 | #define GMOCK_INTERNAL_DETECT_CALLTYPE_I_Calltype , |
298 | |
299 | #define GMOCK_INTERNAL_UNPACK_Calltype(...) __VA_ARGS__ |
300 | |
301 | // Note: The use of `identity_t` here allows _Ret to represent return types that |
302 | // would normally need to be specified in a different way. For example, a method |
303 | // returning a function pointer must be written as |
304 | // |
305 | // fn_ptr_return_t (*method(method_args_t...))(fn_ptr_args_t...) |
306 | // |
307 | // But we only support placing the return type at the beginning. To handle this, |
308 | // we wrap all calls in identity_t, so that a declaration will be expanded to |
309 | // |
310 | // identity_t<fn_ptr_return_t (*)(fn_ptr_args_t...)> method(method_args_t...) |
311 | // |
312 | // This allows us to work around the syntactic oddities of function/method |
313 | // types. |
314 | #define GMOCK_INTERNAL_SIGNATURE(_Ret, _Args) \ |
315 | ::testing::internal::identity_t<GMOCK_PP_IF(GMOCK_PP_IS_BEGIN_PARENS(_Ret), \ |
316 | GMOCK_PP_REMOVE_PARENS, \ |
317 | GMOCK_PP_IDENTITY)(_Ret)>( \ |
318 | GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_GET_TYPE, _, _Args)) |
319 | |
320 | #define GMOCK_INTERNAL_GET_TYPE(_i, _, _elem) \ |
321 | GMOCK_PP_COMMA_IF(_i) \ |
322 | GMOCK_PP_IF(GMOCK_PP_IS_BEGIN_PARENS(_elem), GMOCK_PP_REMOVE_PARENS, \ |
323 | GMOCK_PP_IDENTITY) \ |
324 | (_elem) |
325 | |
326 | #define GMOCK_INTERNAL_PARAMETER(_i, _Signature, _) \ |
327 | GMOCK_PP_COMMA_IF(_i) \ |
328 | GMOCK_INTERNAL_ARG_O(_i, GMOCK_PP_REMOVE_PARENS(_Signature)) \ |
329 | gmock_a##_i |
330 | |
331 | #define GMOCK_INTERNAL_FORWARD_ARG(_i, _Signature, _) \ |
332 | GMOCK_PP_COMMA_IF(_i) \ |
333 | ::std::forward<GMOCK_INTERNAL_ARG_O( \ |
334 | _i, GMOCK_PP_REMOVE_PARENS(_Signature))>(gmock_a##_i) |
335 | |
336 | #define GMOCK_INTERNAL_MATCHER_PARAMETER(_i, _Signature, _) \ |
337 | GMOCK_PP_COMMA_IF(_i) \ |
338 | GMOCK_INTERNAL_MATCHER_O(_i, GMOCK_PP_REMOVE_PARENS(_Signature)) \ |
339 | gmock_a##_i |
340 | |
341 | #define GMOCK_INTERNAL_MATCHER_ARGUMENT(_i, _1, _2) \ |
342 | GMOCK_PP_COMMA_IF(_i) \ |
343 | gmock_a##_i |
344 | |
345 | #define GMOCK_INTERNAL_A_MATCHER_ARGUMENT(_i, _Signature, _) \ |
346 | GMOCK_PP_COMMA_IF(_i) \ |
347 | ::testing::A<GMOCK_INTERNAL_ARG_O(_i, GMOCK_PP_REMOVE_PARENS(_Signature))>() |
348 | |
349 | #define GMOCK_INTERNAL_ARG_O(_i, ...) \ |
350 | typename ::testing::internal::Function<__VA_ARGS__>::template Arg<_i>::type |
351 | |
352 | #define GMOCK_INTERNAL_MATCHER_O(_i, ...) \ |
353 | const ::testing::Matcher<typename ::testing::internal::Function< \ |
354 | __VA_ARGS__>::template Arg<_i>::type>& |
355 | |
356 | #define MOCK_METHOD0(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 0, __VA_ARGS__) |
357 | #define MOCK_METHOD1(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 1, __VA_ARGS__) |
358 | #define MOCK_METHOD2(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 2, __VA_ARGS__) |
359 | #define MOCK_METHOD3(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 3, __VA_ARGS__) |
360 | #define MOCK_METHOD4(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 4, __VA_ARGS__) |
361 | #define MOCK_METHOD5(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 5, __VA_ARGS__) |
362 | #define MOCK_METHOD6(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 6, __VA_ARGS__) |
363 | #define MOCK_METHOD7(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 7, __VA_ARGS__) |
364 | #define MOCK_METHOD8(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 8, __VA_ARGS__) |
365 | #define MOCK_METHOD9(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 9, __VA_ARGS__) |
366 | #define MOCK_METHOD10(m, ...) \ |
367 | GMOCK_INTERNAL_MOCK_METHODN(, , m, 10, __VA_ARGS__) |
368 | |
369 | #define MOCK_CONST_METHOD0(m, ...) \ |
370 | GMOCK_INTERNAL_MOCK_METHODN(const, , m, 0, __VA_ARGS__) |
371 | #define MOCK_CONST_METHOD1(m, ...) \ |
372 | GMOCK_INTERNAL_MOCK_METHODN(const, , m, 1, __VA_ARGS__) |
373 | #define MOCK_CONST_METHOD2(m, ...) \ |
374 | GMOCK_INTERNAL_MOCK_METHODN(const, , m, 2, __VA_ARGS__) |
375 | #define MOCK_CONST_METHOD3(m, ...) \ |
376 | GMOCK_INTERNAL_MOCK_METHODN(const, , m, 3, __VA_ARGS__) |
377 | #define MOCK_CONST_METHOD4(m, ...) \ |
378 | GMOCK_INTERNAL_MOCK_METHODN(const, , m, 4, __VA_ARGS__) |
379 | #define MOCK_CONST_METHOD5(m, ...) \ |
380 | GMOCK_INTERNAL_MOCK_METHODN(const, , m, 5, __VA_ARGS__) |
381 | #define MOCK_CONST_METHOD6(m, ...) \ |
382 | GMOCK_INTERNAL_MOCK_METHODN(const, , m, 6, __VA_ARGS__) |
383 | #define MOCK_CONST_METHOD7(m, ...) \ |
384 | GMOCK_INTERNAL_MOCK_METHODN(const, , m, 7, __VA_ARGS__) |
385 | #define MOCK_CONST_METHOD8(m, ...) \ |
386 | GMOCK_INTERNAL_MOCK_METHODN(const, , m, 8, __VA_ARGS__) |
387 | #define MOCK_CONST_METHOD9(m, ...) \ |
388 | GMOCK_INTERNAL_MOCK_METHODN(const, , m, 9, __VA_ARGS__) |
389 | #define MOCK_CONST_METHOD10(m, ...) \ |
390 | GMOCK_INTERNAL_MOCK_METHODN(const, , m, 10, __VA_ARGS__) |
391 | |
392 | #define MOCK_METHOD0_T(m, ...) MOCK_METHOD0(m, __VA_ARGS__) |
393 | #define MOCK_METHOD1_T(m, ...) MOCK_METHOD1(m, __VA_ARGS__) |
394 | #define MOCK_METHOD2_T(m, ...) MOCK_METHOD2(m, __VA_ARGS__) |
395 | #define MOCK_METHOD3_T(m, ...) MOCK_METHOD3(m, __VA_ARGS__) |
396 | #define MOCK_METHOD4_T(m, ...) MOCK_METHOD4(m, __VA_ARGS__) |
397 | #define MOCK_METHOD5_T(m, ...) MOCK_METHOD5(m, __VA_ARGS__) |
398 | #define MOCK_METHOD6_T(m, ...) MOCK_METHOD6(m, __VA_ARGS__) |
399 | #define MOCK_METHOD7_T(m, ...) MOCK_METHOD7(m, __VA_ARGS__) |
400 | #define MOCK_METHOD8_T(m, ...) MOCK_METHOD8(m, __VA_ARGS__) |
401 | #define MOCK_METHOD9_T(m, ...) MOCK_METHOD9(m, __VA_ARGS__) |
402 | #define MOCK_METHOD10_T(m, ...) MOCK_METHOD10(m, __VA_ARGS__) |
403 | |
404 | #define MOCK_CONST_METHOD0_T(m, ...) MOCK_CONST_METHOD0(m, __VA_ARGS__) |
405 | #define MOCK_CONST_METHOD1_T(m, ...) MOCK_CONST_METHOD1(m, __VA_ARGS__) |
406 | #define MOCK_CONST_METHOD2_T(m, ...) MOCK_CONST_METHOD2(m, __VA_ARGS__) |
407 | #define MOCK_CONST_METHOD3_T(m, ...) MOCK_CONST_METHOD3(m, __VA_ARGS__) |
408 | #define MOCK_CONST_METHOD4_T(m, ...) MOCK_CONST_METHOD4(m, __VA_ARGS__) |
409 | #define MOCK_CONST_METHOD5_T(m, ...) MOCK_CONST_METHOD5(m, __VA_ARGS__) |
410 | #define MOCK_CONST_METHOD6_T(m, ...) MOCK_CONST_METHOD6(m, __VA_ARGS__) |
411 | #define MOCK_CONST_METHOD7_T(m, ...) MOCK_CONST_METHOD7(m, __VA_ARGS__) |
412 | #define MOCK_CONST_METHOD8_T(m, ...) MOCK_CONST_METHOD8(m, __VA_ARGS__) |
413 | #define MOCK_CONST_METHOD9_T(m, ...) MOCK_CONST_METHOD9(m, __VA_ARGS__) |
414 | #define MOCK_CONST_METHOD10_T(m, ...) MOCK_CONST_METHOD10(m, __VA_ARGS__) |
415 | |
416 | #define MOCK_METHOD0_WITH_CALLTYPE(ct, m, ...) \ |
417 | GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 0, __VA_ARGS__) |
418 | #define MOCK_METHOD1_WITH_CALLTYPE(ct, m, ...) \ |
419 | GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 1, __VA_ARGS__) |
420 | #define MOCK_METHOD2_WITH_CALLTYPE(ct, m, ...) \ |
421 | GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 2, __VA_ARGS__) |
422 | #define MOCK_METHOD3_WITH_CALLTYPE(ct, m, ...) \ |
423 | GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 3, __VA_ARGS__) |
424 | #define MOCK_METHOD4_WITH_CALLTYPE(ct, m, ...) \ |
425 | GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 4, __VA_ARGS__) |
426 | #define MOCK_METHOD5_WITH_CALLTYPE(ct, m, ...) \ |
427 | GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 5, __VA_ARGS__) |
428 | #define MOCK_METHOD6_WITH_CALLTYPE(ct, m, ...) \ |
429 | GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 6, __VA_ARGS__) |
430 | #define MOCK_METHOD7_WITH_CALLTYPE(ct, m, ...) \ |
431 | GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 7, __VA_ARGS__) |
432 | #define MOCK_METHOD8_WITH_CALLTYPE(ct, m, ...) \ |
433 | GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 8, __VA_ARGS__) |
434 | #define MOCK_METHOD9_WITH_CALLTYPE(ct, m, ...) \ |
435 | GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 9, __VA_ARGS__) |
436 | #define MOCK_METHOD10_WITH_CALLTYPE(ct, m, ...) \ |
437 | GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 10, __VA_ARGS__) |
438 | |
439 | #define MOCK_CONST_METHOD0_WITH_CALLTYPE(ct, m, ...) \ |
440 | GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 0, __VA_ARGS__) |
441 | #define MOCK_CONST_METHOD1_WITH_CALLTYPE(ct, m, ...) \ |
442 | GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 1, __VA_ARGS__) |
443 | #define MOCK_CONST_METHOD2_WITH_CALLTYPE(ct, m, ...) \ |
444 | GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 2, __VA_ARGS__) |
445 | #define MOCK_CONST_METHOD3_WITH_CALLTYPE(ct, m, ...) \ |
446 | GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 3, __VA_ARGS__) |
447 | #define MOCK_CONST_METHOD4_WITH_CALLTYPE(ct, m, ...) \ |
448 | GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 4, __VA_ARGS__) |
449 | #define MOCK_CONST_METHOD5_WITH_CALLTYPE(ct, m, ...) \ |
450 | GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 5, __VA_ARGS__) |
451 | #define MOCK_CONST_METHOD6_WITH_CALLTYPE(ct, m, ...) \ |
452 | GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 6, __VA_ARGS__) |
453 | #define MOCK_CONST_METHOD7_WITH_CALLTYPE(ct, m, ...) \ |
454 | GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 7, __VA_ARGS__) |
455 | #define MOCK_CONST_METHOD8_WITH_CALLTYPE(ct, m, ...) \ |
456 | GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 8, __VA_ARGS__) |
457 | #define MOCK_CONST_METHOD9_WITH_CALLTYPE(ct, m, ...) \ |
458 | GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 9, __VA_ARGS__) |
459 | #define MOCK_CONST_METHOD10_WITH_CALLTYPE(ct, m, ...) \ |
460 | GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 10, __VA_ARGS__) |
461 | |
462 | #define MOCK_METHOD0_T_WITH_CALLTYPE(ct, m, ...) \ |
463 | MOCK_METHOD0_WITH_CALLTYPE(ct, m, __VA_ARGS__) |
464 | #define MOCK_METHOD1_T_WITH_CALLTYPE(ct, m, ...) \ |
465 | MOCK_METHOD1_WITH_CALLTYPE(ct, m, __VA_ARGS__) |
466 | #define MOCK_METHOD2_T_WITH_CALLTYPE(ct, m, ...) \ |
467 | MOCK_METHOD2_WITH_CALLTYPE(ct, m, __VA_ARGS__) |
468 | #define MOCK_METHOD3_T_WITH_CALLTYPE(ct, m, ...) \ |
469 | MOCK_METHOD3_WITH_CALLTYPE(ct, m, __VA_ARGS__) |
470 | #define MOCK_METHOD4_T_WITH_CALLTYPE(ct, m, ...) \ |
471 | MOCK_METHOD4_WITH_CALLTYPE(ct, m, __VA_ARGS__) |
472 | #define MOCK_METHOD5_T_WITH_CALLTYPE(ct, m, ...) \ |
473 | MOCK_METHOD5_WITH_CALLTYPE(ct, m, __VA_ARGS__) |
474 | #define MOCK_METHOD6_T_WITH_CALLTYPE(ct, m, ...) \ |
475 | MOCK_METHOD6_WITH_CALLTYPE(ct, m, __VA_ARGS__) |
476 | #define MOCK_METHOD7_T_WITH_CALLTYPE(ct, m, ...) \ |
477 | MOCK_METHOD7_WITH_CALLTYPE(ct, m, __VA_ARGS__) |
478 | #define MOCK_METHOD8_T_WITH_CALLTYPE(ct, m, ...) \ |
479 | MOCK_METHOD8_WITH_CALLTYPE(ct, m, __VA_ARGS__) |
480 | #define MOCK_METHOD9_T_WITH_CALLTYPE(ct, m, ...) \ |
481 | MOCK_METHOD9_WITH_CALLTYPE(ct, m, __VA_ARGS__) |
482 | #define MOCK_METHOD10_T_WITH_CALLTYPE(ct, m, ...) \ |
483 | MOCK_METHOD10_WITH_CALLTYPE(ct, m, __VA_ARGS__) |
484 | |
485 | #define MOCK_CONST_METHOD0_T_WITH_CALLTYPE(ct, m, ...) \ |
486 | MOCK_CONST_METHOD0_WITH_CALLTYPE(ct, m, __VA_ARGS__) |
487 | #define MOCK_CONST_METHOD1_T_WITH_CALLTYPE(ct, m, ...) \ |
488 | MOCK_CONST_METHOD1_WITH_CALLTYPE(ct, m, __VA_ARGS__) |
489 | #define MOCK_CONST_METHOD2_T_WITH_CALLTYPE(ct, m, ...) \ |
490 | MOCK_CONST_METHOD2_WITH_CALLTYPE(ct, m, __VA_ARGS__) |
491 | #define MOCK_CONST_METHOD3_T_WITH_CALLTYPE(ct, m, ...) \ |
492 | MOCK_CONST_METHOD3_WITH_CALLTYPE(ct, m, __VA_ARGS__) |
493 | #define MOCK_CONST_METHOD4_T_WITH_CALLTYPE(ct, m, ...) \ |
494 | MOCK_CONST_METHOD4_WITH_CALLTYPE(ct, m, __VA_ARGS__) |
495 | #define MOCK_CONST_METHOD5_T_WITH_CALLTYPE(ct, m, ...) \ |
496 | MOCK_CONST_METHOD5_WITH_CALLTYPE(ct, m, __VA_ARGS__) |
497 | #define MOCK_CONST_METHOD6_T_WITH_CALLTYPE(ct, m, ...) \ |
498 | MOCK_CONST_METHOD6_WITH_CALLTYPE(ct, m, __VA_ARGS__) |
499 | #define MOCK_CONST_METHOD7_T_WITH_CALLTYPE(ct, m, ...) \ |
500 | MOCK_CONST_METHOD7_WITH_CALLTYPE(ct, m, __VA_ARGS__) |
501 | #define MOCK_CONST_METHOD8_T_WITH_CALLTYPE(ct, m, ...) \ |
502 | MOCK_CONST_METHOD8_WITH_CALLTYPE(ct, m, __VA_ARGS__) |
503 | #define MOCK_CONST_METHOD9_T_WITH_CALLTYPE(ct, m, ...) \ |
504 | MOCK_CONST_METHOD9_WITH_CALLTYPE(ct, m, __VA_ARGS__) |
505 | #define MOCK_CONST_METHOD10_T_WITH_CALLTYPE(ct, m, ...) \ |
506 | MOCK_CONST_METHOD10_WITH_CALLTYPE(ct, m, __VA_ARGS__) |
507 | |
508 | #define GMOCK_INTERNAL_MOCK_METHODN(constness, ct, Method, args_num, ...) \ |
509 | GMOCK_INTERNAL_ASSERT_VALID_SIGNATURE( \ |
510 | args_num, ::testing::internal::identity_t<__VA_ARGS__>); \ |
511 | GMOCK_INTERNAL_MOCK_METHOD_IMPL( \ |
512 | args_num, Method, GMOCK_PP_NARG0(constness), 0, 0, , ct, , \ |
513 | (::testing::internal::identity_t<__VA_ARGS__>)) |
514 | |
515 | #define GMOCK_MOCKER_(arity, constness, Method) \ |
516 | GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__) |
517 | |
518 | #endif // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_FUNCTION_MOCKER_H_ |
519 | |