Exemplo n.º 1
0
def test_peek_returns_highest_priority_value():
    heap = Heap(5, default_priority_function)
    heap.insert(1)
    heap.insert(5)
    heap.insert(6)
    heap.insert(2)
    result = heap.peek()
    assert result == 6
Exemplo n.º 2
0
def test_heap_behaves_correctly_with_duplicate_values():
    heap = Heap(5, default_priority_function)
    heap.insert(1)
    heap.insert(5)
    heap.insert(3)
    heap.insert(5)
    assert heap.extract() == 5
    assert heap.extract() == 5
    assert heap.extract() == 3
    assert heap.peek() == 1