diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/tsearch.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/tsearch.c b/test/tsearch.c new file mode 100644 index 0000000..45c4eef --- /dev/null +++ b/test/tsearch.c @@ -0,0 +1,15 @@ +#include <stdio.h> +#include <search.h> +#include <string.h> +#define CAST (int (*) (const void *, const void *)) +int compar (const char * a, const char * b) { + return strcmp(a, b); +} +int main () { + void * root = NULL; + tsearch("key1", &root, CAST compar); + tsearch("key1", &root, CAST compar); + tsearch("key2", &root, CAST compar); + fprintf(stdout, "this should say key1: %s\n", *(char **) tfind("key1", &root, CAST compar)); + return 0; +} |