Skip to content

Commit 2c60393

Browse files
committed
implemented heap sort unittest
1 parent 14fed29 commit 2c60393

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import unittest
2+
from classical_algorithms.python.heapsort import heapSort
3+
4+
class TestHeapSort(unittest.TestCase):
5+
def test_heap_sort(self):
6+
7+
print('None Input')
8+
self.assertRaises(TypeError, heapSort, None)
9+
10+
print('Empty Input')
11+
self.assertEqual(heapSort([]), [])
12+
13+
print('One Element')
14+
self.assertEqual(heapSort([13]), [13])
15+
16+
print('Multipe nElements')
17+
test_array = [-23,-1,0,1,10,-10,1000, 2]
18+
solution_array = [-23,-10,-1,0,1,2,10,1000]
19+
20+
self.assertEqual(heapSort(test_array), solution_array)
21+
22+
print('Successful test_heap_sort\n')
23+
24+
25+
if __name__=='__main__':
26+
unittest.main()

0 commit comments

Comments
 (0)