pygorithm/test/test_sort.py

22 lines
649 B
Python
Raw Normal View History

2023-12-11 18:17:16 +08:00
from sort.quick_sort import *
from sort.insert_sort import *
from sort.merge_sort import *
def test_quick_sort():
nums = [47, 29, 71, 99, 78, 19, 24, 47]
assert [19, 24, 29, 47, 47, 71, 78, 99] == quick_sort(nums, 0, len(nums) - 1)
def test_insert_sort1():
nums = [47, 29, 71, 99, 78, 19, 24, 47]
assert [19, 24, 29, 47, 47, 71, 78, 99] == insert_sort(nums)
def test_insert_sort2():
nums = [47, 29, 71, 99, 78, 19, 24, 47]
assert [19, 24, 29, 47, 47, 71, 78, 99] == bin_insert_sort(nums)
def test_merge_sort():
nums = [47, 29, 71, 99, 78, 19, 24, 47]
assert [19, 24, 29, 47, 47, 71, 78, 99] == merge_sort(nums)