@Test public void shouldReturnNegativeIntForNullArray() { String errorMsg = "response not a negative int"; int position = positionFinder.getPosition(null, 3); assertTrue(errorMsg, position < 0); }
private void assertMidPointIsAsExpected(int low, int high, int expectedMidPoint) { String errorMsg = "midpoint not as expected"; int actualMidPoint; actualMidPoint = positionFinder.getMidPoint(low, high); assertEquals(errorMsg, expectedMidPoint, actualMidPoint); }
@Test public void shouldReturnNegativePositionIfValueDoesNotExistInArray() { String errorMsg = "position is not less than 0"; int[] valueArray = {1, 2, 3, 4, 5}; int position = positionFinder.getPosition(valueArray, 9); assertTrue(errorMsg, position < 0); }
@Test public void shouldReturnPositivePositionIfValueExistInArray() { String errorMsg = "position is not greater than 0"; int[] valueArray = {1, 2, 3, 4, 5}; int position = positionFinder.getPosition(valueArray, 3); assertTrue(errorMsg, position > 0); }
@Test public void shouldReturnHighGivenArray() { String errorMsg = "midpoint not as expected"; int[] valueArray = {1, 2, 3, 4, 5}; int high = positionFinder.getHigh(valueArray); assertEquals(errorMsg, 4, high); }
private void assertPositionIsAsExpected(int[] valueArray, int value, int expectedPosition) { String errorMsg = "position not as expected"; int actualPosition = positionFinder.getPosition(valueArray, value); assertEquals(errorMsg, expectedPosition, actualPosition); }