def test_after_single_push_extract_max_removes_and_returns_value(self): heap = MaxHeap() heap.insert(0) assert heap.size() == 1 assert not heap.is_empty() assert heap.extract_max() == 0 assert heap.size() == 0 assert heap.is_empty()
def test_after_single_push_delete_max_removes_the_value(self): heap = MaxHeap() heap.insert(0) assert heap.size() == 1 assert not heap.is_empty() heap.delete_max() assert heap.size() == 0 assert heap.is_empty()
def test_two_pushes_and_two_extract_max_correct_values_empty_at_end(self): heap = MaxHeap() heap.insert(0) heap.insert(1) assert heap.size() == 2 assert not heap.is_empty() assert heap.extract_max() == 1 assert heap.size() == 1 assert not heap.is_empty() assert heap.extract_max() == 0 assert heap.size() == 0 assert heap.is_empty()
def test_heap_size_is_3_after_three_pushes(self): heap = MaxHeap() heap.insert(0) heap.insert(1) heap.insert(2) assert heap.size() == 3
def test_heap_size_is_1_after_single_push(self): heap = MaxHeap() heap.insert(0) assert heap.size() == 1
def test_size_of_empty_heap_is_0(self): heap = MaxHeap() assert heap.size() == 0