-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsort4test.py
More file actions
executable file
·34 lines (26 loc) · 872 Bytes
/
sort4test.py
File metadata and controls
executable file
·34 lines (26 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from sort4 import selection_sort
import nose
def run_test(original, expected):
'''Sort list original and compare it to list expected.'''
selection_sort(original)
assert original == expected
def test_empty():
'''Test sorting empty list.'''
run_test([], [])
def test_one():
'''Test sorting a list of one value.'''
run_test([1], [1])
def test_two_ordered():
'''Test sorting an already-sorted list of two values.'''
run_test([1, 2], [1, 2])
def test_two_reversed():
'''Test sorting a reverse-ordered list of two values.'''
run_test([2, 1], [1, 2])
def test_three_identical():
'''Test sorting a list of three equal values.'''
run_test([3, 3, 3], [3, 3, 3])
def test_three_split():
'''Test sorting a list with an odd value out.'''
run_test([3, 0, 3], [0, 3, 3])
if __name__ == '__main__':
nose.runmodule()