c->last = key;
}
-static void t_tree(void)
+static void t_tree_search(void)
{
struct tree_node *root = NULL;
void *values[11] = { 0 };
struct tree_node *nodes[11] = { 0 };
size_t i = 1;
- struct curry c = { 0 };
/*
* Pseudo-randomly insert the pointers for elements between
check_pointer_eq(nodes[i], tree_search(&values[i], &root, &t_compare, 0));
}
- infix_walk(root, check_increasing, &c);
+ tree_free(root);
+}
+
+static void t_infix_walk(void)
+{
+ struct tree_node *root = NULL;
+ void *values[11] = { 0 };
+ struct curry c = { 0 };
+ size_t i = 1;
+
+ do {
+ tree_search(&values[i], &root, t_compare, 1);
+ i = (i * 7) % 11;
+ } while (i != 1);
+
+ infix_walk(root, &check_increasing, &c);
tree_free(root);
}
int cmd_main(int argc, const char *argv[])
{
- TEST(t_tree(), "tree_search and infix_walk work");
+ TEST(t_tree_search(), "tree_search works");
+ TEST(t_infix_walk(), "infix_walk works");
return test_done();
}