forked from abranhe/allalgorithms-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_sorting.py
More file actions
51 lines (38 loc) · 1.52 KB
/
Copy pathtest_sorting.py
File metadata and controls
51 lines (38 loc) · 1.52 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import unittest
from allalgorithms.sorting import (
bubble_sort,
insertion_sort,
merge_sort,
selection_sort,
pigeonhole_sort,
stooge_sort,
cocktail_shaker_sort,
tree_sort,
heap_sort,
shell_sort,
)
class TestSorting(unittest.TestCase):
def test_merge_sort(self):
self.assertEqual([-44, 1, 2, 3, 7, 19], merge_sort([7, 3, 2, 19, -44, 1]))
def test_bubble_sort(self):
self.assertEqual([-44, 1, 2, 3, 7, 19], bubble_sort([7, 3, 2, 19, -44, 1]))
def test_insertion_sort(self):
self.assertEqual([-44, 1, 2, 3, 7, 19], insertion_sort([7, 3, 2, 19, -44, 1]))
def test_selection_sort(self):
self.assertEqual([-44, 1, 2, 3, 7, 19], selection_sort([7, 3, 2, 19, -44, 1]))
def test_pigeonhole_sort(self):
self.assertEqual([-44, 1, 2, 3, 7, 19], pigeonhole_sort([7, 3, 2, 19, -44, 1]))
def test_stooge_sort(self):
self.assertEqual([-44, 1, 2, 3, 7, 19], stooge_sort([7, 3, 2, 19, -44, 1]))
def test_cocktail_shaker_sort(self):
self.assertEqual([-44, 1, 2, 3, 7, 19], cocktail_shaker_sort([7, 3, 2, 19, -44, 1]))
def test_tree_sort(self):
self.assertEqual([-44, 1, 2, 3, 7, 19], tree_sort([7, 3, 2, 19, -44, 1]))
def test_heap_sort(self):
array = [7, 3, 2, 19, -44, 1]
heap_sort(array)
self.assertEqual([-44, 1, 2, 3, 7, 19], array)
def test_shell_sort(self):
self.assertEqual([-44, 1, 2, 3, 7, 19], shell_sort([7, 3, 2, 19, -44, 1]))
if __name__ == "__main__":
unittest.main()