Replace Boost PP_Iterate by C++11 variadic templates

This allows support for any number of arguments and makes setting MOCK_MAX_ARGS unnecessary.
It also allows for easier debugging due to being able to step into actual code instead of preprocessor generated stuff
This commit is contained in:
Alexander Grund 2022-01-31 19:27:57 +01:00
parent 90d9ac8055
commit fca30e7780
No known key found for this signature in database
GPG key ID: AA48A0760367A42B
17 changed files with 368 additions and 472 deletions

View file

@ -15,6 +15,7 @@ Released -
* Removed MOCK_*_TPL as they are no longer required, use the non _TPL variant even for templates
* Added MOCK_PROTECT_SIGNATURE to pass function signatures with commas in the return type
* Remove support for protecting function signatures via BOOST_IDENTITY_TYPE, use MOCK_PROTECT_SIGNATURE instead
* Add support for unlimitted number of arguments making MOCK_MAX_ARGS superflous
[endsect]

View file

@ -110,24 +110,6 @@ For more information about the serialization operator and the use of mock::forma
[endsect]
[section Number of arguments]
The maximum number of arguments a mocked method can have is defined by MOCK_MAX_ARGS.
By default this value is set to 9, but if needed it can be changed before including the library :
[max_args]
This means methods with up to 20 arguments will then be accepted.
The mock object library uses several boost libraries and will adjust some of their constants if they haven't already been defined :
* Boost.Function with BOOST_FUNCTION_MAX_ARGS required at MOCK_MAX_ARGS or higher
* Boost.FunctionTypes with BOOST_FT_MAX_ARITY required at MOCK_MAX_ARGS + 1 or higher
A compilation error will happen if one of those constants is already defined too low.
[endsect]
[section Test framework integration]
By default the library expects to be used in conjunction with Boost.Test e.g. :

View file

@ -145,12 +145,6 @@ BOOST_AUTO_TEST_CASE(near_constraint_works_with_with_float_wrapper_and_cref)
}
} // namespace near_constraint_cref_test
#undef MOCK_MAX_ARGS
//[ max_args
#define MOCK_MAX_ARGS 20
#include <turtle/mock.hpp>
//]
#if defined(__GNUC__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wunused-parameter"