cmocka: Implement expect_int_in_set_count()

This commit is contained in:
Andreas Schneider 2024-01-06 14:11:33 +01:00
parent 241c933413
commit 59b61c72b1
2 changed files with 37 additions and 16 deletions

View File

@ -879,6 +879,27 @@ void expect_in_set(#function, #parameter, uintmax_t value_array[]);
expect_in_set_count(function, parameter, value_array, 1)
#endif
#ifdef DOXYGEN
/**
* @brief Add an event to check if the parameter value is part of the provided
* integer array.
*
* The event is triggered by calling check_expected() in the mocked function.
*
* @param[in] #function The function to add the check for.
*
* @param[in] #parameter The name of the parameter passed to the function.
*
* @param[in] value_array[] The array to check for the value.
*
* @see check_expected().
*/
void expect_in_set(#function, #parameter, intmax_t value_array[]);
#else
#define expect_int_in_set(function, parameter, value_array) \
expect_int_in_set_count(function, parameter, value_array, 1)
#endif
#ifdef DOXYGEN
/**
* @brief Add an event to check if the parameter value is part of the provided

View File

@ -1734,14 +1734,14 @@ static void expect_set(
check_data, &check_integer_set->event, count);
}
static void expect_int_in_set(const char *const function,
const char *const parameter,
const char *const file,
const size_t line,
const intmax_t values[],
const size_t number_of_values,
const CheckParameterValue check_function,
const size_t count)
static void __expect_int_in_set(const char *const function,
const char *const parameter,
const char *const file,
const size_t line,
const intmax_t values[],
const size_t number_of_values,
const CheckParameterValue check_function,
const size_t count)
{
struct check_integer_set *const check_integer_set =
calloc(number_of_values,
@ -1786,14 +1786,14 @@ void _expect_int_in_set(const char *const function,
const size_t number_of_values,
const size_t count)
{
expect_int_in_set(function,
parameter,
file,
line,
values,
number_of_values,
check_int_in_set,
count);
__expect_int_in_set(function,
parameter,
file,
line,
values,
number_of_values,
check_int_in_set,
count);
}
/* Add an event to check whether a value isn't in a set. */