[LANG-1729] NumberUtils.isParsable() returns true for Fullwidth Unicode
digits Add Long test case
This commit is contained in:
parent
aad9a675b3
commit
96c211eb1b
|
@ -114,6 +114,22 @@ public class NumberUtilsTest extends AbstractLangTest {
|
|||
return NumberUtils.isParsable(s);
|
||||
}
|
||||
|
||||
private boolean isLongParsable(final String s) {
|
||||
final NumberFormat instance = NumberFormat.getInstance();
|
||||
instance.setParseIntegerOnly(false);
|
||||
try {
|
||||
instance.parse(s);
|
||||
} catch (final ParseException e) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
Long.parseLong(s);
|
||||
} catch (final NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
return NumberUtils.isParsable(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for {@link NumberUtils#toDouble(BigDecimal)}
|
||||
*/
|
||||
|
@ -826,6 +842,22 @@ public class NumberUtilsTest extends AbstractLangTest {
|
|||
assertFalse(NumberUtils.isDigits("abc"), "isDigits(String) neg 4 failed");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsIntParsableLang1729() {
|
||||
assertTrue(isIntParsable("1"));
|
||||
assertFalse(isIntParsable("1 2 3"));
|
||||
assertTrue(isIntParsable("123"));
|
||||
assertFalse(isIntParsable("1 2 3"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsLongParsableLang1729() {
|
||||
assertTrue(isLongParsable("1"));
|
||||
assertFalse(isLongParsable("1 2 3"));
|
||||
assertTrue(isLongParsable("123"));
|
||||
assertFalse(isLongParsable("1 2 3"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests isCreatable(String) and tests that createNumber(String) returns a valid number iff isCreatable(String)
|
||||
* returns false.
|
||||
|
@ -957,15 +989,6 @@ public class NumberUtilsTest extends AbstractLangTest {
|
|||
assertTrue(NumberUtils.isParsable("-.236"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled("Passes on OpenJDK 64-Bit Server VM (build 23-ea+18-1469, mixed mode, sharing)")
|
||||
public void testIsParsableLang1729() {
|
||||
assertTrue(isIntParsable("1"));
|
||||
assertFalse(isIntParsable("1 2 3"));
|
||||
assertTrue(isIntParsable("123"));
|
||||
assertFalse(isIntParsable("1 2 3"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLang1087() {
|
||||
// no sign cases
|
||||
|
|
Loading…
Reference in New Issue