示例#1
0
 def test_with_empty_data(self):
     self.assertEqual(-1, solve_iteratively([], 5))
示例#2
0
 def test_with_one_element_data_and_missing_key(self):
     self.assertEqual(-1, solve_iteratively([3], 5))
示例#3
0
 def test_with_all_duplicate_elements_and_equal_key(self):
     self.assertEqual(4, solve_iteratively([3, 3, 3, 3, 3, 3, 3, 3, 3, 3],
                                           3))
示例#4
0
 def test_with_all_duplicate_elements_and_greater_key(self):
     self.assertEqual(-1,
                      solve_iteratively([3, 3, 3, 3, 3, 3, 3, 3, 3, 3], 5))
示例#5
0
 def test_with_key_as_one_of_duplicates(self):
     self.assertEqual(4, solve_iteratively([0, 1, 2, 4, 4, 4, 4, 7, 8, 9],
                                           4))
示例#6
0
 def test_with_several_element_data_with_duplicates_and_present_key(self):
     self.assertEqual(2, solve_iteratively([5, -7, 3, 0, 9, -1, 9], 0))
示例#7
0
 def test_with_several_element_data_with_duplicates_and_missing_key(self):
     self.assertEqual(-1, solve_iteratively([5, -7, 3, 0, 9, -1, 9], 4))
示例#8
0
 def test_with_three_element_data_and_present_key(self):
     self.assertEqual(0, solve_iteratively([1, 2, 3], 1))
     self.assertEqual(1, solve_iteratively([1, 2, 3], 2))
     self.assertEqual(2, solve_iteratively([1, 2, 3], 3))
示例#9
0
 def test_with_one_element_data_and_present_key(self):
     self.assertEqual(0, solve_iteratively([5], 5))