Subversion Repositories HelenOS

Rev

Rev 2027 | Rev 2071 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2027 Rev 2050
Line 31... Line 31...
31
#include <adt/btree.h>
31
#include <adt/btree.h>
32
#include <debug.h>
32
#include <debug.h>
33
 
33
 
34
static void *data = (void *) 0xdeadbeef;
34
static void *data = (void *) 0xdeadbeef;
35
 
35
 
36
char * test_btree1(void)
36
char * test_btree1(bool quiet)
37
{
37
{
38
    btree_t t;
38
    btree_t t;
39
    int i;
39
    int i;
40
 
40
 
41
    btree_create(&t);
41
    btree_create(&t);
42
 
42
   
-
 
43
    if (!quiet)
43
    printf("Inserting keys.\n");
44
        printf("Inserting keys.\n");
44
    btree_insert(&t, 19, data, NULL);
45
    btree_insert(&t, 19, data, NULL);
45
    btree_insert(&t, 20, data, NULL);
46
    btree_insert(&t, 20, data, NULL);
46
    btree_insert(&t, 21, data, NULL);
47
    btree_insert(&t, 21, data, NULL);
47
    btree_insert(&t, 0, data, NULL);
48
    btree_insert(&t, 0, data, NULL);
48
    btree_insert(&t, 25, data, NULL);
49
    btree_insert(&t, 25, data, NULL);
Line 74... Line 75...
74
 
75
 
75
    for (i = 30; i < 50; i++)
76
    for (i = 30; i < 50; i++)
76
        btree_insert(&t, i, data, NULL);
77
        btree_insert(&t, i, data, NULL);
77
    for (i = 100; i >= 50; i--)
78
    for (i = 100; i >= 50; i--)
78
        btree_insert(&t, i, data, NULL);
79
        btree_insert(&t, i, data, NULL);
79
 
-
 
80
    btree_print(&t);
-
 
81
   
80
   
-
 
81
    if (!quiet)
-
 
82
        btree_print(&t);
-
 
83
   
-
 
84
    if (!quiet)
82
    printf("Removing keys.\n");
85
        printf("Removing keys.\n");
83
    btree_remove(&t, 50, NULL);
86
    btree_remove(&t, 50, NULL);
84
    btree_remove(&t, 49, NULL);
87
    btree_remove(&t, 49, NULL);
85
    btree_remove(&t, 51, NULL);
88
    btree_remove(&t, 51, NULL);
86
    btree_remove(&t, 46, NULL);
89
    btree_remove(&t, 46, NULL);
87
    btree_remove(&t, 45, NULL);
90
    btree_remove(&t, 45, NULL);
Line 152... Line 155...
152
    btree_remove(&t, 42, NULL);
155
    btree_remove(&t, 42, NULL);
153
    btree_remove(&t, 39, NULL);
156
    btree_remove(&t, 39, NULL);
154
    btree_remove(&t, 34, NULL);
157
    btree_remove(&t, 34, NULL);
155
    btree_remove(&t, 35, NULL);
158
    btree_remove(&t, 35, NULL);
156
    btree_remove(&t, 36, NULL);
159
    btree_remove(&t, 36, NULL);
157
 
160
   
-
 
161
    if (!quiet)
158
    btree_print(&t);
162
        btree_print(&t);
159
   
163
   
160
    return NULL;
164
    return NULL;
161
}
165
}