def test_heap_fuzz(int_heap): for _ in six.moves.range(random.randint(1, 100000)): ops = random.randint(0, 1) if ops == 0: # push heap.push(int_heap, random.randint(0, sys.maxsize)) elif ops == 1: # pop if int_heap.size(): heap.pop(int_heap) if int_heap.size(): assert smallest(int_heap.values) == int_heap.values[0] verify(int_heap, 0)
def test_heap_fuzz(int_heap): for _ in six.moves.range(random.randint(1, 100000)): ops = random.randint(0, 1) if ops == 0: # push heap.push(int_heap, random.randint(0, sys.maxint)) elif ops == 1: # pop if int_heap.size(): heap.pop(int_heap) if int_heap.size(): assert smallest(int_heap.values) == int_heap.values[0] verify(int_heap, 0)
def test_pop(int_heap, values): for value in values: heap.push(int_heap, value) verify(int_heap, 0) for i in sorted(values): assert i == heap.pop(int_heap) verify(int_heap, 0) assert int_heap.size() == 0