summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2024-01-06 13:59:23 +0100
committerAndreas Schneider <asn@cryptomilk.org>2024-02-02 11:21:34 +0100
commit241c9334135d9e79b601909b8f0f7e0f379fb468 (patch)
tree9f151a3bc9fd77478a85354be5e0ea43e5ea4ced
parentc999637585c9113c6c32966338c71dd5ec065774 (diff)
downloadcmocka-241c9334135d9e79b601909b8f0f7e0f379fb468.zip
cmocka-241c9334135d9e79b601909b8f0f7e0f379fb468.tar.gz
cmocka-241c9334135d9e79b601909b8f0f7e0f379fb468.tar.bz2
tests: Add test for expect_int_in_set_count()
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/test_expect_u_int_in_set.c33
2 files changed, 34 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index e491f6d..2807116 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -18,6 +18,7 @@ endif()
set(CMOCKA_TESTS
test_alloc
test_expect_check
+ test_expect_u_int_in_set
test_expect_check_fail
test_group_setup_assert
test_group_setup_fail
diff --git a/tests/test_expect_u_int_in_set.c b/tests/test_expect_u_int_in_set.c
new file mode 100644
index 0000000..7e095a1
--- /dev/null
+++ b/tests/test_expect_u_int_in_set.c
@@ -0,0 +1,33 @@
+#include "config.h"
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+#include <stdint.h>
+#include <cmocka.h>
+#include <cmocka_private.h>
+#include <stdio.h>
+#include <string.h>
+
+
+static void mock_test_int(intmax_t value)
+{
+ check_expected(value);
+}
+
+static void test_expect_int_in_set_count(void **state)
+{
+ intmax_t set[] = { -1, 0, 1 };
+ (void)state; /* unused */
+
+ expect_int_in_set_count(mock_test_int, value, set, 1);
+
+ mock_test_int(-1);
+}
+
+int main(void) {
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test(test_expect_int_in_set_count)};
+
+ return cmocka_run_group_tests(tests, NULL, NULL);
+}