@Test public void checkIntRange_whenValuesInFloatRange_shouldReturnEmptyList() { BaseValidator.ValidationContext context = BaseValidator.getValidationContext(String.class); assertThat(BaseValidator.checkFloatRange(context, 10d, -1.0d, 10d)).isEmpty(); assertThat(BaseValidator.checkFloatRange(context, 10d, -1.0d, 11d)).isEmpty(); assertThat(BaseValidator.checkFloatRange(context, -1d, -1d, 11d)).isEmpty(); assertThat(BaseValidator.checkFloatRange(context, -1d, Double.NEGATIVE_INFINITY, 11d)).isEmpty(); assertThat(BaseValidator.checkFloatRange(context, -1d, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY)) .isEmpty(); assertThat(BaseValidator.checkFloatRange(context, -1d, -10d, Double.POSITIVE_INFINITY)).isEmpty(); assertThat(BaseValidator.checkFloatRange(context, Double.POSITIVE_INFINITY, -10d, Double.POSITIVE_INFINITY)) .isEmpty(); assertThat(BaseValidator.checkFloatRange(context, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY)).isEmpty(); }
@Test public void checkIntRange_whenValuesNotInFloatRange_shouldReturnError() { BaseValidator.ValidationContext context = BaseValidator.getValidationContext(String.class); assertThat(BaseValidator.checkFloatRange(context, -10d, -1d, 10d)).isNotEmpty(); assertThat(BaseValidator.checkFloatRange(context, 12d, -1d, 11d)).isNotEmpty(); List<RaveError> errors = BaseValidator.checkFloatRange(context, 12d, -1d, 11d); assertThat(errors).hasSize(1); assertThat(errors.get(0).getErrorMsg()).contains(RaveErrorStrings.FLOAT_RANGE_ERROR); }