diff options
author | Eshan Kelkar <eshankelkar@galorithm.com> | 2023-12-23 11:07:02 +0530 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2024-01-05 07:51:51 +0100 |
commit | a5cb5c33543aa5132a73cca4d1536627eb82b154 (patch) | |
tree | da1d171f81e3afc939e65009d1ceb1ba109c85f0 | |
parent | 5740aff1a13174424d05372dc3f33f6bda30386e (diff) | |
download | cmocka-a5cb5c33543aa5132a73cca4d1536627eb82b154.zip cmocka-a5cb5c33543aa5132a73cca4d1536627eb82b154.tar.gz cmocka-a5cb5c33543aa5132a73cca4d1536627eb82b154.tar.bz2 |
Add unit tests for assert_false()
Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r-- | tests/CMakeLists.txt | 18 | ||||
-rw-r--r-- | tests/test_assert_false.c | 26 | ||||
-rw-r--r-- | tests/test_assert_false_fail.c | 26 |
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); +} |