#include <stdlib.h>#include <stdio.h>#include <string.h>#include "icl_hash.h"
Go to the source code of this file.
Functions | |
| int | main (int argc, char **argv) |
This file contains test code for the icl_hash routines.
Definition in file icl_hash_test.c.
| int main | ( | int | argc, | |
| char ** | argv | |||
| ) |
Entry point for icl_hash tester.
| argc | -- arg count | |
| argv | -- array of command line args |
Definition at line 25 of file icl_hash_test.c.
{
icl_hash_t* ht = icl_hash_create(64, NULL);
icl_entry_t* p = NULL;
char *str, *foo;
printf("Inserting Hello: A word\n");
p = icl_hash_insert(ht, strdup("Hello"), strdup("A word"));
printf("New node: key:%s data:%s\n", p->key, (char*)p->data);
str = (char *)icl_hash_find(ht, "Hello");
if(str) printf("Found %s\n", str);
p = icl_hash_insert(ht, strdup("n"), strdup("a string for n"));
printf("New node: key:%s data:%s\n", p->key, (char*)p->data);
str = (char *)icl_hash_find(ht, "n");
if(str) printf("Found %s\n", str);
p = icl_hash_insert(ht, strdup("k"), strdup("a number for k"));
printf("New node: key:%s data:%s\n", p->key, (char*)p->data);
str = (char *)icl_hash_find(ht, "k");
if(str) printf("Found %s\n", str);
printf("Looking for non-existent node\n");
str = (char *)icl_hash_find(ht, "foo");
if(!str) printf("...cool, not found.\n");
foo = strdup("foo");
printf("Updating node\n");
if(!icl_hash_update_insert(ht, foo, strdup("new entry for k"), (void**)&str))
printf("update failed\n");
else {
printf("Looking for non-existent node\n");
str = (char *)icl_hash_find(ht, foo);
if(str) printf("Found %s\n", str);
}
icl_hash_dump(stderr, ht);
icl_hash_destroy(ht, free, free);
exit(EXIT_SUCCESS);
}

1.6.3-20100507