示例#1
0
 def test_sample(self):
     self.assertEqual(1, binarysearch.search([0,1,2], 1))
示例#2
0
 def test_one_element_in_list(self):
     self.assertEqual(0, binarysearch.search([1], 0))
示例#3
0
 def element_not_in_list(self):
     self.assertEqual(None, binarysearch.search([1, 2, 3], 3))
示例#4
0
 def element_in_list_of_many(self):
     self.assertEqual(1, binarysearch.search([1, 2, 3, 4], 1))
示例#5
0
 def test_lots(self):
     self.assertEqual(4, binarysearch.search([0, 5, 10, 15, 20, 25, 30, 35], 20))
示例#6
0
 def test_five(self):
     self.assertEqual(2, binarysearch.search([0, 1, 2, 3, 4], 2))
示例#7
0
 def test_none(self):
     self.assertEqual(None, binarysearch.search([], 1))
示例#8
0
 def test_words(self):
     self.assertEqual(0, binarysearch.search(["zebra", "horse"], "zebra"))
示例#9
0
 def test_beginning(self):
     self.assertEqual(0, binarysearch.search([0,1,2], 0))
示例#10
0
 def test_one(self):
     self.assertEqual(0, binarysearch.search([0], 0))
示例#11
0
 def test_end(self):
     self.assertEqual(2, binarysearch.search([0,1,2], 2))
示例#12
0
 def test_nonexistent(self):
     self.assertEqual(None, binarysearch.search([0,1,2], 666))
示例#13
0
 def test_empty(self):
     self.assertEqual(None, binarysearch.search([], 666))
示例#14
0
 def test_unit_length_list(self):
     self.assertEqual(0, binarysearch.search([666], 666))
示例#15
0
 def test_2items(self):
     self.assertEqual(1, binarysearch.search([0,1], 1))