6#ifndef MIMICPP_INTERFACE_MOCK_HPP
7#define MIMICPP_INTERFACE_MOCK_HPP
77#define MIMICPP_DETAIL_STRIP_PARENS(x) MIMICPP_DETAIL_STRIP_PARENS_OUTER(MIMICPP_DETAIL_STRIP_PARENS_INNER x)
83#define MIMICPP_DETAIL_STRIP_PARENS_INNER(...) MIMICPP_DETAIL_STRIP_PARENS_INNER __VA_ARGS__
89#define MIMICPP_DETAIL_STRIP_PARENS_OUTER(...) MIMICPP_DETAIL_STRIP_PARENS_OUTER_(__VA_ARGS__)
95#define MIMICPP_DETAIL_STRIP_PARENS_OUTER_(...) MIMICPP_DETAIL_STRIP_PARENS_STRIPPED_##__VA_ARGS__
101#define MIMICPP_DETAIL_STRIP_PARENS_STRIPPED_MIMICPP_DETAIL_STRIP_PARENS_INNER
121#define MIMICPP_DETAIL_PARENS ()
127#define MIMICPP_DETAIL_COMMA_DELIMITER() ,
133#define MIMICPP_DETAIL_NO_DELIMITER()
139#define MIMICPP_DETAIL_IDENTITY(...) __VA_ARGS__
145#define MIMICPP_DETAIL_EXPAND(...) MIMICPP_DETAIL_EXPAND3(MIMICPP_DETAIL_EXPAND3(MIMICPP_DETAIL_EXPAND3(MIMICPP_DETAIL_EXPAND3(__VA_ARGS__))))
151#define MIMICPP_DETAIL_EXPAND3(...) MIMICPP_DETAIL_EXPAND2(MIMICPP_DETAIL_EXPAND2(MIMICPP_DETAIL_EXPAND2(MIMICPP_DETAIL_EXPAND2(__VA_ARGS__))))
157#define MIMICPP_DETAIL_EXPAND2(...) MIMICPP_DETAIL_EXPAND1(MIMICPP_DETAIL_EXPAND1(MIMICPP_DETAIL_EXPAND1(MIMICPP_DETAIL_EXPAND1(__VA_ARGS__))))
163#define MIMICPP_DETAIL_EXPAND1(...) __VA_ARGS__
172#define MIMICPP_DETAIL_FOR_EACH_EXT_INDIRECT(macro, sequence, ...) macro(sequence, __VA_ARGS__)
189#define MIMICPP_DETAIL_FOR_EACH_EXT(macro, token, delimiter, projection_macro, bound, ...) \
190 __VA_OPT__(MIMICPP_DETAIL_EXPAND(MIMICPP_DETAIL_FOR_EACH_EXT_HELPER(macro, token, token, delimiter, projection_macro, bound, __VA_ARGS__)))
196#define MIMICPP_DETAIL_FOR_EACH_EXT_HELPER(macro, token, sequence, delimiter, projection_macro, bound, a1, ...) \
197 MIMICPP_DETAIL_FOR_EACH_EXT_INDIRECT(macro, sequence, MIMICPP_DETAIL_STRIP_PARENS(bound), projection_macro(a1)) \
198 __VA_OPT__(delimiter() MIMICPP_FOR_EACH_EXT_AGAIN MIMICPP_DETAIL_PARENS(macro, token, sequence##token, delimiter, projection_macro, bound, __VA_ARGS__))
204#define MIMICPP_FOR_EACH_EXT_AGAIN() MIMICPP_DETAIL_FOR_EACH_EXT_HELPER
225#define MIMICPP_DETAIL_MAKE_SIGNATURE(sequence, bound_data, ret, call_convention, param_type_list, specs, ...) \
226 MIMICPP_DETAIL_STRIP_PARENS(ret) \
227 call_convention param_type_list specs
233#define MIMICPP_DETAIL_MAKE_SIGNATURE_LIST(...) \
234 MIMICPP_DETAIL_FOR_EACH_EXT( \
235 MIMICPP_DETAIL_MAKE_SIGNATURE, \
237 MIMICPP_DETAIL_COMMA_DELIMITER, \
238 MIMICPP_DETAIL_STRIP_PARENS, \
248#define MIMICPP_DETAIL_MAKE_OVERLOADED_MOCK(mock_name, signatures) \
249 ::mimicpp::Mock<MIMICPP_DETAIL_STRIP_PARENS(signatures)> mock_name \
269#define MIMICPP_DETAIL_MAKE_PARAM(sequence, bound_data, type) MIMICPP_DETAIL_STRIP_PARENS(type) arg_##sequence
275#define MIMICPP_DETAIL_MAKE_PARAM_LIST(...) \
276 MIMICPP_DETAIL_FOR_EACH_EXT( \
277 MIMICPP_DETAIL_MAKE_PARAM, \
279 MIMICPP_DETAIL_COMMA_DELIMITER, \
280 MIMICPP_DETAIL_IDENTITY, \
314#define MIMICPP_DETAIL_FORWARD_ARG_AS_TUPLE(sequence, bound_data, param_type) \
315 [&]<typename... Type>([[maybe_unused]] const ::mimicpp::type_list<Type...>) noexcept { \
316 return ::std::forward_as_tuple( \
317 ::std::forward<Type>(arg_##sequence)...); \
318 }(::mimicpp::type_list<MIMICPP_DETAIL_STRIP_PARENS(param_type)>{})
324#define MIMICPP_DETAIL_FORWARD_ARGS_AS_TUPLE(...) \
325 MIMICPP_DETAIL_FOR_EACH_EXT( \
326 MIMICPP_DETAIL_FORWARD_ARG_AS_TUPLE, \
328 MIMICPP_DETAIL_COMMA_DELIMITER, \
329 MIMICPP_DETAIL_IDENTITY, \
353#define MIMICPP_DETAIL_MAKE_OVERLOAD_INFOS_ALL(ret, param_type_list, specs, call_convention, ...) \
356 MIMICPP_DETAIL_STRIP_PARENS(call_convention), \
358 MIMICPP_DETAIL_STRIP_PARENS(specs), \
359 (MIMICPP_DETAIL_MAKE_PARAM_LIST(MIMICPP_DETAIL_STRIP_PARENS(param_type_list))), \
360 (MIMICPP_DETAIL_FORWARD_ARGS_AS_TUPLE(MIMICPP_DETAIL_STRIP_PARENS(param_type_list))))
369#define MIMICPP_DETAIL_MAKE_OVERLOAD_INFOS_SPECS(ret, param_type_list, specs, ...) \
370 MIMICPP_DETAIL_MAKE_OVERLOAD_INFOS_ALL(ret, param_type_list, specs, )
378#define MIMICPP_DETAIL_MAKE_OVERLOAD_INFOS_BASIC(ret, param_type_list, ...) \
379 MIMICPP_DETAIL_MAKE_OVERLOAD_INFOS_ALL(ret, param_type_list, , )
386#define MIMICPP_DETAIL_SELECT_MAKE_OVERLOAD_INFOS(_1, _2, N, ...) N
395#define MIMICPP_ADD_OVERLOAD(ret, param_type_list, ...) \
396 MIMICPP_DETAIL_SELECT_MAKE_OVERLOAD_INFOS( \
398 MIMICPP_DETAIL_MAKE_OVERLOAD_INFOS_ALL, \
399 MIMICPP_DETAIL_MAKE_OVERLOAD_INFOS_SPECS, \
400 MIMICPP_DETAIL_MAKE_OVERLOAD_INFOS_BASIC)(ret, param_type_list, __VA_ARGS__, )
411namespace mimicpp::detail
413 template <
typename Signature>
414 constexpr auto indirectly_apply_mock = []<
typename... Args>(
auto& mock, Args&&... args)
421 return std::move(mock)(std::forward<Args>(args)...);
425 return mock(std::forward<Args>(args)...);
444#define MIMICPP_DETAIL_MAKE_METHOD_OVERRIDE(ignore, mock_name, fn_name, ret, call_convention, param_type_list, specs, param_list, forward_list, ...) \
445 inline MIMICPP_DETAIL_STRIP_PARENS(ret) call_convention fn_name param_list specs override \
447 using SignatureT = MIMICPP_DETAIL_STRIP_PARENS(ret) param_type_list specs; \
448 return ::std::apply( \
449 ::mimicpp::detail::indirectly_apply_mock<SignatureT>, \
451 ::std::make_tuple(::std::ref(mock_name)), \
452 ::std::tuple_cat(MIMICPP_DETAIL_STRIP_PARENS(forward_list)))); \
461#define MIMICPP_DETAIL_MAKE_METHOD_OVERRIDES(mock_name, fn_name, ...) \
462 MIMICPP_DETAIL_FOR_EACH_EXT( \
463 MIMICPP_DETAIL_MAKE_METHOD_OVERRIDE, \
465 MIMICPP_DETAIL_NO_DELIMITER, \
466 MIMICPP_DETAIL_STRIP_PARENS, \
467 (mock_name, fn_name), \
480#define MIMICPP_MOCK_OVERLOADED_METHOD(fn_name, ...) \
481 MIMICPP_DETAIL_MAKE_METHOD_OVERRIDES(fn_name##_, fn_name, __VA_ARGS__) \
482 MIMICPP_DETAIL_MAKE_OVERLOADED_MOCK( \
484 (MIMICPP_DETAIL_MAKE_SIGNATURE_LIST(__VA_ARGS__)))
496#define MIMICPP_MOCK_METHOD(fn_name, ret, param_type_list, ...) \
497 MIMICPP_MOCK_OVERLOADED_METHOD( \
499 MIMICPP_ADD_OVERLOAD(ret, param_type_list __VA_OPT__(, ) __VA_ARGS__))
501#ifndef MIMICPP_CONFIG_ONLY_PREFIXED_MACROS
507 #define MOCK_METHOD MIMICPP_MOCK_METHOD
513 #define MOCK_OVERLOADED_METHOD MIMICPP_MOCK_OVERLOADED_METHOD
519 #define ADD_OVERLOAD MIMICPP_ADD_OVERLOAD
constexpr ValueCategory signature_ref_qualification_v
Convenience constant, exposing the value member of the actual type-trait.
Definition Fwd.hpp:203
typename signature_return_type< Signature >::type signature_return_type_t
Convenience alias, exposing the type member alias of the actual type-trait.
Definition Fwd.hpp:171
Definition BoostTest.hpp:20