Exemplo n.º 1
0
def test_strings():
    lst = ['cat', 'a', 'c', 'b']
    merge_sort(lst)
    assert lst == ['a', 'b', 'c', 'cat']
Exemplo n.º 2
0
def test_list_reverse_order():
    lst = [42, 23, 16, 15, 8, 4]
    merge_sort(lst)
    assert lst == [4, 8, 15, 16, 23, 42]
Exemplo n.º 3
0
def test_one_element():
    lst = [4]
    merge_sort(lst)
    assert lst == [4]
Exemplo n.º 4
0
def test_two_elements():
    lst = [5, 4]
    merge_sort(lst)
    assert lst == [4, 5]
Exemplo n.º 5
0
def test_same_vals():
    lst = [1, 1, 1, 1, 1]
    merge_sort(lst)
    assert lst == [1, 1, 1, 1, 1]
Exemplo n.º 6
0
def test_empty_list():
    lst = []
    merge_sort(lst)
    assert lst == []
Exemplo n.º 7
0
def test_nearly_sorted():
    lst = [2, 3, 5, 7, 13, 11]
    merge_sort(lst)
    assert lst == [2, 3, 5, 7, 11, 13]
def test_revers():
    assert merge_sort([20,18,12,8,5,-2])== [-2,5,8,12,18,20]
Exemplo n.º 9
0
def test_few_uniques():
    lst = [5, 12, 7, 5, 5, 7]
    merge_sort(lst)
    assert lst == [5, 5, 5, 7, 7, 12]
Exemplo n.º 10
0
def test_simple_lst():
    lst = [8, 4, 23, 42, 16, 15]
    merge_sort(lst)
    assert lst == [4, 8, 15, 16, 23, 42]
Exemplo n.º 11
0
def test_list_zeros_and_negative():
    lst = [-23, -0.5, -4, 0, -1]
    merge_sort(lst)
    assert lst == [-23, -4, -1, -0.5, 0]
Exemplo n.º 12
0
def test_list_reverse_order2():
    lst = [20, 18, 12, 8, 5, -2]
    merge_sort(lst)
    assert lst == [-2, 5, 8, 12, 18, 20]
def test_uniques():
    assert merge_sort([5,12,7,5,5,7])== [5,5,5,7,7,12]
def test_empty_list():
    x = []
    expected = 'This list is empty'
    actual = merge_sort(x)
    assert expected == actual
Exemplo n.º 15
0
def test_sorted():
    lst = [2, 3, 5, 7, 11, 13]
    merge_sort(lst)
    assert lst == [2, 3, 5, 7, 11, 13]
def test_sort_normal_list():
    x = [8, 4, 23, 42, 16, 15]
    expected = [4, 8, 15, 16, 23, 42]
    actual = merge_sort(x)
    assert expected == actual
def test_nearly_sorted():
    assert merge_sort([2,3,5,7,13,11])== [2,3,5,7,11,13]