コード例 #1
0
  @Test
  public void shouldReturnNegativeIntForNullArray() {
    String errorMsg = "response not a negative int";

    int position = positionFinder.getPosition(null, 3);
    assertTrue(errorMsg, position < 0);
  }
コード例 #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);
  }
コード例 #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);
  }
コード例 #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);
  }
コード例 #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);
  }
コード例 #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);
  }