diff --git a/src/btstack_linked_list.c b/src/btstack_linked_list.c index 33a1fab93..6c1d7c9d3 100644 --- a/src/btstack_linked_list.c +++ b/src/btstack_linked_list.c @@ -118,7 +118,7 @@ int btstack_linked_list_remove(btstack_linked_list_t * list, btstack_linked_ite int btstack_linked_list_count(btstack_linked_list_t * list){ btstack_linked_item_t *it; int counter = 0; - for (it = (btstack_linked_item_t *) list; it ; it = it->next) { + for (it = (btstack_linked_item_t *) list; it->next ; it = it->next) { counter++; } return counter; diff --git a/test/linked_list/btstack_linked_list_test.c b/test/linked_list/btstack_linked_list_test.c index ffd6aa237..f8a27f3d5 100644 --- a/test/linked_list/btstack_linked_list_test.c +++ b/test/linked_list/btstack_linked_list_test.c @@ -8,6 +8,16 @@ btstack_linked_item_t itemB; btstack_linked_item_t itemC; btstack_linked_item_t itemD; +TEST_GROUP(LinkedListEmpty){ + void setup(void){ + testList = NULL; + } +}; + +TEST(LinkedListEmpty, CountAll){ + CHECK_EQUAL(0, btstack_linked_list_count(&testList)); +} + TEST_GROUP(LinkedList){ void setup(void){ testList = NULL; @@ -18,6 +28,10 @@ TEST_GROUP(LinkedList){ } }; +TEST(LinkedList, CountAll){ + CHECK_EQUAL(4, btstack_linked_list_count(&testList)); +} + TEST(LinkedList, Iterator){ btstack_linked_list_iterator_t it; btstack_linked_list_iterator_init(&it, &testList);