1 #include <ccan/rbtree/rbtree.c>
2 #include <ccan/tap/tap.h>
3 #include <ccan/talloc/talloc.h>
7 #define NUM_ELEMS 10000
9 static bool lookup_all(trbt_tree_t *rb, bool exist)
13 for (i = 0; i < NUM_ELEMS; i++) {
14 int *p = trbt_lookup32(rb, i);
27 static bool insert_all(trbt_tree_t *rb, bool exist)
31 for (i = 0; i < NUM_ELEMS; i++) {
32 int *p = trbt_insert32(rb, i, talloc_memdup(rb, &i, sizeof(i)));
45 static void delete_all(trbt_tree_t *rb)
49 for (i = 0; i < NUM_ELEMS; i++) {
57 void *ctx = talloc_init("toplevel");
62 rb = trbt_create(ctx, 0);
65 /* None should be there. */
66 ok1(lookup_all(rb, false));
68 /* Insert, none should be there previously. */
69 ok1(insert_all(rb, false));
72 ok1(lookup_all(rb, true));
75 ok1(insert_all(rb, true));
80 /* One more time... */
81 ok1(lookup_all(rb, false));
82 ok1(insert_all(rb, false));
84 /* All are children of rb, so this is clean. */
87 /* This exits depending on whether all tests passed */