alhudz commented on code in PR #1712:
URL: https://github.com/apache/commons-lang/pull/1712#discussion_r3434790791
##########
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:
Fair point. The `+` form runs through the same suffix-strip: the leading
sign stays on `str` and only the trailing `L` is dropped, so
`+0xFFFFFFFFFFFFFFFFL` resolves to `new BigInteger("+FFFFFFFFFFFFFFFF", 16)`
exactly like the `-0x...L` case that's already asserted. It merged before I
could fold the `+` assertion in, but happy to add it as a small follow-up if
the explicit case is wanted.
--
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]