Commit d8f7825d authored by Liam E. Roeth's avatar Liam E. Roeth

Add some functions to test

parent 4f7b3269
......@@ -3,19 +3,29 @@
#include "llist.h"
int main(){
puts("Constructing list manually...");
NODE *two = construct(5, NULL);
NODE *one = construct(1, two);
NODE *root = construct(3, one);
print_list(root);
printf("Searching for 5...\n");
puts("Adding 7 to end...");
add_to_end(root, 7);
print_list(root);
printf("Now it is %d elements long.\n", length(root));
printf("The head is at %p.\n", root);
puts("Adding 6 to the beginning and 8 at index 2...");
insert_node(root, 0, 6);
insert_node(root, 2, 8);
print_list(root);
printf("The head is still at %p.\n", root);
puts("Searching for 5...");
NODE_ERR target = search(root, 5);
printf("I found it at index %d\n", target.err);
printf("The number I found there was ");
printf("I found it at index %d.\n", target.err);
fputs("The number I found there was: ", stdout);
print_node(target.node);
printf("Deleting list...\n");
puts("Deleting list...");
delete_list(root);
printf("Now it is garbage:\n");
puts("Now it is garbage:");
print_list(root);
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment