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