Add unit tests for assert_true()
Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
parent
ad567f8d85
commit
5740aff1a1
|
@ -26,6 +26,8 @@ set(CMOCKA_TESTS
|
|||
test_groups
|
||||
test_float_macros
|
||||
test_double_macros
|
||||
test_assert_true
|
||||
test_assert_true_fail
|
||||
test_assert_macros
|
||||
test_assert_macros_fail
|
||||
test_assert_ptr
|
||||
|
@ -76,6 +78,22 @@ set_tests_properties(
|
|||
"\\[ SKIPPED \\] test_check_skip"
|
||||
)
|
||||
|
||||
# test_assert_true
|
||||
set_tests_properties(
|
||||
test_assert_true
|
||||
PROPERTIES
|
||||
PASS_REGULAR_EXPRESSION
|
||||
"\\[ PASSED \\] 1 test\\(s\\)."
|
||||
)
|
||||
|
||||
# test_assert_true_fail
|
||||
set_tests_properties(
|
||||
test_assert_true_fail
|
||||
PROPERTIES
|
||||
PASS_REGULAR_EXPRESSION
|
||||
"x != 10 is not true"
|
||||
)
|
||||
|
||||
# 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_true(void **state)
|
||||
{
|
||||
int x = 10;
|
||||
|
||||
(void)state; /* unused */
|
||||
assert_true(x == 10);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
const struct CMUnitTest tests[] = {
|
||||
cmocka_unit_test(test_assert_true),
|
||||
};
|
||||
|
||||
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_true_fail(void **state)
|
||||
{
|
||||
int x = 10;
|
||||
|
||||
(void)state; /* unused */
|
||||
assert_true(x != 10);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
const struct CMUnitTest tests[] = {
|
||||
cmocka_unit_test(test_assert_true_fail),
|
||||
};
|
||||
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||
}
|
Loading…
Reference in New Issue