def test_with_empty_data(self): self.assertEqual(-1, solve_iteratively([], 5))
def test_with_one_element_data_and_missing_key(self): self.assertEqual(-1, solve_iteratively([3], 5))
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))
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))
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))
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))
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))
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))
def test_with_one_element_data_and_present_key(self): self.assertEqual(0, solve_iteratively([5], 5))