tests: Add tests for assert_int_in_range()

This commit is contained in:
Andreas Schneider 2022-05-18 08:16:13 +02:00
parent 237d748050
commit e68a2333a3
3 changed files with 27 additions and 0 deletions

View File

@ -7,6 +7,7 @@ EXPORTS
_assert_in_range
_assert_in_set
_assert_int_equal
_assert_int_in_range
_assert_int_not_equal
_assert_memory_equal
_assert_memory_not_equal

View File

@ -27,6 +27,7 @@ set(CMOCKA_TESTS
test_assert_macros_fail
test_assert_u_int
test_assert_u_int_fail
test_assert_range
test_basics
test_skip
test_stop

25
tests/test_assert_range.c Normal file
View File

@ -0,0 +1,25 @@
#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_int_in_range(void **state)
{
(void)state; /* unused */
assert_int_in_range(0, 0, 1);
assert_int_in_range(1, 0, 1);
assert_int_in_range(0, -1, 1);
assert_int_in_range(0, INTMAX_MIN, INTMAX_MAX);
}
int main(void) {
const struct CMUnitTest range_tests[] = {
cmocka_unit_test(test_assert_int_in_range),
};
return cmocka_run_group_tests(range_tests, NULL, NULL);
}