예제 #1
0
def test_more_inputs():
    output = DummyOutput()
    n_inputs = 100
    bubblesort.options['n_inputs'] = n_inputs
    bubblesort.run(IntGenerator(), output)
    assert len(output) == n_inputs
    for i in range(len(output) - 1):
        assert output[i] == output[i + 1] + 1
예제 #2
0
def test_run():
    output = DummyOutput()
    n_inputs = 10
    b_tree.options['n_inputs'] = n_inputs
    b_tree.run(IntGenerator(), output)
    assert len(output) == n_inputs
    for i in range(len(output) - 1):
        assert output[i] == output[i + 1] + 1
예제 #3
0
def test_min_more_inputs():
    output = DummyOutput()
    n_inputs = 100
    red_black_tree.options['n_inputs'] = n_inputs
    red_black_tree.run(IntGenerator(), output)
    assert len(output) == n_inputs
    for i in range(len(output) - 1):
        assert output[i] == output[i + 1] + 1
예제 #4
0
def test_run_hoare():
    output = DummyOutput()
    n_inputs = 11
    quicksort.options['n_inputs'] = n_inputs
    quicksort.options['type'] = 'hoare'
    quicksort.run(IntGenerator(), output)
    assert len(output) == n_inputs
    for i, j in enumerate(output):
        assert j == i + 1 + (255 - n_inputs)
예제 #5
0
def test_min():
    output = DummyOutput()
    n_inputs = 10
    heap.options['n_inputs'] = n_inputs
    heap.options['type'] = 'min'
    heap.run(IntGenerator(), output)
    assert len(output) == n_inputs
    for i in range(len(output) - 1):
        assert output[i] == output[i + 1] + 1
예제 #6
0
def test_run():
    output = DummyOutput()
    n_inputs = 10
    bucketsort.options['n_inputs'] = n_inputs
    bucketsort.run(IntGenerator(), output)
    assert len(output) == n_inputs
    assert output[0] == 0
    assert output[1] == 255
    for i in range(2, len(output)):
        assert output[i] == i - 2
예제 #7
0
def test_max_more_inputs():
    output = DummyOutput()
    n_inputs = 100
    first_message = 'Tree insertion order:'
    binary_search_tree.options['n_inputs'] = n_inputs
    binary_search_tree.options['function'] = 'max'
    binary_search_tree.run(IntGenerator(), output)
    assert len(output) == n_inputs + 1
    assert output[0] == first_message
    for i in range(1, len(output) - 1):
        assert output[i] == 255 - (n_inputs - i)
예제 #8
0
def test_insert_more_inputs():
    output = DummyOutput()
    n_inputs = 100
    final_message_prefix = 'Insert : '
    first_message = 'Tree insertion order:'
    binary_search_tree.options['n_inputs'] = n_inputs
    binary_search_tree.options['function'] = 'insert'
    binary_search_tree.run(IntGenerator(), output)
    assert len(output) == n_inputs + 2
    assert output[0] == first_message
    for i in range(1, len(output) - 1):
        assert output[i] == 256 - i
    assert output[-1][:len(final_message_prefix)] == final_message_prefix
    assert int(output[-1][len(final_message_prefix):]) == 255 - n_inputs
예제 #9
0
def test_run_mid():
    output = DummyOutput()
    n_inputs = 11
    quicksort.options['n_inputs'] = n_inputs
    quicksort.options['type'] = 'mid'
    quicksort.run(IntGenerator(), output)
    assert len(output) == n_inputs
    expected_value = 255 - 1
    for i in range(n_inputs // 2):
        assert output[i] == expected_value
        expected_value -= 2
    expected_value = 255
    for i in range(1, 1 + math.ceil(n_inputs / 2)):
        assert output[-i] == expected_value
        expected_value -= 2
예제 #10
0
def test_small_convex_hull():
    output = DummyOutput()
    n_inputs = 10
    convex_hull.options['n_inputs'] = n_inputs
    convex_hull.run(IntGenerator(), output)
    assert len(output) == n_inputs
예제 #11
0
def test_run():
    output = DummyOutput()
    n_inputs = 10
    mergesort.options['n_inputs'] = n_inputs
    mergesort.run(IntGenerator(), output)
    assert len(output) == n_inputs