def test_happy_path():
    actual = quick_sort([8, 4, 23, 42, 16, 15], 0, 5)
    expect = [4, 8, 15, 16, 23, 42]
    assert actual == expect
def test_reverse_sorted():
    actual = quick_sort([20, 18, 12, 8, 5, -2], 0, 5)
    expect = [-2, 5, 8, 12, 18, 20]
    assert actual == expect
def test_few_uniques():
    actual = quick_sort([5, 12, 7, 5, 5, 7], 0, 5)
    expect = [5, 5, 5, 7, 7, 12]
    assert actual == expect
def test_nearly_sorted():
    actual = quick_sort([2, 3, 5, 7, 13, 11], 0, 5)
    expect = [2, 3, 5, 7, 11, 13]
    assert actual == expect
def test_revers():
    assert quick_sort([20, 18, 12, 8, 5, -2], 0, 5) == [-2, 5, 8, 12, 18, 20]
def test_uniques():
    assert quick_sort([5, 12, 7, 5, 5, 7], 0, 5) == [5, 5, 5, 7, 7, 12]
def test_quick_sort_empty_array():
    arr = []
    n = len(arr)
    expected = []
    actual = quick_sort(arr, 0, n - 1)
    assert actual == expected
def test_nearly_sorted():
    assert quick_sort([2, 3, 5, 7, 13, 11], 0, 5) == [2, 3, 5, 7, 11, 13]
def test_quick_sort_array():
    arr = [50, 10, 5, 20, 15, 30, 45, 40, 35, 25]
    n = len(arr)
    expected = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]
    actual = quick_sort(arr, 0, n - 1)
    assert actual == expected
예제 #10
0
def test_quick_sort_1(fixed_array1):
    r = len(fixed_array1) - 1
    quick_sort(fixed_array1, 0, r)
    assert fixed_array1 == [-2, 5, 8, 12, 18, 20]
예제 #11
0
def test_quick_sort_3(fixed_array3):
    r = len(fixed_array3) - 1
    quick_sort(fixed_array3, 0, r)
    assert fixed_array3 == [2, 3, 5, 7, 11, 13]
예제 #12
0
def test_quick_sort_2(fixed_array2):
    r = len(fixed_array2) - 1
    quick_sort(fixed_array2, 0, r)
    assert fixed_array2 == [5, 5, 5, 7, 7, 12]
예제 #13
0

def test_quick_sort_3(fixed_array3):
    r = len(fixed_array3) - 1
    quick_sort(fixed_array3, 0, r)
    assert fixed_array3 == [2, 3, 5, 7, 11, 13]


@pytest.fixture
def fixed_array1():
    bt = [20, 18, 12, 8, 5, -2]
    return bt


@pytest.fixture
def fixed_array2():
    bt = [5, 12, 7, 5, 5, 7]
    return bt


@pytest.fixture
def fixed_array3():
    bt = [2, 3, 5, 7, 13, 11]
    return bt


aa = [8, 4, 23, 42, 16, 15]
bb = len(aa) - 1
quick_sort(aa, 0, bb)

print(aa)