test(heap): test insert after every pop just in case
parent
5b2ce6acaa
commit
167611e6fa
|
@ -159,6 +159,18 @@ void test_pop_random() {
|
|||
TEST_CHECK_(data == (void *)numbers[i], "pop %lx == %lx", (uint64_t)data, numbers[i]);
|
||||
TEST_SIZE(heap, n - i - 1);
|
||||
TEST_CHECK(count_nodes_heap(heap) == n - i - 1);
|
||||
|
||||
// Assure each size is also a valid heap after inserting
|
||||
vieter_heap_insert(heap, numbers[i], (void *)numbers[i]);
|
||||
TEST_SIZE(heap, n - i);
|
||||
TEST_CHECK(count_nodes_heap(heap) == n - i);
|
||||
|
||||
data = NULL;
|
||||
|
||||
TEST_CHECK(vieter_heap_pop(&data, heap) == vieter_heap_ok);
|
||||
TEST_CHECK_(data == (void *)numbers[i], "pop %lx == %lx", (uint64_t)data, numbers[i]);
|
||||
TEST_SIZE(heap, n - i - 1);
|
||||
TEST_CHECK(count_nodes_heap(heap) == n - i - 1);
|
||||
}
|
||||
|
||||
vieter_heap_free(heap);
|
||||
|
|
Loading…
Reference in New Issue