コード例 #1
0
  @Test
  public void testSearchKeyCase4() {

    int[] arr = {6, 7, 1, 2, 3, 4, 5};
    int key = 5;

    int actual = RotatedSortedArraySearch.searchKey(arr, key);
    int expected = 6;
    assertEquals(actual, expected);
  }
コード例 #2
0
  @Test
  public void testSearchKeyNotExists() {

    int[] arr = {7, 1, 2, 3, 4, 5, 6};
    int key = 0;

    int actual = RotatedSortedArraySearch.searchKey(arr, key);
    int expected = -1;
    assertEquals(actual, expected);
  }