Fixing NumberUtils.isNumber so that 1.1L is not considered a number. LANG-664
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1054202 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7df70a8c6b
commit
8e2f4ddb9a
|
@ -1409,8 +1409,8 @@ public class NumberUtils {
|
||||||
}
|
}
|
||||||
if (chars[i] == 'l'
|
if (chars[i] == 'l'
|
||||||
|| chars[i] == 'L') {
|
|| chars[i] == 'L') {
|
||||||
// not allowing L with an exponent
|
// not allowing L with an exponent or decimal point
|
||||||
return foundDigit && !hasExp;
|
return foundDigit && !hasExp && !hasDecPoint;
|
||||||
}
|
}
|
||||||
// last character is illegal
|
// last character is illegal
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1139,6 +1139,10 @@ public class NumberUtilsTest extends TestCase {
|
||||||
// LANG-521
|
// LANG-521
|
||||||
val = "2.";
|
val = "2.";
|
||||||
assertTrue("isNumber(String) LANG-521 failed", NumberUtils.isNumber(val));
|
assertTrue("isNumber(String) LANG-521 failed", NumberUtils.isNumber(val));
|
||||||
|
|
||||||
|
// LANG-664
|
||||||
|
val = "1.1L";
|
||||||
|
assertFalse("isNumber(String) LANG-664 failed", NumberUtils.isNumber(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkCreateNumber(String val) {
|
private boolean checkCreateNumber(String val) {
|
||||||
|
|
Loading…
Reference in New Issue