Skip to content

Commit

Permalink
Updating tests: adding cases and todo list
Browse files Browse the repository at this point in the history
  • Loading branch information
alaouimehdi1995 committed May 5, 2019
1 parent 4d323f9 commit ed5bfaa
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion sorts/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,19 @@
{'input': [8, 7, 6, 5, 4, 3, -2, -5], 'expected': [-5, -2, 3, 4, 5, 6, 7, 8]},
{'input': [-5, -2, 3, 4, 5, 6, 7, 8], 'expected': [-5, -2, 3, 4, 5, 6, 7, 8]},
{'input': [5, 6, 1, 4, 0, 1, -2, -5, 3, 7], 'expected': [-5, -2, 0, 1, 1, 3, 4, 5, 6, 7]},
{'input': [2, -2], 'expected': [-2, 2]},
{'input': [1], 'expected': [1]},
{'input': [], 'expected': []},
]

'''
TODO:
- Fix some broken tests in particular cases (as [] for example),
- Unify the input format: should always be function(input_collection) (no additional args)
- Unify the output format: should always be a collection instead of updating input elements
and returning None
- Rewrite some algorithms in function format (in case there is no function definition)
'''

TEST_FUNCTIONS = [
bogo_sort,
Expand Down Expand Up @@ -59,4 +70,5 @@

for function in TEST_FUNCTIONS:
for case in TEST_CASES:
assert function(case['input']) == case['expected']
result = function(case['input'])
assert result == case['expected'], 'Executed function: {}, {} != {}'.format(function.__name__, result, case['expected'])

0 comments on commit ed5bfaa

Please sign in to comment.