This contains a test of the interval_tree.
#include "tests.h"
static void do_test(
struct interval_node *tree,
size_t num_nodes,
enum {
ntests = 100,
ntrees = 100,
};
size_t nmax = 1550;
tree = malloc(nmax * sizeof(tree[0]));
if (tree)
{
size_t i;
for (i = 0; i < ntrees; ++i)
{
size_t n = random()%(nmax + 1);
}
}
free(tree);
return TEST_EXIT_CODE;
}
static inline struct interval rand_interval() {
x = (double)(random() - RAND_MAX/2);
y = (double)(x + random());
iv.left = x;
return iv;
}
static void do_test(
struct interval_node *tree,
size_t num_nodes,
{
size_t j, noverlaps;
unsigned i;
for (i = 0; i < num_nodes; ++i)
tree[i].range = rand_interval();
for (i = 0; i < ntests; ++i)
{
iv = rand_interval();
PUT_ERR("overlap result does not overlap\n");
noverlaps = 0;
for (j = 0; j < num_nodes; j++)
PUT_ERR("overlap count mismatch\n");
}
}
int main(int argc, char **argv)
void yac_search_interval_tree(struct interval_node tree[], size_t num_nodes, struct interval query, struct overlaps *overlaps)
void yac_generate_interval_tree(struct interval_node intervals[], size_t num_nodes)
static int overlap_test(struct interval a, struct interval b)