示例#1
0
def test_insertion_sort_nearly_sorted():
    arr = [2, 3, 5, 7, 13, 11]
    expected = [2, 3, 5, 7, 11, 13]
    actual = insertion_sort(arr)
    assert actual == expected
示例#2
0
def test_insertion_sort_simple():
    arr = [8, 4, 23, 42, 16, 15]
    expected = [4, 8, 15, 16, 23, 42]
    actual = insertion_sort(arr)
    assert actual == expected
示例#3
0
def test_insertion_sort_reverse():
    arr = [20, 18, 12, 8, 5, -2]
    expected = [-2, 5, 8, 12, 18, 20]
    actual = insertion_sort(arr)
    assert actual == expected
示例#4
0
def test_insertion_sort_few_unique():
    arr = [5, 12, 7, 5, 5, 7]
    expected = [5, 5, 5, 7, 7, 12]
    actual = insertion_sort(arr)
    assert actual == expected
示例#5
0
def test_already_sorted():
    array = [1, 2, 3, 4, 5]
    test = insertion_sort(array)
    assert test == [1, 2, 3, 4, 5]
示例#6
0
def test_insertion_sort_empty():
    array = []
    test = insertion_sort(array)
    assert test == []
示例#7
0
def test_insertion_sort_single():
    array = [1]
    test = insertion_sort(array)
    assert test == [1]
示例#8
0
def test_insertion_sort_duplicates():
    array = [1, 5, 4, 3, 2, 1]
    test = insertion_sort(array)
    assert test == [1, 1, 2, 3, 4, 5]
示例#9
0
def test_insertion_sort():
    array = [5, 4, 3, 2, 1]
    test = insertion_sort(array)
    assert test == [1, 2, 3, 4, 5]