MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / test_heapCreate

Function test_heapCreate

tests/unit/test_heap.c:73–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73static 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
112static void test_heapPopulate(void) {
113 // create a new heap

Callers

nothing calls this directly

Calls 7

Heap_newFunction · 0.85
Heap_countFunction · 0.85
Heap_peekFunction · 0.85
Heap_pollFunction · 0.85
Heap_contains_itemFunction · 0.85
Heap_remove_itemFunction · 0.85
Heap_freeFunction · 0.85

Tested by

no test coverage detected