fix convert to int bug

This commit is contained in:
Looly
2022-06-16 12:49:55 +08:00
parent 64e11c9de8
commit ea4bc023af
4 changed files with 15 additions and 1 deletions

View File

@@ -217,4 +217,11 @@ public class MapUtilTest {
Assert.assertEquals(Integer.valueOf(1), map.get("a"));
Assert.assertEquals(Integer.valueOf(2), map.get("b"));
}
@Test(expected = NumberFormatException.class)
public void getIntTest(){
final HashMap<String, String> map = MapUtil.of("age", "d");
final Integer age = MapUtil.getInt(map, "age");
Assert.assertNotNull(age);
}
}

View File

@@ -287,6 +287,12 @@ public class NumberUtilTest {
Assert.assertEquals(1482, v1);
}
@Test(expected = NumberFormatException.class)
public void parseIntTest3() {
int v1 = NumberUtil.parseInt("d");
Assert.assertEquals(0, v1);
}
@Test
public void parseNumberTest() {
// from 5.4.8 issue#I23ORQ@Gitee