TestHeapEmptyPop tests that pop returns properly after heap is closed.
(t *testing.T)
| 132 | |
| 133 | // TestHeapEmptyPop tests that pop returns properly after heap is closed. |
| 134 | func TestHeapEmptyPop(t *testing.T) { |
| 135 | h := NewHeap(testHeapObjectKeyFunc, compareInts) |
| 136 | go func() { |
| 137 | time.Sleep(1 * time.Second) |
| 138 | h.Close() |
| 139 | }() |
| 140 | _, err := h.Pop() |
| 141 | if err == nil || err.Error() != closedMsg { |
| 142 | t.Errorf("pop should have returned heap closed error: %v", err) |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | // TestHeap_AddIfNotPresent tests Heap.AddIfNotPresent and ensures that heap |
| 147 | // invariant is preserved after adding items. |