#include <stdlib.h>#include <stdio.h>#include <string.h>#include "icl_list.h"
Go to the source code of this file.
Defines | |
| #define | strcmp cmp |
Functions | |
| int | cmp (void *p1, void *p2) |
| int | main (int argc, char **argv) |
This file contains test code for the icl_list routines.
Definition in file icl_list_test.c.
| #define strcmp cmp |
Definition at line 20 of file icl_list_test.c.
| int cmp | ( | void * | p1, | |
| void * | p2 | |||
| ) |
Definition at line 18 of file icl_list_test.c.
{ return strcmp((char*)p1, (char*) p2); }
| int main | ( | int | argc, | |
| char ** | argv | |||
| ) |
Entry point for icl_list tester.
| argc | -- arg count | |
| argv | -- array of command line args |
Definition at line 31 of file icl_list_test.c.
{
icl_list_t* head = icl_list_new();
icl_list_t* l = NULL;
icl_list_prepend(head, strdup("A word"));
icl_list_prepend(head, strdup("B word"));
icl_list_prepend(head, strdup("This word"));
icl_list_prepend(head, strdup("C word"));
icl_list_prepend(head, strdup("D word"));
icl_list_prepend(head, strdup("That word"));
printf("size %d\n", icl_list_size(head));
printf("Printing the list\n");
for (l=icl_list_first(head); l!=NULL; l=icl_list_next(head, l)) {
printf("%s\n", (char *)l->data);
}
printf("Search: This word\n");
l=icl_list_search(head, "This word", strcmp);
printf("Found %s\n", (char *)l->data);
printf("Insert: After this word\n");
l=icl_list_insert(head, l, strdup("After this word"));
printf("Search: This man\n");
l=icl_list_search(head, "This man", strcmp);
if (l!=NULL) printf("Found %s\n", (char *)l->data);
else printf("Not found\n");
printf("Search: After this word\n");
l=icl_list_search(head, "After this word", strcmp);
if (l!=NULL) printf("Found %s\n", (char *)l->data);
else printf("Not found\n");
icl_list_destroy(head, free);
exit(EXIT_SUCCESS);
}

1.6.3-20100507