Exemplo n.º 1
0
def test__Heap_remove_and_insert2(xs,ys):
    '''
    This test performs a mixture of both insertions and removals.
    This ensures that there are no weird interactions between inserting and removing.
    '''
    xs = list(xs)
    heap = Heap(xs)
    for y in ys:
        heap.insert(y)
        heap.remove_min()
        assert heap.is_heap_satisfied()
Exemplo n.º 2
0
def test__Heap_remove1(xs):
    '''
    This tests the remove function.
    In order to test the remove function, we must be able to generate valid Heaps.
    Therefore, you must have all the insert functionality completed before this test can pass.
    '''
    xs = list(xs)
    heap = Heap(xs)
    while len(xs)>0:
        x = min(xs)
        xs.remove(min(xs))
        assert x in heap.to_list('inorder')
        heap.remove_min()
        assert heap.is_heap_satisfied()