Example #1
0
 def test_normalRandomEvenInputListPresent(self):
     for i in range(10):
         randValue = random.randint(1, 100)
         inputList = list(range(1, 101))
         self.assertEqual(
             inputList.index(randValue),
             binarySearch.binarySearchWithIndex(inputList, randValue))
Example #2
0
 def test_normalOddInputListPresent(self):
     self.assertEqual(
         0, binarySearch.binarySearchWithIndex([0, 1, 2, 3, 4], 0))
Example #3
0
 def test_normalOddInputListAbsent(self):
     self.assertEqual(
         -1, binarySearch.binarySearchWithIndex([0, 1, 2, 3, 4], 5))
Example #4
0
 def test_normalEvenInputListAbsent(self):
     self.assertEqual(-1, binarySearch.binarySearchWithIndex([0, 1, 2, 3],
                                                             4))
Example #5
0
 def test_normalWithIndexSingletonListValuePresent(self):
     self.assertEqual(0, binarySearch.binarySearchWithIndex([1], 1))
Example #6
0
 def test_normalWithIndexSingletonListValueAbsent(self):
     self.assertEqual(-1, binarySearch.binarySearchWithIndex([0], 1))
Example #7
0
 def test_normalWithIndexEmptyList(self):
     self.assertEqual(-1, binarySearch.binarySearchWithIndex([], 1))