From d55869a5e52eadbb39e6980b107711b221543985 Mon Sep 17 00:00:00 2001 From: Snaipe Date: Fri, 27 Nov 2015 13:43:59 +0100 Subject: [PATCH] Moved criterion_test_params to internal API --- include/criterion/internal/parameterized.h | 42 ++++++++++++++++++++++ include/criterion/types.h | 42 +--------------------- src/core/runner_coroutine.c | 1 + 3 files changed, 44 insertions(+), 41 deletions(-) diff --git a/include/criterion/internal/parameterized.h b/include/criterion/internal/parameterized.h index c254531..4fbd511 100644 --- a/include/criterion/internal/parameterized.h +++ b/include/criterion/internal/parameterized.h @@ -27,6 +27,48 @@ # include "test.h" # include "../types.h" +struct criterion_test_params { + size_t size; + void *params; + size_t length; + void (*cleanup)(struct criterion_test_params *); + +# ifdef __cplusplus + constexpr criterion_test_params(size_t size, void *params, size_t length) + : size(size) + , params(params) + , length(length) + , cleanup(nullptr) + {} + + constexpr criterion_test_params(size_t size, void *params, size_t length, + void (*cleanup)(struct criterion_test_params *)) + : size(size) + , params(params) + , length(length) + , cleanup(cleanup) + {} + + template + constexpr criterion_test_params(std::vector>& vec, + void (*cleanup)(criterion_test_params *) = nullptr) + : size(sizeof (T)) + , params(&vec[0]) + , length(vec.size()) + , cleanup(cleanup) + {} + + template + constexpr criterion_test_params(T (&arr)[N], + void (*cleanup)(criterion_test_params *) = nullptr) + : size(sizeof (arr[0])) + , params(static_cast(&arr)) + , length(N) + , cleanup(cleanup) + {} +# endif +}; + # ifdef __cplusplus # define CR_PARAM_TEST_PROTOTYPE_(Param, Category, Name) \ extern "C" void CR_IDENTIFIER_(Category, Name, impl)(Param) diff --git a/include/criterion/types.h b/include/criterion/types.h index 905b6ac..5c9cc33 100644 --- a/include/criterion/types.h +++ b/include/criterion/types.h @@ -51,47 +51,7 @@ enum criterion_test_kind { CR_TEST_PARAMETERIZED, }; -struct criterion_test_params { - size_t size; - void *params; - size_t length; - void (*cleanup)(struct criterion_test_params *); - -# ifdef __cplusplus - constexpr criterion_test_params(size_t size, void *params, size_t length) - : size(size) - , params(params) - , length(length) - , cleanup(nullptr) - {} - - constexpr criterion_test_params(size_t size, void *params, size_t length, - void (*cleanup)(struct criterion_test_params *)) - : size(size) - , params(params) - , length(length) - , cleanup(cleanup) - {} - - template - constexpr criterion_test_params(std::vector>& vec, - void (*cleanup)(criterion_test_params *) = nullptr) - : size(sizeof (T)) - , params(&vec[0]) - , length(vec.size()) - , cleanup(cleanup) - {} - - template - constexpr criterion_test_params(T (&arr)[N], - void (*cleanup)(criterion_test_params *) = nullptr) - : size(sizeof (arr[0])) - , params(static_cast(&arr)) - , length(N) - , cleanup(cleanup) - {} -# endif -}; +struct criterion_test_params; struct criterion_test_extra_data { int sentinel_; diff --git a/src/core/runner_coroutine.c b/src/core/runner_coroutine.c index 50f336c..57a091a 100644 --- a/src/core/runner_coroutine.c +++ b/src/core/runner_coroutine.c @@ -25,6 +25,7 @@ #include #include #include "criterion/logging.h" +#include "criterion/internal/parameterized.h" #include "runner_coroutine.h" #include "worker.h" #include "stats.h"