예제 #1
0
def test_list_reverse_order():
    lst = [42, 23, 16, 15, 8, 4]
    quick_sort(lst, 0, 5)
    assert lst == [4, 8, 15, 16, 23, 42]
예제 #2
0
def test_strings():
    lst = ['cat','a', 'c', 'b']
    quick_sort(lst, 0, 3)
    assert lst == ['a', 'b', 'c', 'cat']
예제 #3
0
def test_another_lst():
    lst = [5,12,7,5,5,7]
    quick_sort(lst, 0, 5)
    assert lst == [5, 5, 5, 7, 7, 12]
예제 #4
0
def test_one_element():
    lst = [4]
    quick_sort(lst, 0, 0)
    assert lst == [4]
예제 #5
0
def test_two_elements():
    lst = [5, 4]
    quick_sort(lst, 0, 1)
    assert lst == [4, 5]
예제 #6
0
def test_same_vals():
    lst = [1, 1, 1, 1, 1]
    quick_sort(lst, 0, 4)
    assert lst == [1, 1, 1, 1, 1]
예제 #7
0
def test_empty_list():
    lst = []
    quick_sort(lst, 0, 0)
    assert lst == []
예제 #8
0
def test_simple_lst():
    lst = [8,4,23,42,16,15]
    quick_sort(lst, 0, 5)
    assert lst == [4, 8, 15, 16, 23, 42]
예제 #9
0
def test_sorted():
    lst = [2,3,5,7,11,13]
    quick_sort(lst, 0, 5)
    assert lst == [2,3,5,7,11,13]
예제 #10
0
def test_list_zeros_and_negative():
    lst = [-23, -0.5, -4, 0, -1]
    quick_sort(lst, 0, 4)
    assert lst == [-23, -4, -1, -0.5, 0]
예제 #11
0
def test_few_uniques():
    lst = [5,12,7,5,5,7]
    quick_sort(lst, 0, 5)
    assert lst == [5, 5, 5, 7, 7, 12]
예제 #12
0
def test_list_reverse_order2():
    lst = [20,18,12,8,5,-2]
    quick_sort(lst, 0, 5)
    assert lst == [-2, 5, 8, 12, 18, 20]
def test_quick_sort():
    assert quick_sort([20,18,12,8,5,-2],0,5)==[-2,5,8,12,18,20]
    assert quick_sort([5,12,7,5,5,7],0,5)==[5,5,5,7,7,12]
    assert quick_sort([2,3,5,7,13,11],0,5)==[2,3,5,7,11,13]
예제 #14
0
def test_sort_normal_list():
    x = [8, 4, 23, 42, 16, 15]
    n = len(x)
    expected = [4, 8, 15, 16, 23, 42]
    actual = quick_sort(x, 0, n - 1)
    assert expected == x
예제 #15
0
def test_empty_list():
    x = []
    n = len(x)
    expected = 'This list is empty'
    actual = quick_sort(x, 0, n - 1)
    assert expected == actual
예제 #16
0
def test_sort_reversed_list():
    x = [20, 18, 12, 8, 5, -2]
    n = len(x)
    expected = [-2, 5, 8, 12, 18, 20]
    actual = quick_sort(x, 0, n - 1)
    assert expected == x