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 2529468667858711e5327af4339b3ad765265b1d
Author: Gary Gregory <[email protected]>
AuthorDate: Fri Jun 19 17:25:44 2026 +0000

    Use compareTo() in BigIntegerValidator.minValue() (#400).
    
    Sort members.
---
 src/changes/changes.xml                            |  1 +
 .../routines/BigIntegerValidatorTest.java          | 32 +++++++++++-----------
 2 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index f9baa632..ae525924 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -83,6 +83,7 @@ The <action> type attribute can be add,update,fix,remove.
     <action type="fix" dev="ggregory" due-to="sahvx655-wq, Gary 
Gregory">Compare CAS and EC check digit against validated code, not raw input 
(#398).</action>
     <action type="fix" dev="ggregory" due-to="sahvx655-wq">Prevent URL path 
traversal bypass via percent encoding in UrlValidator (#383).</action>
     <action type="fix" dev="ggregory" due-to="sahvx655-wq">Fix ISIN 
country-code check using untrimmed input (#399).</action>
+    <action type="fix" dev="ggregory" due-to="sahvx655-wq, Gary Gregory">Use 
compareTo() in BigIntegerValidator.minValue() (#400)..</action>
     <!-- ADD -->
     <action type="add" dev="ggregory" due-to="Gary Gregory">Add and use 
CheckDigitException.CheckDigitException(String, Object...) (#389).</action>
     <action type="add" dev="ggregory" due-to="Gary Gregory">Add and use 
ValidatorException.ValidatorException(Throwable). Call sites that previously 
called new ValidatorException(Throwable#getMessage()) now preserve that 
exception (#390).</action>
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 50002c18..b3f0bc8d 100644
--- 
a/src/test/java/org/apache/commons/validator/routines/BigIntegerValidatorTest.java
+++ 
b/src/test/java/org/apache/commons/validator/routines/BigIntegerValidatorTest.java
@@ -114,22 +114,6 @@ class BigIntegerValidatorTest extends 
AbstractNumberValidatorTest {
         assertEquals(BigDecimalValidator.getInstance().validate(belowLongStr, 
"#").toBigInteger(), resultBelowLong);
     }
 
-    /**
-     * Test minValue() against bounds for values outside the long range, using 
exact BigIntegers so the comparison is not affected by double rounding.
-     */
-    @Test
-    void testMinValueOutsideLongRange() {
-        final BigIntegerValidator instance = BigIntegerValidator.getInstance();
-        final BigInteger aboveMax = 
BigInteger.valueOf(Long.MAX_VALUE).add(BigInteger.ONE);
-        final BigInteger belowMin = 
BigInteger.valueOf(Long.MIN_VALUE).subtract(BigInteger.ONE);
-        // aboveMax is greater than every long, so it is >= any long minimum
-        assertTrue(instance.minValue(aboveMax, Long.MAX_VALUE));
-        assertTrue(instance.minValue(aboveMax, Long.MIN_VALUE));
-        // belowMin is smaller than every long, so it is not >= any long 
minimum
-        assertFalse(instance.minValue(belowMin, Long.MIN_VALUE));
-        assertFalse(instance.minValue(belowMin, Long.MAX_VALUE));
-    }
-
     /**
      * Test BigInteger Range/Min/Max
      */
@@ -194,4 +178,20 @@ class BigIntegerValidatorTest extends 
AbstractNumberValidatorTest {
         assertFalse(BigIntegerValidator.getInstance().isValid(xxxx, pattern), 
"isValid(B) pattern");
         assertFalse(BigIntegerValidator.getInstance().isValid(patternVal, 
pattern, Locale.GERMAN), "isValid(B) both");
     }
+
+    /**
+     * Test minValue() against bounds for values outside the long range, using 
exact BigIntegers so the comparison is not affected by double rounding.
+     */
+    @Test
+    void testMinValueOutsideLongRange() {
+        final BigIntegerValidator instance = BigIntegerValidator.getInstance();
+        final BigInteger aboveMax = 
BigInteger.valueOf(Long.MAX_VALUE).add(BigInteger.ONE);
+        final BigInteger belowMin = 
BigInteger.valueOf(Long.MIN_VALUE).subtract(BigInteger.ONE);
+        // aboveMax is greater than every long, so it is >= any long minimum
+        assertTrue(instance.minValue(aboveMax, Long.MAX_VALUE));
+        assertTrue(instance.minValue(aboveMax, Long.MIN_VALUE));
+        // belowMin is smaller than every long, so it is not >= any long 
minimum
+        assertFalse(instance.minValue(belowMin, Long.MIN_VALUE));
+        assertFalse(instance.minValue(belowMin, Long.MAX_VALUE));
+    }
 }

Reply via email to