def test_pop_heap(): heap1 = Heap(num_list) heap2 = Heap() heap3 = Heap() heap2.extend(num_list) for i in num_list: heap3.push(i) expected = [-2, 3, 10] assert (expected == [i for i in pop_heap(heap1)]) assert (expected == [i for i in pop_heap(heap2)]) assert (expected == [i for i in pop_heap(heap3)])
def test_pop_heap(): heap1 = Heap(num_list) heap2 = Heap() heap3 = Heap() heap2.extend(num_list) for i in num_list: heap3.push(i) expected = [-2, 3, 10] assert(expected == [i for i in pop_heap(heap1)]) assert(expected == [i for i in pop_heap(heap2)]) assert(expected == [i for i in pop_heap(heap3)])
def random_heap(): h = Heap() h.push(10) h.push(20) h.push(2) h.push(100) h.push(150) return h
def full_heap(): h = Heap() h.push(100) h.push(19) h.push(36) h.push(17) h.push(3) h.push(25) h.push(1) h.push(2) h.push(7) return h