Example #1
0
 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()
Example #2
0
 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()
Example #3
0
    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()
Example #4
0
 def test_heap_is_not_empty_after_insert(self):
     heap = MaxHeap()
     heap.insert(0)
     assert not heap.is_empty()
Example #5
0
 def test_empty_heap_is_empty(self):
     heap = MaxHeap()
     assert heap.is_empty()