Ejemplo n.º 1
0
    def test_binarySearchFindsElementsInListWithSizeOfOne(self):
        what = 1
        where = [1]

        foundIdx = binarySearch(where=where, what=what)

        self.assertEqual(foundIdx, where.index(what))
Ejemplo n.º 2
0
    def test_binarySearchReturnsNoneIfElementIsNotFound(self):
        what = 2
        where = [1]

        foundIdx = binarySearch(where=where, what=what)

        self.assertIsNone(foundIdx)
Ejemplo n.º 3
0
Archivo: test_main.py Proyecto: kuzb/CP
 def test_binary_search_found(self):
     ls = [
         12, 19, 49, 59, 72, 88, 108, 121, 146, 152, 168, 201, 212, 218, 223
     ]
     target = 72
     index = 4
     self.assertEqual(binarySearch(ls, target), index)
Ejemplo n.º 4
0
    def test_binarySearchFindsElementsInListWithEvenSize(self):
        size = 10
        for i in range(size):
            what = i
            where = range(size)

            foundIdx = binarySearch(where=where, what=what)

            self.assertEqual(foundIdx, where.index(what))