forked from ams-bjones/sorting
/
sorttests.py
33 lines (28 loc) · 1.17 KB
/
sorttests.py
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
import sorting
import unittest
class TestSequenceFunctions(unittest.TestCase):
def test1(self):
''' given a list, swap element 1 for the next element'''
inlist = [4,3,2,1]
outlist = [4,2,3,1]
assert (sorting.swap(inlist,1)==outlist) #test 1 fails, swap does not work as expected.
def test2(self):
'''Test 2 checks that the bubble sort can sort a list of 4 items reversed.
'''
inlist = [4,3,2,1]
outlist = [1,2,3,4]
assert (sorting.bsort(inlist)==outlist) #test 2 fails - list not sorted by bubble sort
def test3(self):
'''Test 2 checks that the bubble sort can sort a list of 4 items reversed.
'''
inlist = [4,3,2,1]
outlist = [1,2,3,4]
assert (sorting.ssort(inlist)==outlist) #test 3 fails - list not sorted by Selection sort
def test4(self):
'''Test 2 checks that the bubble sort can sort a list of 4 items reversed.
'''
inlist = [4,3,2,1]
outlist = [1,2,3,4]
assert (sorting.msort(inlist)==outlist) #test 4 fails - list not sorted by merge sort
if __name__ == '__main__':
unittest.main()