示例#1
0
文件: test.py 项目: mozartc/detector
 def test_bsearch_trivial(self):
     arr = [10, 20, 30, 40, 50]
     indx = prepaire.bsearch(arr, 35, 0, len(arr) - 1)
     self.assertEqual(2, indx)
示例#2
0
文件: test.py 项目: mozartc/detector
 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)
示例#3
0
文件: test.py 项目: mozartc/detector
 def test_bsearch_interval(self):
     arr = [10, 20, 30, 40, 50]
     indx = prepaire.bsearch(arr, 35, 0, 1)
     self.assertEqual(1, indx)
示例#4
0
文件: test.py 项目: mozartc/detector
 def test_bsearch_duplicate(self):
     arr = [10, 20, 30, 40, 50]
     indx = prepaire.bsearch(arr, 30, 0, len(arr) - 1)
     self.assertEqual(2, indx)
示例#5
0
文件: test.py 项目: mozartc/detector
 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)
示例#6
0
 def test_bsearch_trivial(self):
     arr = [10, 20, 30, 40, 50]
     indx = prepaire.bsearch(arr, 35, 0, len(arr)-1)
     self.assertEqual(2, indx)
示例#7
0
 def test_bsearch_interval(self):
     arr = [10, 20, 30, 40, 50]
     indx = prepaire.bsearch(arr, 35, 0, 1)
     self.assertEqual(1, indx)
示例#8
0
 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)
示例#9
0
 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)
示例#10
0
 def test_bsearch_duplicate(self):
     arr = [10, 20, 30, 40, 50]
     indx = prepaire.bsearch(arr, 30, 0, len(arr)-1)
     self.assertEqual(2, indx)