def test_multipop_maxheap(): maxheap = BinaryHeap([7, 9, 18, 1, 38, 5.4, 6, 200], minheap=False) length = len(maxheap) maxheap.pop() maxheap.pop() maxheap.push(400) maxheap.pop() maxheap.pop() assert maxheap.pop() == 9 assert len(maxheap) == length - 4
def test_multipop_minheap(): minheap = BinaryHeap([7, 9, 18, 1, 38, 5.4, 6, 200]) length = len(minheap) minheap.pop() minheap.pop() minheap.push(0) minheap.pop() minheap.pop() assert minheap.pop() == 7 assert len(minheap) == length - 4
def test_pop_minheap(): minheap = BinaryHeap([7, 9, 18, 1, 38, 5.4, 6]) minheap.push(0) length = len(minheap) assert minheap.pop() == 0 assert len(minheap) == length - 1
def test_pop_maxheap(): maxheap = BinaryHeap([7, 9, 18, 1, 38, 5.4, 6], minheap=False) maxheap.push(400) length = len(maxheap) assert maxheap.pop() == 400 assert len(maxheap) == length - 1
def test_valid_instantiation_max(input, output): """Test instantiation by creating and doing one pop""" heap_under_test = BinaryHeap(input, minheap=False) assert is_maxheap_sorted(heap_under_test) assert heap_under_test.pop() == output