-
Notifications
You must be signed in to change notification settings - Fork 0
/
testing.py
47 lines (30 loc) · 1.01 KB
/
testing.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import unittest
from binarySearch import binarySearchUpper
class binarySearchTest(unittest.TestCase):
def test_01(self):
alist = [1, 3, 6, 10, 15]
item = 1
itemIndexFound = binarySearchUpper(alist, item)
self.assertEqual(itemIndexFound, 0)
def test_02(self):
alist = [1, 3, 6, 10, 15]
item = 3
itemIndexFound = binarySearchUpper(alist, item)
self.assertEqual(itemIndexFound, 1)
def test_03(self):
alist = [1, 3, 6, 10, 15]
item = 5
itemIndexFound = binarySearchUpper(alist, item)
self.assertEqual(itemIndexFound, 2)
def test_04(self):
alist = [1, 3, 6, 10, 15]
item = 2
itemIndexFound = binarySearchUpper(alist, item)
self.assertEqual(itemIndexFound, 1)
def test_05(self):
alist = [1, 3, 6, 10, 15]
item = 20
itemIndexFound = binarySearchUpper(alist, item)
self.assertEqual(itemIndexFound, -1)
if __name__ == '__main__':
unittest.main()