def test_bsearch_trivial(self): arr = [10, 20, 30, 40, 50] indx = prepaire.bsearch(arr, 35, 0, len(arr) - 1) self.assertEqual(2, indx)
def test_bsearch_corner_more(self): arr = [10, 20, 30, 40, 50] indx = prepaire.bsearch(arr, 100, 0, len(arr) - 1) self.assertEqual(4, indx)
def test_bsearch_interval(self): arr = [10, 20, 30, 40, 50] indx = prepaire.bsearch(arr, 35, 0, 1) self.assertEqual(1, indx)
def test_bsearch_duplicate(self): arr = [10, 20, 30, 40, 50] indx = prepaire.bsearch(arr, 30, 0, len(arr) - 1) self.assertEqual(2, indx)
def test_bsearch_extract(self): arr = [(10, 'a'), (20, 'a'), (30, 'a'), (40, 'a'), (50, 'a')] indx = prepaire.bsearch(arr, 35, 0, len(arr) - 1, lambda v: v[0]) self.assertEqual(2, indx)
def test_bsearch_trivial(self): arr = [10, 20, 30, 40, 50] indx = prepaire.bsearch(arr, 35, 0, len(arr)-1) self.assertEqual(2, indx)
def test_bsearch_corner_more(self): arr = [10, 20, 30, 40, 50] indx = prepaire.bsearch(arr, 100, 0, len(arr)-1) self.assertEqual(4, indx)
def test_bsearch_extract(self): arr = [(10, 'a'), (20, 'a'), (30, 'a'), (40, 'a'), (50, 'a')] indx = prepaire.bsearch(arr, 35, 0, len(arr)-1, lambda v: v[0]) self.assertEqual(2, indx)
def test_bsearch_duplicate(self): arr = [10, 20, 30, 40, 50] indx = prepaire.bsearch(arr, 30, 0, len(arr)-1) self.assertEqual(2, indx)