mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-24 18:04:54 +08:00
add test
This commit is contained in:
parent
0bb5dc3443
commit
f8d7fe1daf
@ -7,6 +7,8 @@ import org.junit.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.ParseException;
|
||||
|
||||
/**
|
||||
* {@link NumberUtil} 单元测试类
|
||||
@ -349,6 +351,14 @@ public class NumberUtilTest {
|
||||
Assert.assertEquals("1234.56", bigDecimal.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void issue2878Test() throws ParseException {
|
||||
// https://github.com/dromara/hutool/issues/2878
|
||||
// 当数字中包含一些非数字字符时,按照JDK的规则,不做修改。
|
||||
final BigDecimal bigDecimal = NumberUtil.toBigDecimal("345.sdf");
|
||||
Assert.assertEquals(NumberFormat.getInstance().parse("345.sdf"), bigDecimal.longValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseIntTest() {
|
||||
int number = NumberUtil.parseInt("0xFF");
|
||||
|
Loading…
Reference in New Issue
Block a user