diff options
Diffstat (limited to 'simclist-1.5/regrtest/test4-seeker.c')
| -rw-r--r-- | simclist-1.5/regrtest/test4-seeker.c | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/simclist-1.5/regrtest/test4-seeker.c b/simclist-1.5/regrtest/test4-seeker.c deleted file mode 100644 index 4b4b64a..0000000 --- a/simclist-1.5/regrtest/test4-seeker.c +++ /dev/null @@ -1,53 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <time.h> /* for srandom() */ -#include "../simclist.h" - -#define N 100000 -#define LEN 12 - -struct foo_s { - int a, b; - char c[LEN]; -}; - -int seeker(const void *el, const void *indicator) { - if (((struct foo_s *)el)->a == *(int *)indicator) - return 1; - return 0; -} - -size_t mymeter(const void *el) { - return (sizeof(struct foo_s)); -} - -int main() { - list_t l; - struct foo_s el; - int i, j; - - list_init(& l); - list_attributes_seeker(&l, seeker); - list_attributes_copy(&l, mymeter, 1); - - for (i = 0; i < N; i++) { - el.a = i; - el.b = 3*i; - snprintf(el.c, LEN, "%d-%d", el.a, el.b); - list_insert_at(& l, & el, i); - } - - srandom(time(NULL)); - - for (i = 0; i < N/4; i++) { - j = random() % list_size(&l); - el = *(struct foo_s *)list_seek(&l, &j); - if (el.a != j) { - printf("KO: %d retrieved %d\n", j, el.a); - return 1; - } - } - - list_destroy(& l); - return 0; -} |
