Пример #1
0
def test_swap_parent_child():
    """Test the parent and child values after swap."""
    from bin_heap import BinaryHeap
    bin_hp = BinaryHeap([3, 1.5])
    assert bin_hp._list[0] == 1.5 and bin_hp._list[1] == 3
    bin_hp._swap(0, 1)
    assert bin_hp._list[1] == 1.5 and bin_hp._list[0] == 3
Пример #2
0
def test_swap_list():
    """Test the list after swap."""
    from bin_heap import BinaryHeap
    bin_hp = BinaryHeap([3, 1.5])
    assert bin_hp._list == [1.5, 3]
    bin_hp._swap(0, 1)
    assert bin_hp._list == [3, 1.5]