mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-06 07:00:59 +00:00
test/linked_list: add tests
This commit is contained in:
parent
1f56122ce4
commit
8616781357
@ -175,9 +175,7 @@ btstack_linked_item_t * btstack_linked_list_iterator_next(btstack_linked_list_it
|
||||
}
|
||||
|
||||
void btstack_linked_list_iterator_remove(btstack_linked_list_iterator_t * it){
|
||||
if (it->prev->next != it->curr){
|
||||
log_error("prev item %p does not point to curr %p", it->prev, it->curr);
|
||||
}
|
||||
btstack_assert(it->prev->next == it->curr);
|
||||
it->curr = it->curr->next;
|
||||
it->prev->next = it->curr;
|
||||
it->advance_on_next = 0;
|
||||
|
@ -18,6 +18,18 @@ TEST(LinkedListEmpty, CountAll){
|
||||
CHECK_EQUAL(0, btstack_linked_list_count(&testList));
|
||||
}
|
||||
|
||||
TEST(LinkedListEmpty, IsEmpty){
|
||||
CHECK_EQUAL(true, btstack_linked_list_empty(&testList));
|
||||
}
|
||||
|
||||
TEST(LinkedListEmpty, Addtail){
|
||||
CHECK_EQUAL(true, btstack_linked_list_add_tail(&testList, &itemA));
|
||||
}
|
||||
|
||||
TEST(LinkedListEmpty, RemoveNonExisting){
|
||||
CHECK_EQUAL(false, btstack_linked_list_remove(&testList, &itemA));
|
||||
}
|
||||
|
||||
TEST_GROUP(LinkedList){
|
||||
void setup(void){
|
||||
testList = NULL;
|
||||
@ -38,6 +50,12 @@ TEST(LinkedList, GetFirst){
|
||||
CHECK_EQUAL(item, &itemA);
|
||||
}
|
||||
|
||||
TEST(LinkedList, GetLast){
|
||||
btstack_linked_item_t * item;
|
||||
item = btstack_linked_list_get_last_item(&testList);
|
||||
CHECK_EQUAL(item, &itemD);
|
||||
}
|
||||
|
||||
TEST(LinkedList, Pop){
|
||||
btstack_linked_item_t * item;
|
||||
item = btstack_linked_list_pop(&testList);
|
||||
@ -45,6 +63,14 @@ TEST(LinkedList, Pop){
|
||||
CHECK_EQUAL(3, btstack_linked_list_count(&testList));
|
||||
}
|
||||
|
||||
TEST(LinkedList, AddExisting){
|
||||
CHECK_EQUAL( false, btstack_linked_list_add(&testList, &itemD));
|
||||
}
|
||||
|
||||
TEST(LinkedList, AddTailExisting){
|
||||
CHECK_EQUAL( false, btstack_linked_list_add_tail(&testList, &itemD));
|
||||
}
|
||||
|
||||
TEST(LinkedList, Iterator){
|
||||
btstack_linked_list_iterator_t it;
|
||||
btstack_linked_list_iterator_init(&it, &testList);
|
||||
|
Loading…
Reference in New Issue
Block a user