diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2021-12-26 19:52:31 +0100 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2021-12-26 19:52:31 +0100 |
commit | a10a8fb335e5a817e1a9add49ee179394eea67c4 (patch) | |
tree | 70ea95120f4390a6a5f32cda5a8bf1d45e4e0487 /test/tsearch.c | |
parent | 0.0.16, read debian/changelog (diff) | |
download | sear.c-a10a8fb335e5a817e1a9add49ee179394eea67c4.tar sear.c-a10a8fb335e5a817e1a9add49ee179394eea67c4.tar.gz sear.c-a10a8fb335e5a817e1a9add49ee179394eea67c4.tar.bz2 sear.c-a10a8fb335e5a817e1a9add49ee179394eea67c4.tar.lz sear.c-a10a8fb335e5a817e1a9add49ee179394eea67c4.tar.xz sear.c-a10a8fb335e5a817e1a9add49ee179394eea67c4.tar.zst sear.c-a10a8fb335e5a817e1a9add49ee179394eea67c4.zip |
Diffstat (limited to 'test/tsearch.c')
-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; +} |