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 961e6b11a546eccd99fe3e7897a6ae7312ee5a1d Author: Gary Gregory <[email protected]> AuthorDate: Mon Jul 20 13:03:59 2026 -0700 Sort members --- .../validator/GenericTypeValidatorTest.java | 48 +++++++++++----------- .../routines/checkdigit/CUSIPCheckDigitTest.java | 20 ++++----- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/test/java/org/apache/commons/validator/GenericTypeValidatorTest.java b/src/test/java/org/apache/commons/validator/GenericTypeValidatorTest.java index caf28925..ce19b80c 100644 --- a/src/test/java/org/apache/commons/validator/GenericTypeValidatorTest.java +++ b/src/test/java/org/apache/commons/validator/GenericTypeValidatorTest.java @@ -100,6 +100,18 @@ class GenericTypeValidatorTest extends AbstractCommonTest { protected void tearDown() { } + /** + * Tests that {@link GenericTypeValidator#formatByte(String, Locale)} rejects a fractional value instead of truncating it. A value written with a negative + * exponent and no decimal point (for example "15E-1" for 1.5) is consumed in full by the integer-only format and used to be floored to a non-null result, + * unlike {@link GenericTypeValidator#formatLong(String, Locale)}. + */ + @Test + void testByteLocaleFractional() { + assertNull(GenericTypeValidator.formatByte("15E-1", Locale.US)); + assertNull(GenericTypeValidator.formatByte("5E-1", Locale.US)); + assertEquals(Byte.valueOf((byte) 100), GenericTypeValidator.formatByte("1E2", Locale.US)); + } + /** * Tests that strict {@link GenericTypeValidator#formatDate(String, String, boolean)} rejects a value with trailing characters instead of parsing only its * leading portion. @@ -134,6 +146,18 @@ class GenericTypeValidatorTest extends AbstractCommonTest { assertEquals(129, ((Double) map.get("double")).intValue(), "double value not correct"); } + /** + * Tests that {@link GenericTypeValidator#formatInt(String, Locale)} rejects a fractional value instead of truncating it. A value written with a negative + * exponent and no decimal point (for example "15E-1" for 1.5) is consumed in full by the integer-only format and used to be floored to a non-null result, + * unlike {@link GenericTypeValidator#formatLong(String, Locale)}. + */ + @Test + void testIntLocaleFractional() { + assertNull(GenericTypeValidator.formatInt("15E-1", Locale.US)); + assertNull(GenericTypeValidator.formatInt("5E-1", Locale.US)); + assertEquals(Integer.valueOf(100), GenericTypeValidator.formatInt("1E2", Locale.US)); + } + /** * Tests that {@link GenericTypeValidator#formatLong(String, Locale)} rejects values just outside the long range instead of clamping them. */ @@ -148,18 +172,6 @@ class GenericTypeValidatorTest extends AbstractCommonTest { assertNull(GenericTypeValidator.formatLong("123x", Locale.US)); } - /** - * Tests that {@link GenericTypeValidator#formatByte(String, Locale)} rejects a fractional value instead of truncating it. A value written with a negative - * exponent and no decimal point (for example "15E-1" for 1.5) is consumed in full by the integer-only format and used to be floored to a non-null result, - * unlike {@link GenericTypeValidator#formatLong(String, Locale)}. - */ - @Test - void testByteLocaleFractional() { - assertNull(GenericTypeValidator.formatByte("15E-1", Locale.US)); - assertNull(GenericTypeValidator.formatByte("5E-1", Locale.US)); - assertEquals(Byte.valueOf((byte) 100), GenericTypeValidator.formatByte("1E2", Locale.US)); - } - /** * Tests that {@link GenericTypeValidator#formatShort(String, Locale)} rejects a fractional value instead of truncating it. A value written with a negative * exponent and no decimal point (for example "15E-1" for 1.5) is consumed in full by the integer-only format and used to be floored to a non-null result, @@ -172,18 +184,6 @@ class GenericTypeValidatorTest extends AbstractCommonTest { assertEquals(Short.valueOf((short) 100), GenericTypeValidator.formatShort("1E2", Locale.US)); } - /** - * Tests that {@link GenericTypeValidator#formatInt(String, Locale)} rejects a fractional value instead of truncating it. A value written with a negative - * exponent and no decimal point (for example "15E-1" for 1.5) is consumed in full by the integer-only format and used to be floored to a non-null result, - * unlike {@link GenericTypeValidator#formatLong(String, Locale)}. - */ - @Test - void testIntLocaleFractional() { - assertNull(GenericTypeValidator.formatInt("15E-1", Locale.US)); - assertNull(GenericTypeValidator.formatInt("5E-1", Locale.US)); - assertEquals(Integer.valueOf(100), GenericTypeValidator.formatInt("1E2", Locale.US)); - } - /** * Tests the byte validation. */ diff --git a/src/test/java/org/apache/commons/validator/routines/checkdigit/CUSIPCheckDigitTest.java b/src/test/java/org/apache/commons/validator/routines/checkdigit/CUSIPCheckDigitTest.java index 5b456124..6d0fc239 100644 --- a/src/test/java/org/apache/commons/validator/routines/checkdigit/CUSIPCheckDigitTest.java +++ b/src/test/java/org/apache/commons/validator/routines/checkdigit/CUSIPCheckDigitTest.java @@ -53,6 +53,16 @@ class CUSIPCheckDigitTest extends AbstractCheckDigitTest { invalid = cloneInvalid(); } + /** + * A CUSIP is exactly nine characters. Prepending a zero to a valid code lands on a position weighted zero, so the + * modulus was unaffected and the over-length code validated. + */ + @ParameterizedTest + @ValueSource(strings = { "0037833100", "0931142103" }) + void testOverLengthRejected(final String code) { + assertFalse(routine.isValid(code), "Should fail (not nine characters): " + code); + } + @ParameterizedTest @MethodSource("org.apache.commons.validator.routines.checkdigit.CUSIPCheckDigitTest#cloneInvalid") void testValidator336InvalidCheckDigits(final String invalidCheckDigit) { @@ -64,14 +74,4 @@ class CUSIPCheckDigitTest extends AbstractCheckDigitTest { void testValidator336ValidCheckDigits(final String validCheckDigit) { assertTrue(routine.isValid(validCheckDigit), "Should fail: " + validCheckDigit); } - - /** - * A CUSIP is exactly nine characters. Prepending a zero to a valid code lands on a position weighted zero, so the - * modulus was unaffected and the over-length code validated. - */ - @ParameterizedTest - @ValueSource(strings = { "0037833100", "0931142103" }) - void testOverLengthRejected(final String code) { - assertFalse(routine.isValid(code), "Should fail (not nine characters): " + code); - } }
