Release all memory in tests and fix comment
This commit is contained in:
parent
3d0b652ec9
commit
c0ee55325c
|
@ -732,7 +732,8 @@ int main(int argc, char** argv)
|
|||
exotic_add_test(&handle, &exotic_test_rbtree_size_4, "rbtree_size_4");
|
||||
exotic_add_test(&handle, &exotic_test_rbtree_check_10000, "rbtree_check_10000");
|
||||
exotic_add_test(&handle, &exotic_test_rbtree_iterate_10000, "rbtree_iterate_10000");
|
||||
exotic_add_test(&handle, &exotic_test_rbtree_remove_5000, "rbtree_remove_5000");
|
||||
exotic_add_test(&handle, &exotic_test_rbtree_remove_10000, "rbtree_remove_10000");
|
||||
exotic_add_test(&handle, &exotic_test_rbtree_destroy_1, "rbtree_destroy_1");
|
||||
exotic_add_test(&handle, &exotic_test_sid_create_pool, "sid_create_pool");
|
||||
exotic_add_test(&handle, &exotic_test_sid_check_0a, "sid_check_0a");
|
||||
exotic_add_test(&handle, &exotic_test_sid_check_0b, "sid_check_0b");
|
||||
|
@ -770,6 +771,7 @@ int main(int argc, char** argv)
|
|||
exotic_add_test(&handle, &exotic_test_timer_add_5_events_1, "timer_add_5_events_1");
|
||||
exotic_add_test(&handle, &exotic_test_timer_check_5_events_1, "timer_check_5_events_1");
|
||||
exotic_add_test(&handle, &exotic_test_timer_process_5_events_1, "timer_process_5_events_1");
|
||||
exotic_add_test(&handle, &exotic_test_timer_shutdown, "timer_shutdown");
|
||||
exotic_add_test(&handle, &exotic_test_tokenizer_basic_0, "tokenizer_basic_0");
|
||||
exotic_add_test(&handle, &exotic_test_tokenizer_basic_1, "tokenizer_basic_1");
|
||||
exotic_add_test(&handle, &exotic_test_tokenizer_basic_1a, "tokenizer_basic_1a");
|
||||
|
|
|
@ -122,21 +122,29 @@ EXO_TEST(rbtree_iterate_10000, {
|
|||
return i == MAX_NODES;
|
||||
});
|
||||
|
||||
|
||||
static int freed_nodes = 0;
|
||||
static void free_node(struct rb_node* n)
|
||||
{
|
||||
hub_free((void*) n->key);
|
||||
hub_free((void*) n->value);
|
||||
freed_nodes += 1;
|
||||
}
|
||||
|
||||
EXO_TEST(rbtree_remove_5000, {
|
||||
int i = 0;
|
||||
for (i = 0; i < MAX_NODES ; i += 2)
|
||||
EXO_TEST(rbtree_remove_10000, {
|
||||
int i;
|
||||
int j;
|
||||
for (j = 0; j < 2; j++)
|
||||
{
|
||||
for (i = j; i < MAX_NODES; i += 2)
|
||||
{
|
||||
const char* key = uhub_itoa(i);
|
||||
rb_tree_remove_node(tree, key, &free_node);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return freed_nodes == MAX_NODES;
|
||||
});
|
||||
|
||||
|
||||
EXO_TEST(rbtree_destroy_1, {
|
||||
rb_tree_destroy(tree);
|
||||
return 1;
|
||||
});
|
||||
|
|
|
@ -117,3 +117,9 @@ EXO_TEST(timer_process_5_events_1,{
|
|||
g_now = 4;
|
||||
return timeout_queue_process(g_queue, g_now) == g_triggered;
|
||||
});
|
||||
|
||||
EXO_TEST(timer_shutdown,{
|
||||
timeout_queue_shutdown(g_queue);
|
||||
hub_free(g_queue);
|
||||
return 1;
|
||||
});
|
||||
|
|
|
@ -62,8 +62,8 @@ struct rb_tree
|
|||
extern struct rb_tree* rb_tree_create(rb_tree_compare compare, rb_tree_alloc alloc, rb_tree_free dealloc);
|
||||
|
||||
/**
|
||||
* Deletes the tree and all the nodes.
|
||||
* But not the content inside the nodes.
|
||||
* Delete the tree.
|
||||
* Assumes that the tree is empty.
|
||||
*/
|
||||
extern void rb_tree_destroy(struct rb_tree*);
|
||||
|
||||
|
|
Loading…
Reference in New Issue