45 struct node *n1 = _n1;
46 struct node *n2 = _n2;
50 }
else if (n1->
val == n2->
val) {
61 struct node nodes[3] = {
69 info->name =
"heap_test_1";
70 info->category =
"/main/heap/";
71 info->summary =
"push and pop elements";
72 info->description =
"Push a few elements onto a heap and make sure that they come back off in the right order.";
120 static const unsigned int total = 100000;
123 unsigned int i =
total;
124 long last = LONG_MAX;
130 info->name =
"heap_test_2";
131 info->category =
"/main/heap/";
132 info->summary =
"load test";
134 "Push one hundred thousand random elements on to a heap, " 135 "verify that the heap has been properly constructed, " 136 "and then ensure that the elements are come back off " 137 "in the proper order.";
143 if (!(nodes =
ast_malloc(total *
sizeof(*node)))) {
197 static const unsigned int test_size = 100000;
198 unsigned int i = test_size;
199 long last = LONG_MAX, cur;
205 info->name =
"heap_test_3";
206 info->category =
"/main/heap/";
207 info->summary =
"random element removal test";
209 "Push a hundred thousand random elements on to a heap, " 210 "verify that the heap has been properly constructed, " 211 "randomly remove and re-add 10000 elements, and then " 212 "ensure that the elements come back off in the proper order.";
218 if (!(nodes =
ast_malloc(test_size *
sizeof(*node)))) {
245 if (nodes[random_index].
val != node->
val){
271 if (i != test_size) {
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk main include file. File version handling, generic pbx functions.
static int unload_module(void)
#define AST_TEST_REGISTER(cb)
struct ast_heap * ast_heap_destroy(struct ast_heap *h)
Destroy a max heap.
void * ast_heap_pop(struct ast_heap *h)
Pop the max element off of the heap.
#define ast_heap_push(h, elm)
#define ast_test_status_update(a, b, c...)
struct sla_ringing_trunk * last
long int ast_random(void)
#define ast_malloc(len)
A wrapper for malloc()
static int load_module(void)
#define AST_TEST_UNREGISTER(cb)
#define ast_heap_create(init_height, cmp_fn, index_offset)
void * ast_heap_remove(struct ast_heap *h, void *elm)
Remove a specific element from a heap.
int ast_heap_verify(struct ast_heap *h)
Verify that a heap has been properly constructed.
AST_TEST_DEFINE(heap_test_1)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
static int node_cmp(void *_n1, void *_n2)
static struct ao2_container * nodes
All the nodes that we're aware of.