1
0
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:
Gaëtan Harter 2018-05-15 15:26:45 +02:00
parent 56c2b6a0e3
commit 64bc06f2b6
No known key found for this signature in database
GPG Key ID: 76DF6BCF1B1F883B

View File

@ -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]);