Ejemplo n.º 1
0
  @Test
  public void shouldReturnNegativeIntForNullArray() {
    String errorMsg = "response not a negative int";

    int position = positionFinder.getPosition(null, 3);
    assertTrue(errorMsg, position < 0);
  }
Ejemplo n.º 2
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);
  }
Ejemplo n.º 3
0
  @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);
  }
Ejemplo n.º 4
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);
  }
Ejemplo n.º 5
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);
  }
Ejemplo n.º 6
0
  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);
  }