1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #9137 from cladmi/pr/tests/unittests/cli_foreach_empty_list

tests/unittests: add empty list clist_foreach case
This commit is contained in:
Alexandre Abadie 2018-05-15 17:17:13 +02:00 committed by GitHub
commit d6c63592bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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