Add unit tests for assert_false()
Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
parent
5740aff1a1
commit
a5cb5c3354
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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);
|
||||
}
|
Loading…
Reference in New Issue