mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-25 06:23:53 +01:00
tests/unittests: add empty list clist_foreach case
Add clist_foreach empty list test case which should: * not call `func` * return `NULL`
This commit is contained in:
parent
56c2b6a0e3
commit
64bc06f2b6
@ -237,13 +237,19 @@ static int _foreach_test_trampoline(clist_node_t *node, void *arg)
|
||||
|
||||
static void test_clist_foreach(void)
|
||||
{
|
||||
void *res;
|
||||
list_node_t *list = &test_clist;
|
||||
|
||||
_foreach_called = 0;
|
||||
res = clist_foreach(list, _foreach_test_trampoline, NULL);
|
||||
TEST_ASSERT(_foreach_called == 0);
|
||||
TEST_ASSERT(res == NULL);
|
||||
|
||||
for (int i = 0; i < TEST_CLIST_LEN; i++) {
|
||||
clist_rpush(list, &tests_clist_buf[i]);
|
||||
}
|
||||
|
||||
void *res = clist_foreach(list, _foreach_test_trampoline, NULL);
|
||||
res = clist_foreach(list, _foreach_test_trampoline, NULL);
|
||||
|
||||
TEST_ASSERT(_foreach_called == _foreach_abort_after);
|
||||
TEST_ASSERT(res == &tests_clist_buf[_foreach_abort_after-1]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user