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");
61 rb = trbt_create(ctx, 0);
64 /* None should be there. */
65 ok1(lookup_all(rb, false));
67 /* Insert, none should be there previously. */
68 ok1(insert_all(rb, false));
71 ok1(lookup_all(rb, true));
74 ok1(insert_all(rb, true));
79 /* One more time... */
80 ok1(lookup_all(rb, false));
81 ok1(insert_all(rb, false));
83 /* All are children of rb, so this is clean. */
86 /* This exits depending on whether all tests passed */