Defines | Functions

icl_list_test.c File Reference

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "icl_list.h"
Include dependency graph for icl_list_test.c:

Go to the source code of this file.


#define strcmp   cmp


int cmp (void *p1, void *p2)
int main (int argc, char **argv)

Detailed Description

This file contains test code for the icl_list routines.

Definition in file icl_list_test.c.

Define Documentation

#define strcmp   cmp

Definition at line 20 of file icl_list_test.c.

Function Documentation

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
EXIT_SUCCESS on success, EXIT_FAILURE on error.

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);


Here is the call graph for this function: