예제 #1
0
def test__Heap_remove2(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(set(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 x not in heap.to_list('inorder')
        assert heap.is_heap_satisfied()
예제 #2
0
def test__Heap_insert_list(xs):
    xs = list(xs)
    heap = Heap()
    heap.insert_list(xs)
    assert heap.is_heap_satisfied()
    for x in xs:
        assert x in heap.to_list('inorder')