public void testConvertsToLongPrimitive() throws Exception { Long input = new Long(1000); StringToNumberConverter converter = StringToNumberConverter.toLong(true); Long result = (Long) converter.convert(numberIntegerFormat.format(input.longValue())); assertEquals(input, result); }
public void testToTypes() throws Exception { assertEquals( "Integer.class", Integer.class, StringToNumberConverter.toInteger(false).getToType()); assertEquals("Integer.TYPE", Integer.TYPE, StringToNumberConverter.toInteger(true).getToType()); assertEquals("Double.class", Double.class, StringToNumberConverter.toDouble(false).getToType()); assertEquals("Double.TYPE", Double.TYPE, StringToNumberConverter.toDouble(true).getToType()); assertEquals("Long.class", Long.class, StringToNumberConverter.toLong(false).getToType()); assertEquals("Long.TYPE", Long.TYPE, StringToNumberConverter.toLong(true).getToType()); assertEquals("Float.class", Float.class, StringToNumberConverter.toFloat(false).getToType()); assertEquals("Float.TYPE", Float.TYPE, StringToNumberConverter.toFloat(true).getToType()); assertEquals( "BigInteger.TYPE", BigInteger.class, StringToNumberConverter.toBigInteger().getToType()); assertEquals( "BigDecimal.TYPE", BigDecimal.class, StringToNumberConverter.toBigDecimal().getToType()); assertEquals("Short.class", Short.class, StringToNumberConverter.toShort(false).getToType()); assertEquals("Short.TYPE", Short.TYPE, StringToNumberConverter.toShort(true).getToType()); assertEquals("Byte.class", Byte.class, StringToNumberConverter.toByte(false).getToType()); assertEquals("Byte.TYPE", Byte.TYPE, StringToNumberConverter.toByte(true).getToType()); }