|
| 1 | +from bogo_sort import bogo_sort |
| 2 | +from bubble_sort import bubble_sort |
| 3 | +from bucket_sort import bucket_sort |
| 4 | +from cocktail_shaker_sort import cocktail_shaker_sort |
| 5 | +from comb_sort import comb_sort |
| 6 | +from counting_sort import counting_sort |
| 7 | +from cycle_sort import cycle_sort |
| 8 | +from gnome_sort import gnome_sort |
| 9 | +from heap_sort import heap_sort |
| 10 | +from insertion_sort import insertion_sort |
| 11 | +from merge_sort_fastest import merge_sort as merge_sort_fastest |
| 12 | +from merge_sort import merge_sort |
| 13 | +from pancake_sort import pancake_sort |
| 14 | +from quick_sort_3_partition import quick_sort_3partition |
| 15 | +from quick_sort import quick_sort |
| 16 | +from radix_sort import radix_sort |
| 17 | +from random_pivot_quick_sort import quick_sort_random |
| 18 | +from selection_sort import selection_sort |
| 19 | +from shell_sort import shell_sort |
| 20 | +from tim_sort import tim_sort |
| 21 | +from topological_sort import topological_sort |
| 22 | +from tree_sort import tree_sort |
| 23 | +from wiggle_sort import wiggle_sort |
| 24 | + |
| 25 | + |
| 26 | +TEST_CASES = [ |
| 27 | + {'input': [8, 7, 6, 5, 4, 3, -2, -5], 'expected': [-5, -2, 3, 4, 5, 6, 7, 8]}, |
| 28 | + {'input': [-5, -2, 3, 4, 5, 6, 7, 8], 'expected': [-5, -2, 3, 4, 5, 6, 7, 8]}, |
| 29 | + {'input': [5, 6, 1, 4, 0, 1, -2, -5, 3, 7], 'expected': [-5, -2, 0, 1, 1, 3, 4, 5, 6, 7]}, |
| 30 | + {'input': [2, -2], 'expected': [-2, 2]}, |
| 31 | + {'input': [1], 'expected': [1]}, |
| 32 | + {'input': [], 'expected': []}, |
| 33 | +] |
| 34 | + |
| 35 | +''' |
| 36 | + TODO: |
| 37 | + - Fix some broken tests in particular cases (as [] for example), |
| 38 | + - Unify the input format: should always be function(input_collection) (no additional args) |
| 39 | + - Unify the output format: should always be a collection instead of updating input elements |
| 40 | + and returning None |
| 41 | + - Rewrite some algorithms in function format (in case there is no function definition) |
| 42 | +''' |
| 43 | + |
| 44 | +TEST_FUNCTIONS = [ |
| 45 | + bogo_sort, |
| 46 | + bubble_sort, |
| 47 | + bucket_sort, |
| 48 | + cocktail_shaker_sort, |
| 49 | + comb_sort, |
| 50 | + counting_sort, |
| 51 | + cycle_sort, |
| 52 | + gnome_sort, |
| 53 | + heap_sort, |
| 54 | + insertion_sort, |
| 55 | + merge_sort_fastest, |
| 56 | + merge_sort, |
| 57 | + pancake_sort, |
| 58 | + quick_sort_3partition, |
| 59 | + quick_sort, |
| 60 | + radix_sort, |
| 61 | + quick_sort_random, |
| 62 | + selection_sort, |
| 63 | + shell_sort, |
| 64 | + tim_sort, |
| 65 | + topological_sort, |
| 66 | + tree_sort, |
| 67 | + wiggle_sort, |
| 68 | +] |
| 69 | + |
| 70 | + |
| 71 | +for function in TEST_FUNCTIONS: |
| 72 | + for case in TEST_CASES: |
| 73 | + result = function(case['input']) |
| 74 | + assert result == case['expected'], 'Executed function: {}, {} != {}'.format(function.__name__, result, case['expected']) |
0 commit comments