From 5b65344fd280f1cdbfb6ae0eb6784501dfb534a4 Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Fri, 5 Jul 2013 00:36:19 +0200 Subject: test_rdxtree: use 64-bit keys In addition, add a test with a key larger than 32 bits. --- test/test_rdxtree.c | 49 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 14 deletions(-) (limited to 'test') diff --git a/test/test_rdxtree.c b/test/test_rdxtree.c index 3208c04..de4965b 100644 --- a/test/test_rdxtree.c +++ b/test/test_rdxtree.c @@ -42,14 +42,14 @@ #endif /* RDXTREE_RADIX < 6 */ struct obj { - unsigned long id; + unsigned long long id; }; static void print_subtree(struct rdxtree_node *node, int height, size_t index, size_t level); static struct obj * -obj_create(unsigned long id) +obj_create(unsigned long long id) { struct obj *obj; @@ -79,7 +79,7 @@ print_value(void *ptr, size_t index, size_t level) for (i = level; i > 0; i--) putchar(' '); - printf("%zu:%lu\n", index, obj->id); + printf("%zu:%llu\n", index, obj->id); } static void @@ -361,7 +361,7 @@ test_11(void) { struct rdxtree tree; struct obj *obj; - unsigned long i; + unsigned long long i; int error; TITLE("insert [0..4096] and remove in reverse order"); @@ -387,7 +387,7 @@ test_12(void) { struct rdxtree tree; struct obj *obj; - unsigned long i; + unsigned long long i; int error; TITLE("insert [0..4096] and remove in same order"); @@ -413,7 +413,7 @@ test_13(void) { struct rdxtree tree; struct obj *obj; - unsigned long i; + unsigned long long i; int error; TITLE("allocate"); @@ -435,7 +435,7 @@ test_14(void) { struct rdxtree tree; struct obj *obj; - unsigned long i; + unsigned long long i; int error; TITLE("insert 0, allocate"); @@ -460,7 +460,7 @@ test_15(void) { struct rdxtree tree; struct obj *obj; - unsigned long i; + unsigned long long i; int error; TITLE("insert [0..4095], remove 0, allocate"); @@ -486,7 +486,7 @@ test_16(void) { struct rdxtree tree; struct obj *obj; - unsigned long i; + unsigned long long i; int error; TITLE("insert [0..4095], remove 1, allocate"); @@ -512,7 +512,7 @@ test_17(void) { struct rdxtree tree; struct obj *obj; - unsigned long i; + unsigned long long i; int error; TITLE("insert [0..63] and [128..191], allocate x65"); @@ -550,7 +550,7 @@ test_18(void) { struct rdxtree tree; struct obj *obj; - unsigned long i; + unsigned long long i; int error; TITLE("insert [0..4095], allocate"); @@ -700,7 +700,7 @@ test_25(void) struct rdxtree tree; struct obj *obj; void **slot; - unsigned long i; + unsigned long long i; int error; TITLE("insert_alloc_slot x3"); @@ -723,7 +723,7 @@ test_26(void) { struct rdxtree tree; struct obj *obj; - unsigned long i; + unsigned long long i; int error; TITLE("insert [0..62], remove 63"); @@ -747,7 +747,7 @@ test_27(void) { struct rdxtree tree; struct obj *obj; - unsigned long i; + unsigned long long i; int error; TITLE("insert [0..63], remove 64"); @@ -937,6 +937,26 @@ test_36(void) destroy_tree(&tree); } +static void +test_37(void) +{ + struct rdxtree tree; + struct obj *obj; + void *ptr; + int error; + + TITLE("insert and remove 4294967296"); + + rdxtree_init(&tree); + obj = obj_create(4294967296); + error = rdxtree_insert(&tree, obj->id, obj); + assert(!error); + ptr = rdxtree_remove(&tree, obj->id); + assert(ptr == obj); + obj_destroy(obj); + print_tree(&tree); +} + int main(int argc, char *argv[]) { @@ -979,5 +999,6 @@ main(int argc, char *argv[]) test_34(); test_35(); test_36(); + test_37(); return 0; } -- cgit v1.2.3