-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
22 lines (15 loc) · 877 Bytes
/
test.py
File metadata and controls
22 lines (15 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import unittest
from binary_search import BinarySearch
class BinarySearchTest(unittest.TestCase):
def setUp(self):
self.BinS = BinarySearch([11, 19, 27, 33, 42, 57, 63, 76, 81, 93, 99]) #pass the list while creating the object
def tearDown(self):
pass
def test_binary_search_found(self):
self.assertEqual(self.BinS.binary_search(27), 2) #random element
self.assertEqual(self.BinS.binary_search(11), 0) #first element
self.assertEqual(self.BinS.binary_search(99),10) #last element
def test_binary_search_notFound(self):
self.assertEqual(self.BinS.binary_search(53), -1) #test for element which is not in the set
if __name__ == '__main__':
unittest.main()