|
|
@@ -234,26 +234,28 @@ TEST(DoublyLinkedList, RemoveFirstElementInList) {
|
|
|
DoublyLinkedListDestroy(&list);
|
|
|
}
|
|
|
|
|
|
-TEST(DoublyLinkedList, RemoveMiddleElement) {
|
|
|
+TEST(DoublyLinkedList, RemoveFirstElementInOtherwiseEmptyList) {
|
|
|
int test_data_1 = 2;
|
|
|
- int test_data_2 = 4;
|
|
|
- int test_data_3 = 8;
|
|
|
DoublyLinkedList list;
|
|
|
DoublyLinkedListInitialize(&list, CallocAllocator, CallocDeallocator);
|
|
|
DoublyLinkedListInsertAtTail(&list, &test_data_1);
|
|
|
- DoublyLinkedListInsertAtTail(&list, &test_data_2);
|
|
|
- DoublyLinkedListInsertAtTail(&list, &test_data_3);
|
|
|
- DoublyLinkedListNode *node_to_be_deleted = list.first->next;
|
|
|
+ DoublyLinkedListNode *node_to_be_deleted = list.first;
|
|
|
DoublyLinkedListRemoveNode(&list, &node_to_be_deleted);
|
|
|
- CHECK_EQUAL(4, test_data_2);
|
|
|
- CHECK_EQUAL(8, *( (int *)list.first->next->data ) );
|
|
|
+ CHECK_EQUAL(2, test_data_1);
|
|
|
+ POINTERS_EQUAL(NULL, list.first);
|
|
|
+ POINTERS_EQUAL(NULL, list.last);
|
|
|
DoublyLinkedListDestroy(&list);
|
|
|
}
|
|
|
|
|
|
-TEST(DoublyLinkedList, RemoveFirstElementInOtherwiseEmptyList) {
|
|
|
- FAIL("Not implemented!");
|
|
|
-}
|
|
|
-
|
|
|
TEST(DoublyLinkedList, RemoveLastElementInOtherwiseEmptyList) {
|
|
|
- FAIL("Not implemented!");
|
|
|
+ int test_data_1 = 2;
|
|
|
+ DoublyLinkedList list;
|
|
|
+ DoublyLinkedListInitialize(&list, CallocAllocator, CallocDeallocator);
|
|
|
+ DoublyLinkedListInsertAtTail(&list, &test_data_1);
|
|
|
+ DoublyLinkedListNode *node_to_be_deleted = list.last;
|
|
|
+ DoublyLinkedListRemoveNode(&list, &node_to_be_deleted);
|
|
|
+ CHECK_EQUAL(2, test_data_1);
|
|
|
+ POINTERS_EQUAL(NULL, list.first);
|
|
|
+ POINTERS_EQUAL(NULL, list.last);
|
|
|
+ DoublyLinkedListDestroy(&list);
|
|
|
}
|