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))
def test_normalOddInputListPresent(self): self.assertEqual( 0, binarySearch.binarySearchWithIndex([0, 1, 2, 3, 4], 0))
def test_normalOddInputListAbsent(self): self.assertEqual( -1, binarySearch.binarySearchWithIndex([0, 1, 2, 3, 4], 5))
def test_normalEvenInputListAbsent(self): self.assertEqual(-1, binarySearch.binarySearchWithIndex([0, 1, 2, 3], 4))
def test_normalWithIndexSingletonListValuePresent(self): self.assertEqual(0, binarySearch.binarySearchWithIndex([1], 1))
def test_normalWithIndexSingletonListValueAbsent(self): self.assertEqual(-1, binarySearch.binarySearchWithIndex([0], 1))
def test_normalWithIndexEmptyList(self): self.assertEqual(-1, binarySearch.binarySearchWithIndex([], 1))