mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add test
This commit is contained in:
@@ -7,6 +7,8 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
|
import java.text.NumberFormat;
|
||||||
|
import java.text.ParseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link NumberUtil} 单元测试类
|
* {@link NumberUtil} 单元测试类
|
||||||
@@ -349,6 +351,14 @@ public class NumberUtilTest {
|
|||||||
Assert.assertEquals("1234.56", bigDecimal.toString());
|
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
|
@Test
|
||||||
public void parseIntTest() {
|
public void parseIntTest() {
|
||||||
int number = NumberUtil.parseInt("0xFF");
|
int number = NumberUtil.parseInt("0xFF");
|
||||||
|
Reference in New Issue
Block a user