コード例 #1
0
  public void testConvertsToFloatPrimitive() throws Exception {
    Float input = new Float(1000);

    StringToNumberConverter converter = StringToNumberConverter.toFloat(true);
    Float result = (Float) converter.convert(numberFormat.format(input.floatValue()));

    assertEquals(input, result);
  }
コード例 #2
0
 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());
 }