|
mimic++ v9.2.1
|
Contains utility to simplify the process of generating forwarding facade functions. More...
Topics | |
| detail | |
| Contains several macros, used for facade implementation. | |
| interfaces | |
| [Deprecated] Utilities to simplify interface mocking. | |
Macros | |
| #define | MIMICPP_ADD_OVERLOAD(ret, param_type_list, ...) |
| Adds an overload to the currently built facade. | |
| #define | ADD_OVERLOAD MIMICPP_ADD_OVERLOAD |
| Shorthand variant of MIMICPP_ADD_OVERLOAD. | |
| #define | MIMICPP_MAKE_OVERLOADED_FACADE_EXT(traits, target_name, fn_name, linkage, ...) |
| The most powerful entry point for creating a facade overload-set. | |
| #define | MAKE_OVERLOADED_FACADE_EXT MIMICPP_MAKE_OVERLOADED_FACADE_EXT |
| Shorthand variant of MIMICPP_MAKE_OVERLOADED_FACADE_EXT. | |
| #define | MIMICPP_MAKE_FACADE_EXT(traits, target_name, fn_name, linkage, ret, param_type_list, ...) |
| The most powerful entry point for creating a single facade function. | |
| #define | MAKE_FACADE_EXT MIMICPP_MAKE_FACADE_EXT |
| Shorthand variant of MIMICPP_MAKE_FACADE_EXT. | |
| #define | MIMICPP_MAKE_OVERLOADED_MEMBER_MOCK(fn_name, ...) |
| Entry point for mocking a member method overload-set. | |
| #define | MAKE_OVERLOADED_MEMBER_MOCK MIMICPP_MAKE_OVERLOADED_MEMBER_MOCK |
| Shorthand variant of MIMICPP_MAKE_OVERLOADED_MEMBER_MOCK. | |
| #define | MIMICPP_MAKE_MEMBER_MOCK(fn_name, ret, param_type_list, ...) |
| Entry point for mocking a single member method. | |
| #define | MAKE_MEMBER_MOCK MIMICPP_MAKE_MEMBER_MOCK |
| Shorthand variant of MIMICPP_MAKE_MEMBER_MOCK. | |
| #define | MIMICPP_MAKE_OVERLOADED_MEMBER_MOCK_WITH_THIS(fn_name, ...) |
Entry point for mocking a member method overload-set with an explicit this pointer. | |
| #define | MAKE_OVERLOADED_MEMBER_MOCK_WITH_THIS MIMICPP_MAKE_OVERLOADED_MEMBER_MOCK_WITH_THIS |
| Shorthand variant of MIMICPP_MAKE_OVERLOADED_MEMBER_MOCK_WITH_THIS. | |
| #define | MIMICPP_MAKE_MEMBER_MOCK_WITH_THIS(fn_name, ret, param_type_list, ...) |
| Entry point for mocking a single member method with an explicit this pointer. | |
| #define | MAKE_MEMBER_MOCK_WITH_THIS MIMICPP_MAKE_MEMBER_MOCK_WITH_THIS |
| Shorthand variant of MIMICPP_MAKE_MEMBER_MOCK_WITH_THIS. | |
Contains utility to simplify the process of generating forwarding facade functions.
While this library tries avoiding macros when possible, sometimes we must not be too stubborn. Making interface mocking more enjoyable is such a situation. While this can, of course, be done without macros, this quickly becomes annoying, due to the necessary boilerplate code.
mimic++ therefore introduces several macros, which helps to reduce the effort to a minimum. With them, the boilerplate can be reduced to this macro invocation, which effectively does the same as before:
The good news is that these macros are just a thin layer around the macro-free core and can thus be easily avoided. Nevertheless, mimic++ still aims to become as macro-less as possible. As soon as reflection becomes available, an attempt will be made to solve this feature completely in the C++ language (hopefully with c++26, but only time will tell).
This use-case is fully supported, without any special tricks.
Due to the nature of the mimicpp::Mock design, it directly supports packs without any question.
The interesting part is: Do the facade macros also support variadic templates?
Yes they do! Both handle packs correctly.
They can then be used with arbitrary template arguments.
| #define ADD_OVERLOAD MIMICPP_ADD_OVERLOAD |
Shorthand variant of MIMICPP_ADD_OVERLOAD.
Adds an overload to the currently built facade.
| ret | The return type. |
| param_type_list | The parameter types. |
| ... | Two optional arguments can be supplied, where
|
| #define MAKE_FACADE_EXT MIMICPP_MAKE_FACADE_EXT |
Shorthand variant of MIMICPP_MAKE_FACADE_EXT.
The most powerful entry point for creating a single facade function.
| traits | The facade-traits. |
| target_name | The name of the underlying target object. |
| fn_name | The name of the facade function. |
| linkage | The linkage for the facade function and the target object. |
| ... | Two optional arguments can be supplied, where
|
This macro defines a single target object for one method signature and generates a corresponding facade function. The facade function forwards its calls to the underlying target object.
| #define MAKE_MEMBER_MOCK MIMICPP_MAKE_MEMBER_MOCK |
Shorthand variant of MIMICPP_MAKE_MEMBER_MOCK.
Entry point for mocking a single member method.
| fn_name | The method name. |
| param_type_list | The list of parameter types. |
| ... | Two optional arguments can be supplied, where
|
This macro defines a single mock member-object for one method signature and generates a corresponding facade member function. The facade member function forwards its calls to the underlying mock object-member.
The mock member-object name is the content of fn_name suffixed by an additional _.
| #define MAKE_MEMBER_MOCK_WITH_THIS MIMICPP_MAKE_MEMBER_MOCK_WITH_THIS |
Shorthand variant of MIMICPP_MAKE_MEMBER_MOCK_WITH_THIS.
Entry point for mocking a single member method with an explicit this pointer.
| fn_name | The method name. |
| param_type_list | The list of parameter types. |
| ... | Two optional arguments can be supplied, where
|
This macro defines a single mock member-object for one method signature and generates a corresponding facade member function. The facade member function forwards its calls to the underlying mock object-member and prepends an explicit this pointer to the argument list.
The mock member-object name is the content of fn_name suffixed by an additional _.
self_type alias to be defined in the class where the mock is declared. If self_type does not match the actual containing type, the behavior is undefined.| #define MAKE_OVERLOADED_FACADE_EXT MIMICPP_MAKE_OVERLOADED_FACADE_EXT |
Shorthand variant of MIMICPP_MAKE_OVERLOADED_FACADE_EXT.
The most powerful entry point for creating a facade overload-set.
| traits | The facade-traits. |
| target_name | The name of the underlying target object. |
| fn_name | The name of the facade overload-set. |
| linkage | The linkage for the facade functions and the target object. |
| ... | Overloads must be declared using the MIMICPP_ADD_OVERLOAD macro. |
This macro defines a single target object that supports an arbitrary number of overloads. Each overload is implemented as its own facade function, forwarding calls to the underlying target object.
| #define MAKE_OVERLOADED_MEMBER_MOCK MIMICPP_MAKE_OVERLOADED_MEMBER_MOCK |
Shorthand variant of MIMICPP_MAKE_OVERLOADED_MEMBER_MOCK.
Entry point for mocking a member method overload-set.
| fn_name | The name of the overload-set. |
| ... | Overloads must be declared using the MIMICPP_ADD_OVERLOAD macro. |
This macro defines a single member mock object that supports an arbitrary number of member function overloads. Each overload is implemented as its own facade member function, forwarding calls to the underlying mock member-object.
The mock member-object name is the content of fn_name suffixed by an additional _.
| #define MAKE_OVERLOADED_MEMBER_MOCK_WITH_THIS MIMICPP_MAKE_OVERLOADED_MEMBER_MOCK_WITH_THIS |
Shorthand variant of MIMICPP_MAKE_OVERLOADED_MEMBER_MOCK_WITH_THIS.
Entry point for mocking a member method overload-set with an explicit this pointer.
| fn_name | The name of the overload-set. |
| ... | Overloads must be declared using the MIMICPP_ADD_OVERLOAD macro. |
This macro defines a single member mock object that supports an arbitrary number of member function overloads. Each overload is implemented as its own facade member function, forwarding calls to the underlying mock member-object while prepending an explicit this pointer to the argument list.
The mock member-object name is the content of fn_name suffixed by an additional _.
self_type alias to be defined in the class where the mock is declared. If self_type does not match the actual containing type, the behavior is undefined.| #define MIMICPP_ADD_OVERLOAD | ( | ret, | |
| param_type_list, | |||
| ... ) |
Adds an overload to the currently built facade.
| ret | The return type. |
| param_type_list | The parameter types. |
| ... | Two optional arguments can be supplied, where
|
| #define MIMICPP_MAKE_FACADE_EXT | ( | traits, | |
| target_name, | |||
| fn_name, | |||
| linkage, | |||
| ret, | |||
| param_type_list, | |||
| ... ) |
The most powerful entry point for creating a single facade function.
| traits | The facade-traits. |
| target_name | The name of the underlying target object. |
| fn_name | The name of the facade function. |
| linkage | The linkage for the facade function and the target object. |
| ... | Two optional arguments can be supplied, where
|
This macro defines a single target object for one method signature and generates a corresponding facade function. The facade function forwards its calls to the underlying target object.
| #define MIMICPP_MAKE_MEMBER_MOCK | ( | fn_name, | |
| ret, | |||
| param_type_list, | |||
| ... ) |
Entry point for mocking a single member method.
| fn_name | The method name. |
| param_type_list | The list of parameter types. |
| ... | Two optional arguments can be supplied, where
|
This macro defines a single mock member-object for one method signature and generates a corresponding facade member function. The facade member function forwards its calls to the underlying mock object-member.
The mock member-object name is the content of fn_name suffixed by an additional _.
| #define MIMICPP_MAKE_MEMBER_MOCK_WITH_THIS | ( | fn_name, | |
| ret, | |||
| param_type_list, | |||
| ... ) |
Entry point for mocking a single member method with an explicit this pointer.
| fn_name | The method name. |
| param_type_list | The list of parameter types. |
| ... | Two optional arguments can be supplied, where
|
This macro defines a single mock member-object for one method signature and generates a corresponding facade member function. The facade member function forwards its calls to the underlying mock object-member and prepends an explicit this pointer to the argument list.
The mock member-object name is the content of fn_name suffixed by an additional _.
self_type alias to be defined in the class where the mock is declared. If self_type does not match the actual containing type, the behavior is undefined.| #define MIMICPP_MAKE_OVERLOADED_FACADE_EXT | ( | traits, | |
| target_name, | |||
| fn_name, | |||
| linkage, | |||
| ... ) |
The most powerful entry point for creating a facade overload-set.
| traits | The facade-traits. |
| target_name | The name of the underlying target object. |
| fn_name | The name of the facade overload-set. |
| linkage | The linkage for the facade functions and the target object. |
| ... | Overloads must be declared using the MIMICPP_ADD_OVERLOAD macro. |
This macro defines a single target object that supports an arbitrary number of overloads. Each overload is implemented as its own facade function, forwarding calls to the underlying target object.
| #define MIMICPP_MAKE_OVERLOADED_MEMBER_MOCK | ( | fn_name, | |
| ... ) |
Entry point for mocking a member method overload-set.
| fn_name | The name of the overload-set. |
| ... | Overloads must be declared using the MIMICPP_ADD_OVERLOAD macro. |
This macro defines a single member mock object that supports an arbitrary number of member function overloads. Each overload is implemented as its own facade member function, forwarding calls to the underlying mock member-object.
The mock member-object name is the content of fn_name suffixed by an additional _.
| #define MIMICPP_MAKE_OVERLOADED_MEMBER_MOCK_WITH_THIS | ( | fn_name, | |
| ... ) |
Entry point for mocking a member method overload-set with an explicit this pointer.
| fn_name | The name of the overload-set. |
| ... | Overloads must be declared using the MIMICPP_ADD_OVERLOAD macro. |
This macro defines a single member mock object that supports an arbitrary number of member function overloads. Each overload is implemented as its own facade member function, forwarding calls to the underlying mock member-object while prepending an explicit this pointer to the argument list.
The mock member-object name is the content of fn_name suffixed by an additional _.
self_type alias to be defined in the class where the mock is declared. If self_type does not match the actual containing type, the behavior is undefined.