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:
Henri Yandell 2011-01-01 06:56:59 +00:00
parent 7df70a8c6b
commit 8e2f4ddb9a
2 changed files with 6 additions and 2 deletions

View File

@ -1409,8 +1409,8 @@ public class NumberUtils {
}
if (chars[i] == 'l'
|| chars[i] == 'L') {
// not allowing L with an exponent
return foundDigit && !hasExp;
// not allowing L with an exponent or decimal point
return foundDigit && !hasExp && !hasDecPoint;
}
// last character is illegal
return false;

View File

@ -1139,6 +1139,10 @@ public class NumberUtilsTest extends TestCase {
// LANG-521
val = "2.";
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) {