This is an automated email from the ASF dual-hosted git repository. garydgregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-validator.git
commit 774b017f35dc88baa510002bac3023c4c5c66fdc Author: Gary Gregory <[email protected]> AuthorDate: Sat Jul 11 07:39:37 2026 -0400 Sort members --- .../routines/BigIntegerValidatorTest.java | 46 +++++++++++----------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/test/java/org/apache/commons/validator/routines/BigIntegerValidatorTest.java b/src/test/java/org/apache/commons/validator/routines/BigIntegerValidatorTest.java index 431c334f..af2e6a03 100644 --- a/src/test/java/org/apache/commons/validator/routines/BigIntegerValidatorTest.java +++ b/src/test/java/org/apache/commons/validator/routines/BigIntegerValidatorTest.java @@ -197,29 +197,6 @@ class BigIntegerValidatorTest extends AbstractNumberValidatorTest { assertFalse(instance.minValue(belowMin, Long.MAX_VALUE)); } - /** - * The {@link Number} overloads must compare against the exact bound. A non-integer bound was converted with BigInteger.toBigInteger(), which truncates - * towards zero, so a fractional minimum was floored (wrongly admitting a value below it) and a fractional maximum was floored too (wrongly admitting a value - * above a negative maximum). - */ - @Test - void testNumberRangeFractionalBound() { - final AbstractNumberValidator instance = BigIntegerValidator.getInstance(); - final Number five = BigInteger.valueOf(5); - // 5 >= 5.9 is false, but flooring the bound to 5 made it pass - assertFalse(instance.minValue(five, Double.valueOf(5.9))); - assertFalse(instance.minValue(five, new BigDecimal("5.9"))); - // a whole-number bound is unaffected - assertTrue(instance.minValue(five, BigInteger.valueOf(5))); - - final Number minusFive = BigInteger.valueOf(-5); - // -5 <= -5.9 is false, but flooring the bound to -5 made it pass - assertFalse(instance.maxValue(minusFive, Double.valueOf(-5.9))); - assertFalse(instance.maxValue(minusFive, new BigDecimal("-5.9"))); - // -6 <= -5.9 is true - assertTrue(instance.maxValue(BigInteger.valueOf(-6), Double.valueOf(-5.9))); - } - /** * A {@link Float} bound must be compared at its real magnitude. The bound is converted through {@link AbstractNumberValidator#toBigDecimal}, which had no * {@code Float} branch, so a {@code Float} fell through to {@code new BigDecimal(value.toString())}; {@code Float.toString} emits only the digits needed to @@ -254,6 +231,29 @@ class BigIntegerValidatorTest extends AbstractNumberValidatorTest { assertFalse(instance.minValue(negBelow, negBound), "value below the real negative float is below the minimum"); } + /** + * The {@link Number} overloads must compare against the exact bound. A non-integer bound was converted with BigInteger.toBigInteger(), which truncates + * towards zero, so a fractional minimum was floored (wrongly admitting a value below it) and a fractional maximum was floored too (wrongly admitting a value + * above a negative maximum). + */ + @Test + void testNumberRangeFractionalBound() { + final AbstractNumberValidator instance = BigIntegerValidator.getInstance(); + final Number five = BigInteger.valueOf(5); + // 5 >= 5.9 is false, but flooring the bound to 5 made it pass + assertFalse(instance.minValue(five, Double.valueOf(5.9))); + assertFalse(instance.minValue(five, new BigDecimal("5.9"))); + // a whole-number bound is unaffected + assertTrue(instance.minValue(five, BigInteger.valueOf(5))); + + final Number minusFive = BigInteger.valueOf(-5); + // -5 <= -5.9 is false, but flooring the bound to -5 made it pass + assertFalse(instance.maxValue(minusFive, Double.valueOf(-5.9))); + assertFalse(instance.maxValue(minusFive, new BigDecimal("-5.9"))); + // -6 <= -5.9 is true + assertTrue(instance.maxValue(BigInteger.valueOf(-6), Double.valueOf(-5.9))); + } + /** * A non-finite {@link Double} bound must not be routed through {@link BigDecimal}, which cannot represent {@code NaN} or an infinity. The {@link Number} * overloads previously converted every bound to a {@code BigDecimal} and so threw {@code NumberFormatException} for such a bound, whereas the sibling
