#include #include #include "linked-list.h" /**** * * This is a testing program for the simple implementation in linked-list{h,c}. * */ /** * Print the given list with the given debugging message one line above the * list output. */ void print(LinkedList* l, char* msg) { printf("List contents, should be %s\n ", msg); printList(l); printf("\n"); } /** * Allocate a linked list, insert some values in it, and print it out after * each insert. */ int main () { LinkedList* l; l = newLinkedList(); print(l, "empty"); insert(l, newListNode(0), 0); print(l, "0"); insert(l, newListNode(1), 1); print(l, "0,1"); insert(l, newListNode(2), 2); print(l, "0,1,2"); insert(l, newListNode(3), 3); print(l, "0,1,2,3"); insert(l, newListNode(-1), 0); print(l, "-1,0,1,2,3"); insert(l, newListNode(10), 3); print(l, "-1,0,1,10,2,3"); insert(l, newListNode(100), 6); print(l, "-1,0,1,10,2,3,100"); insert(l, newListNode(100), l->length+1); print(l, "-1,0,1,10,2,3,100"); insert(l, newListNode(100), -1); print(l, "-1,0,1,10,2,3,100"); exit(0); }