X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=inline;f=lib%2Fredblack-test.c;h=80a7a000ce8711603b11fce25877ca03fb46b4bb;hb=b18ffb4f5ef9c5d83d7a3e28c37fabbb7df44be2;hp=ede1a71e8baede52f7663130d7a36c0c8b901a16;hpb=b3524e137a080e8a37687347e1898cc1f0a91379;p=libucw.git diff --git a/lib/redblack-test.c b/lib/redblack-test.c index ede1a71e..80a7a000 100644 --- a/lib/redblack-test.c +++ b/lib/redblack-test.c @@ -4,9 +4,8 @@ * (c) 2002, Robert Spalek */ -#define DEBUG #include "lib/lib.h" -#include "lib/conf.h" +#include "lib/getopt.h" #include "lib/fastbuf.h" #include #include @@ -39,7 +38,6 @@ static void my_dump_data(struct fastbuf *fb, struct my1_node *n) #define TREE_WANT_DELETE #define TREE_WANT_ITERATOR #define TREE_WANT_DUMP -#define TREE_STATIC #define TREE_CONSERVE_SPACE #include "redblack.h" @@ -123,13 +121,13 @@ usage(void) int main(int argc, char **argv) { - uns verbose = 0, number = 1000, asserts = 0; + int verbose = 0, number = 1000, asserts = 0; int opt; struct fastbuf *fb, *dump_fb; struct my_tree t; struct my2_tree t2; int i; - cfdeffile = NULL; + cf_def_file = NULL; log_init(argv[0]); while ((opt = cf_getopt(argc, argv, options, CF_NO_LONG_OPTS, NULL)) >= 0) switch (opt) @@ -177,7 +175,8 @@ main(int argc, char **argv) } for (i=0; i<100; i++) { - int res UNUSED = my_delete(&t, i); + int a = i/10, b = i%10, j = a*10 + (b + a) % 10; + int res UNUSED = my_delete(&t, j); ASSERT(res); my_dump(dump_fb, &t); } @@ -192,13 +191,6 @@ main(int argc, char **argv) my_dump(NULL, &t); } my_dump(dump_fb, &t); - for (i=0; i<997; i++) - { - int res UNUSED = my_delete(&t, i*111 % 997); - ASSERT(res); - my_dump(NULL, &t); - } - my_dump(dump_fb, &t); i = 0; TREE_FOR_ALL(my, &t, n) { @@ -206,6 +198,14 @@ main(int argc, char **argv) i++; } TREE_END_FOR; + ASSERT(i == 997); + for (i=0; i<997; i++) + { + int res UNUSED = my_delete(&t, i*111 % 997); + ASSERT(res); + my_dump(NULL, &t); + } + my_dump(dump_fb, &t); my_cleanup(&t); if (verbose > 0) bputs(fb, "Complete tree passed\n");