def test_one_push_pop(): bin_list = BinaryHeap() bin_list.push(10) assert bin_list.pop() == 10
def test_organize_right(): """Test organize right after pop.""" from bin_heap import BinaryHeap bin_hp = BinaryHeap([12, 13, 9, 15, 16, 3, 5]) bin_hp.pop() bin_hp._list == [5, 13, 3, 15, 16, 9]
def test_pop_heap(): """Test heap function orders value correctly after pop.""" from bin_heap import BinaryHeap bin_hp = BinaryHeap([1, 1.5, 3, 4, 2, 2.5, 6, 2, 8, 5.5, 3.5]) bin_hp.pop() assert bin_hp._list == [1.5, 2, 2.5, 3.5, 2, 3, 6, 4, 8, 5.5]
def test_max_pop(): """Test pop on max heap.""" from bin_heap import BinaryHeap maxheap = BinaryHeap([1, 2, 3], 'max') assert maxheap.pop() == 3