### Question:
Utils { public static int myBinarySearch(int[] indices, int key, int begin, int end) { if (indices.length == 0 || begin == end) { return -1; } end--; int mid = begin; while (begin <= end) { mid = (end + begin) >> 1; if (indices[mid] < key) { begin = mid + 1; } else if (indices[mid] > key) { end = mid - 1; } else { return mid; } } if (indices[mid] < key) { return -mid-2; } else { return -mid-1; } }  static int binarySearch(int[] index, int key, int begin, int end); static int myBinarySearch(int[] indices, int key, int begin, int end);  }### Answer:
@Test public void testMyBinarySearch() { System.out.println("binarySearch"); int[] index = {10, 11, 12, 13, 14}; int key = 12; int begin = 0; int end = 5; int expResult = 2; int result = Utils.myBinarySearch(index, key, begin, end); assertEquals(expResult, result); }
@Test public void testMyBinaryLast() { System.out.println("binarySearch"); int[] index = {10, 11, 12, 13, 14}; int key = 14; int begin = 0; int end = 5; int expResult = 4; int result = Utils.myBinarySearch(index, key, begin, end); assertEquals(expResult, result); }
@Test public void testMyBinarySearchNotFound() { System.out.println("binarySearch"); int[] index = {10, 13, 15, 17, 19}; int key = 16; int begin = 0; int end = 5; int expResult = -4; int result = Utils.myBinarySearch(index, key, begin, end); assertEquals(expResult, result); }
@Test public void testMissingBeforeFirst() { System.out.println("binarySearch"); int[] index = {10, 13, 15, 17, 19}; int key = 8; int begin = 0; int end = 5; int expResult = -1; int result = Utils.myBinarySearch(index, key, begin, end); assertEquals(expResult, result); }
@Test public void testMissingBeforeSecond() { System.out.println("binarySearch"); int[] index = {10, 13, 15, 17, 19}; int key = 11; int begin = 0; int end = 5; int expResult = -2; int result = Utils.myBinarySearch(index, key, begin, end); assertEquals(expResult, result); }
@Test public void testMissingAfterLast() { System.out.println("binarySearch"); int[] index = {10, 13, 15, 17, 19}; int key = 25; int begin = 0; int end = 5; int expResult = -6; int result = Utils.myBinarySearch(index, key, begin, end); assertEquals(expResult, result); }
@Test public void testMissingAfterSecondLast() { System.out.println("binarySearch"); int[] index = {10, 13, 15, 17, 19}; int key = 18; int begin = 0; int end = 5; int expResult = -5; int result = Utils.myBinarySearch(index, key, begin, end); assertEquals(expResult, result); }