sarankumarbaskar commented on code in PR #1712:
URL: https://github.com/apache/commons-lang/pull/1712#discussion_r3428535267
##########
src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java:
##########
@@ -661,6 +661,13 @@ void testCreateNumber() {
assertEquals(Integer.decode("+0xF"), NumberUtils.createNumber("+0xF"),
"createNumber(String) LANG-1645a failed");
assertEquals(Long.decode("+0xFFFFFFFF"),
NumberUtils.createNumber("+0xFFFFFFFF"), "createNumber(String) LANG-1645b
failed");
assertEquals(new BigInteger("+FFFFFFFFFFFFFFFF", 16),
NumberUtils.createNumber("+0xFFFFFFFFFFFFFFFF"), "createNumber(String)
LANG-1645c failed");
+ // A hex literal too large for a Long but carrying an explicit 'L'/'l'
type suffix must drop the suffix
+ // before falling back to BigInteger, matching the decimal path (e.g.
"12345678901234567890L").
+ assertEquals(new BigInteger("FFFFFFFFFFFFFFFF", 16),
NumberUtils.createNumber("0xFFFFFFFFFFFFFFFFL"));
+ assertEquals(new BigInteger("FFFFFFFFFFFFFFFF", 16),
NumberUtils.createNumber("0xFFFFFFFFFFFFFFFFl"));
+ assertEquals(new BigInteger("8000000000000000", 16),
NumberUtils.createNumber("0x8000000000000000L"));
+ assertEquals(new BigInteger("-FFFFFFFFFFFFFFFF", 16),
NumberUtils.createNumber("-0xFFFFFFFFFFFFFFFFL"));
+ assertEquals(new BigInteger("FFFFFFFFFFFFFFFF", 16),
NumberUtils.createNumber("#FFFFFFFFFFFFFFFFL"));
// Map to a BigDecimal, not a Float.
Review Comment:
This looks consistent with the decimal suffix path, and the added tests fail
without the production change. One small suggestion: since the description
mentions signed forms and nearby LANG-1645 tests cover +0x..., it would give
wider coverage to add a +0xFFFFFFFFFFFFFFFFL assertion as well.
```java
assertEquals(new BigInteger("+FFFFFFFFFFFFFFFF", 16),
NumberUtils.createNumber("+0xFFFFFFFFFFFFFFFFL"));
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]