29 lines
713 B
C
29 lines
713 B
C
#include "acutest.h"
|
|
#include "vieter_heap.h"
|
|
#include "vieter_heap_tree.h"
|
|
#include <stdlib.h>
|
|
|
|
void test_merge_same_order() {
|
|
vieter_heap_node *root_a = vieter_heap_node_init();
|
|
root_a->key = 1;
|
|
root_a->order = 0;
|
|
|
|
vieter_heap_node *root_b = vieter_heap_node_init();
|
|
root_b->key = 2;
|
|
root_b->order = 0;
|
|
|
|
vieter_heap_node *merged = vieter_heap_tree_merge_same_order(root_a, root_b);
|
|
|
|
TEST_CHECK(merged == root_a);
|
|
TEST_CHECK(merged->key == 1);
|
|
TEST_CHECK(merged->largest_order == root_b);
|
|
TEST_CHECK(merged->ptr.next_largest_order == NULL);
|
|
|
|
vieter_heap_tree_free(merged);
|
|
}
|
|
|
|
TEST_LIST = {
|
|
{"heap merge same order", test_merge_same_order},
|
|
{NULL, NULL}
|
|
};
|