예제 #1
0
 def test_empty_array(self):
     self.assertIsNone(rotated_array_search([], 10))
     print(rotated_array_search([], 10))  # Prints None
예제 #2
0
 def test_none(self):
     self.assertIsNone(rotated_array_search(None, 10))
     print(rotated_array_search(None, 10))  # Prints None
예제 #3
0
 def test_ordered_array_not_rotated(self):
     arr = [1, 2, 3, 4, 5]
     expected = self.linear_search(arr, 3)
     self.assertEqual(expected, rotated_array_search(arr, 3))
     print(rotated_array_search(arr, 3))  # Prints index 2
예제 #4
0
 def test_no_target_value_within_array(self):
     arr = [6, 7, 8, 1, 2, 3, 4]
     expected = self.linear_search(arr, 10)
     self.assertEqual(expected, rotated_array_search(arr, 10))
     print(rotated_array_search(
         arr, 10))  # Prints -1. No target value within array
예제 #5
0
 def test_rotated_array_search_4(self):
     arr = [6, 7, 8, 1, 2, 3, 4]
     expected = self.linear_search(arr, 1)
     self.assertEqual(expected, rotated_array_search(arr, 1))
     print(rotated_array_search(arr, 1))  # Prints index 3