コード例 #1
0
  @Test
  public void testFailedValidation() {
    String firstValue = "-1";
    String secondValue = "0";
    String thirdValue = "2";

    assertFalse(validator.isValid(firstValue));
    assertFalse(validator.isValid(secondValue));
    assertFalse(validator.isValid(thirdValue));
  }
コード例 #2
0
  @Test
  public void testSuccessfulValidation() {
    int[] powerValues = {0, 1, 2, 3};
    int[] multipliers = {1, 5};

    int base = 10;

    for (int multiplier : multipliers) {
      for (int power : powerValues) {
        int value = (int) (multiplier * Math.pow(base, power));

        assertTrue(validator.isValid(Integer.toString(value)));
      }
    }
  }