| 71 | } |
| 72 | |
| 73 | static void test_heapCreate(void) { |
| 74 | void *elem; |
| 75 | // create a new heap |
| 76 | heap_t *heap = Heap_new(cmp, NULL); |
| 77 | |
| 78 | TEST_ASSERT(Heap_count(heap) == 0); // expecting heap to be empty |
| 79 | |
| 80 | //-------------------------------------------------------------------------- |
| 81 | // try to peek top of heap |
| 82 | //-------------------------------------------------------------------------- |
| 83 | |
| 84 | elem = Heap_peek(heap); |
| 85 | TEST_ASSERT(elem == NULL); // expecting NULL for empty heap |
| 86 | |
| 87 | //-------------------------------------------------------------------------- |
| 88 | // try to get element from heap |
| 89 | //-------------------------------------------------------------------------- |
| 90 | |
| 91 | elem = Heap_poll(heap); |
| 92 | TEST_ASSERT(elem == NULL); // expecting NULL for empty heap |
| 93 | |
| 94 | //-------------------------------------------------------------------------- |
| 95 | // try to locate a none existing element |
| 96 | //-------------------------------------------------------------------------- |
| 97 | |
| 98 | int x = 2; |
| 99 | TEST_ASSERT(Heap_contains_item(heap, &x) == 0); |
| 100 | |
| 101 | //-------------------------------------------------------------------------- |
| 102 | // try to remove a none existing element |
| 103 | //-------------------------------------------------------------------------- |
| 104 | |
| 105 | elem = Heap_remove_item(heap, &x); |
| 106 | TEST_ASSERT(elem == NULL); |
| 107 | |
| 108 | // free heap |
| 109 | Heap_free(heap); |
| 110 | } |
| 111 | |
| 112 | static void test_heapPopulate(void) { |
| 113 | // create a new heap |
nothing calls this directly
no test coverage detected