Add tests to show magnitude boundary between Float, Double and BigDecimal
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1408359 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cbb9aed860
commit
d2bea5ffd3
|
@ -245,6 +245,20 @@ public void testCreateNumber() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tests to show when magnitude causes switch to next Number type
|
||||||
|
// Will probably need to be adjusted if code is changed to check precision (LANG-693)
|
||||||
|
@Test
|
||||||
|
public void testCreateNumberMagnitude() {
|
||||||
|
// Test Float.MAX_VALUE, and same with +1 in final digit to check conversion changes to next Number type
|
||||||
|
assertEquals(Float.class, NumberUtils.createNumber("3.4028235e+38").getClass());
|
||||||
|
assertEquals(Double.class, NumberUtils.createNumber("3.4028236e+38").getClass());
|
||||||
|
|
||||||
|
// Test Double.MAX_VALUE
|
||||||
|
assertEquals(Double.class, NumberUtils.createNumber("1.7976931348623157e+308").getClass());
|
||||||
|
// Test with +2 in final digit (+1 does not cause roll-over to BigDecimal)
|
||||||
|
assertEquals(BigDecimal.class, NumberUtils.createNumber("1.7976931348623159e+308").getClass());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateFloat() {
|
public void testCreateFloat() {
|
||||||
assertEquals("createFloat(String) failed", Float.valueOf("1234.5"), NumberUtils.createFloat("1234.5"));
|
assertEquals("createFloat(String) failed", Float.valueOf("1234.5"), NumberUtils.createFloat("1234.5"));
|
||||||
|
|
Loading…
Reference in New Issue