1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
/*
* Copyright (C) 2010. See COPYRIGHT in top-level directory.
*/
#include <stdio.h>
#include <stdlib.h>
#include <conflict_tree.h>
#define MAX 20
#define INC 4
int main(int argc, char **argv) {
uint8_t *i;
ctree_t ctree = CTREE_EMPTY;
printf("========== FORWARD INSERT CHECK ==========\n");
for (i = 0; i <= (uint8_t*) MAX; i+=INC) {
printf("----- Inserting [%10p, %10p] -----\n", i, i+INC-1);
int conflict = ctree_insert(&ctree, i, i+INC-1);
ctree_print(ctree);
if (conflict)
printf("Error, conflict inserting %p\n", i);
}
for (i = 0; i <= (uint8_t*) MAX; i+=INC) {
printf("----- Checking [%10p, %10p] -----\n", i, i+INC-1);
int conflict = ctree_insert(&ctree, i, i+INC-1);
if (!conflict)
printf("Error, no conflict inserting %p\n", i);
}
ctree_destroy(&ctree);
printf("========== REVERSE INSERT CHECK ==========\n");
for (i = (uint8_t*) MAX+INC; i-INC >= (uint8_t*) 0 && i-INC <= (uint8_t*) MAX; i-=INC) {
printf("----- Inserting [%10p, %10p] -----\n", i-INC, i-1);
int conflict = ctree_insert(&ctree, i-INC, i-1);
ctree_print(ctree);
if (conflict)
printf("Error, conflict inserting %p\n", i);
}
for (i = 0; i <= (uint8_t*) MAX; i+=INC) {
printf("----- Checking [%10p, %10p] -----\n", i, i+INC-1);
int conflict = ctree_insert(&ctree, i, i+INC-1);
if (!conflict)
printf("Error, no conflict inserting %p\n", i);
}
ctree_destroy(&ctree);
return 0;
}
|