From bf44aeaf5cd7f03d3bd842c8046b7346c5035f06 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sat, 14 Feb 2009 19:18:33 +0000 Subject: Remove dict, hash and rbtree from libparserutils svn path=/trunk/libparserutils/; revision=6512 --- test/rbtree.c | 88 ----------------------------------------------------------- 1 file changed, 88 deletions(-) delete mode 100644 test/rbtree.c (limited to 'test/rbtree.c') diff --git a/test/rbtree.c b/test/rbtree.c deleted file mode 100644 index ac27964..0000000 --- a/test/rbtree.c +++ /dev/null @@ -1,88 +0,0 @@ -#include -#include -#include - -#include "utils/rbtree.h" - -#include "testutils.h" - -static void *myrealloc(void *ptr, size_t len, void *pw) -{ - UNUSED(pw); - - return realloc(ptr, len); -} - -static int mycmp(const void *a, const void *b) -{ - return ((intptr_t) a) - ((intptr_t) b); -} - -int main(int argc, char **argv) -{ - parserutils_rbtree *tree; - - UNUSED(argc); - UNUSED(argv); - - assert(parserutils_rbtree_create(mycmp, myrealloc, NULL, &tree) == - PARSERUTILS_OK); - -#define N 40000 -#define G 307 -//#define N 400 -//#define G 7 - - printf("Inserting %d items\n", N); - - for (int i = G, count = 1; i != 0; i = (i + G) % N, count++) { - void *old; - assert(parserutils_rbtree_insert(tree, - (char *) NULL + i, (char *) NULL + i, - &old) == PARSERUTILS_OK); - - if ((count % 10000) == 0) - printf("%d\n", count); - } - - printf("Removing %d items\n", N/2); - - for (int i = 1, count = 1; i < N; i += 2, count++) { - void *key, *value; - assert(parserutils_rbtree_delete(tree, (char *) NULL + i, - &key, &value) == PARSERUTILS_OK); - if ((count % 10000) == 0) - printf("%d\n", count); - } - - printf("Finding %d items\n", N/2); - - for (int i = 2, count = 1; i < N; i += 2, count++) { - void *value = NULL; - assert(parserutils_rbtree_find(tree, (char *) NULL + i, - &value) == PARSERUTILS_OK); - assert(value != NULL && value == (char *) NULL + i); - if ((count % 10000) == 0) - printf("%d\n", count); - } - - printf("Verifying & removing %d items\n", N/2); - - for (int i = 1, count = 1; i < N; i += 2, count++) { - void *key, *value = NULL; - assert(parserutils_rbtree_find(tree, (char *) NULL + i, - &value) == PARSERUTILS_OK); - assert(value == NULL); - assert(parserutils_rbtree_delete(tree, (char *) NULL + i, - &key, &value) == PARSERUTILS_OK); - if ((count % 10000) == 0) - printf("%d\n", count); - } - - parserutils_rbtree_destroy(tree, NULL, NULL); - - printf("PASS\n"); - - return 0; -} - -- cgit v1.2.3