[LANG-1729] NumberUtils.isParsable() returns true for Fullwidth Unicode
digits Add Byte test case
This commit is contained in:
parent
aacc467954
commit
e4aba3f828
|
@ -97,7 +97,23 @@ public class NumberUtilsTest extends AbstractLangTest {
|
|||
assertTrue(NumberUtils.compare((short) 213, (short) 32) > 0);
|
||||
}
|
||||
|
||||
private boolean isIntegerParsable(final String s) {
|
||||
private boolean isParsableByte(final String s) {
|
||||
final NumberFormat instance = NumberFormat.getInstance();
|
||||
instance.setParseIntegerOnly(false);
|
||||
try {
|
||||
instance.parse(s);
|
||||
} catch (final ParseException e) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
Byte.parseByte(s);
|
||||
} catch (final NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
return NumberUtils.isParsable(s);
|
||||
}
|
||||
|
||||
private boolean isParsableInteger(final String s) {
|
||||
final NumberFormat instance = NumberFormat.getInstance();
|
||||
instance.setParseIntegerOnly(false);
|
||||
try {
|
||||
|
@ -113,7 +129,7 @@ public class NumberUtilsTest extends AbstractLangTest {
|
|||
return NumberUtils.isParsable(s);
|
||||
}
|
||||
|
||||
private boolean isLongParsable(final String s) {
|
||||
private boolean isParsableLong(final String s) {
|
||||
final NumberFormat instance = NumberFormat.getInstance();
|
||||
instance.setParseIntegerOnly(false);
|
||||
try {
|
||||
|
@ -129,7 +145,7 @@ public class NumberUtilsTest extends AbstractLangTest {
|
|||
return NumberUtils.isParsable(s);
|
||||
}
|
||||
|
||||
private boolean isShortParsable(final String s) {
|
||||
private boolean isParsableShort(final String s) {
|
||||
final NumberFormat instance = NumberFormat.getInstance();
|
||||
instance.setParseIntegerOnly(false);
|
||||
try {
|
||||
|
@ -1007,28 +1023,36 @@ public class NumberUtilsTest extends AbstractLangTest {
|
|||
compareIsCreatableWithCreateNumber("+2.0", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLang1729IsParsableByte() {
|
||||
assertTrue(isParsableByte("1"));
|
||||
assertFalse(isParsableByte("1 2 3"));
|
||||
assertTrue(isParsableByte("123"));
|
||||
assertFalse(isParsableByte("1 2 3"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLang1729IsParsableInteger() {
|
||||
assertTrue(isIntegerParsable("1"));
|
||||
assertFalse(isIntegerParsable("1 2 3"));
|
||||
assertTrue(isIntegerParsable("123"));
|
||||
assertFalse(isIntegerParsable("1 2 3"));
|
||||
assertTrue(isParsableInteger("1"));
|
||||
assertFalse(isParsableInteger("1 2 3"));
|
||||
assertTrue(isParsableInteger("123"));
|
||||
assertFalse(isParsableInteger("1 2 3"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLang1729IsParsableLong() {
|
||||
assertTrue(isLongParsable("1"));
|
||||
assertFalse(isLongParsable("1 2 3"));
|
||||
assertTrue(isLongParsable("123"));
|
||||
assertFalse(isLongParsable("1 2 3"));
|
||||
assertTrue(isParsableLong("1"));
|
||||
assertFalse(isParsableLong("1 2 3"));
|
||||
assertTrue(isParsableLong("123"));
|
||||
assertFalse(isParsableLong("1 2 3"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLang1729IsParsableShort() {
|
||||
assertTrue(isShortParsable("1"));
|
||||
assertFalse(isShortParsable("1 2 3"));
|
||||
assertTrue(isShortParsable("123"));
|
||||
assertFalse(isShortParsable("1 2 3"));
|
||||
assertTrue(isParsableShort("1"));
|
||||
assertFalse(isParsableShort("1 2 3"));
|
||||
assertTrue(isParsableShort("123"));
|
||||
assertFalse(isParsableShort("1 2 3"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue