summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2024-01-06 14:11:33 +0100
committerAndreas Schneider <asn@cryptomilk.org>2024-02-02 11:21:34 +0100
commit59b61c72b1f7d976064b4ffba572051ef0a324e9 (patch)
tree92493ab8d57474fc756ca061f1e97a812567463e
parent241c9334135d9e79b601909b8f0f7e0f379fb468 (diff)
downloadcmocka-59b61c72b1f7d976064b4ffba572051ef0a324e9.zip
cmocka-59b61c72b1f7d976064b4ffba572051ef0a324e9.tar.gz
cmocka-59b61c72b1f7d976064b4ffba572051ef0a324e9.tar.bz2
cmocka: Implement expect_int_in_set_count()
-rw-r--r--include/cmocka.h21
-rw-r--r--src/cmocka.c32
2 files changed, 37 insertions, 16 deletions
diff --git a/include/cmocka.h b/include/cmocka.h
index 8c9c39a..cfd5226 100644
--- a/include/cmocka.h
+++ b/include/cmocka.h
@@ -882,6 +882,27 @@ void expect_in_set(#function, #parameter, uintmax_t value_array[]);
#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
* array.
*
* The event is triggered by calling check_expected() in the mocked function.
diff --git a/src/cmocka.c b/src/cmocka.c
index b603417..f7c2d24 100644
--- a/src/cmocka.c
+++ b/src/cmocka.c
@@ -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. */