summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/CMakeLists.txt18
-rw-r--r--tests/test_assert_false.c26
-rw-r--r--tests/test_assert_false_fail.c26
3 files changed, 70 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 188b4ea..e491f6d 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -28,6 +28,8 @@ set(CMOCKA_TESTS
test_double_macros
test_assert_true
test_assert_true_fail
+ test_assert_false
+ test_assert_false_fail
test_assert_macros
test_assert_macros_fail
test_assert_ptr
@@ -94,6 +96,22 @@ set_tests_properties(
"x != 10 is not true"
)
+# test_assert_false
+set_tests_properties(
+ test_assert_false
+ PROPERTIES
+ PASS_REGULAR_EXPRESSION
+ "\\[ PASSED \\] 1 test\\(s\\)."
+)
+
+# test_assert_false_fail
+set_tests_properties(
+ test_assert_false_fail
+ PROPERTIES
+ PASS_REGULAR_EXPRESSION
+ "x == 10 is not false"
+)
+
# test_assert_macros_fail
set_tests_properties(
test_assert_macros_fail
diff --git a/tests/test_assert_false.c b/tests/test_assert_false.c
new file mode 100644
index 0000000..db57e7a
--- /dev/null
+++ b/tests/test_assert_false.c
@@ -0,0 +1,26 @@
+#include "config.h"
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+#include <stdint.h>
+
+#include <cmocka.h>
+#include <cmocka_private.h>
+
+static void test_assert_false(void **state)
+{
+ int x = 10;
+
+ (void)state; /* unused */
+ assert_false(x != 10);
+}
+
+int main(void)
+{
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test(test_assert_false),
+ };
+
+ return cmocka_run_group_tests(tests, NULL, NULL);
+}
diff --git a/tests/test_assert_false_fail.c b/tests/test_assert_false_fail.c
new file mode 100644
index 0000000..863bd5d
--- /dev/null
+++ b/tests/test_assert_false_fail.c
@@ -0,0 +1,26 @@
+#include "config.h"
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+#include <stdint.h>
+
+#include <cmocka.h>
+#include <cmocka_private.h>
+
+static void test_assert_false_fail(void **state)
+{
+ int x = 10;
+
+ (void)state; /* unused */
+ assert_false(x == 10);
+}
+
+int main(void)
+{
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test(test_assert_false_fail),
+ };
+
+ return cmocka_run_group_tests(tests, NULL, NULL);
+}