Package jodd.typeconverter.impl

Examples of jodd.typeconverter.impl.LongConverter


    ShortConverter shortConverter = new ShortConverter();
    register(Short.class, shortConverter);
    register(short.class, shortConverter);
    register(MutableShort.class, new MutableShortConverter(this));

    LongConverter longConverter = new LongConverter();
    register(Long.class, longConverter);
    register(long.class, longConverter);
    register(MutableLong.class, new MutableLongConverter(this));

    ByteConverter byteConverter = new ByteConverter();
View Full Code Here


    ShortConverter shortConverter = new ShortConverter();
    register(Short.class, shortConverter);
    register(short.class, shortConverter);
    register(MutableShort.class, new MutableShortConverter(this));

    LongConverter longConverter = new LongConverter();
    register(Long.class, longConverter);
    register(long.class, longConverter);
    register(MutableLong.class, new MutableLongConverter(this));

    ByteConverter byteConverter = new ByteConverter();
View Full Code Here

public class LongConverterTest {

  @Test
  public void testConversion() {
    LongConverter longConverter = new LongConverter();

    assertNull(longConverter.convert(null));

    assertEquals(Long.valueOf(173), longConverter.convert(Long.valueOf(173)));

    assertEquals(Long.valueOf(173), longConverter.convert(Integer.valueOf(173)));
    assertEquals(Long.valueOf(173), longConverter.convert(Short.valueOf((short) 173)));
    assertEquals(Long.valueOf(173), longConverter.convert(Double.valueOf(173.0D)));
    assertEquals(Long.valueOf(173), longConverter.convert(Float.valueOf(173.0F)));
    assertEquals(Long.valueOf(173), longConverter.convert("173"));
    assertEquals(Long.valueOf(173), longConverter.convert(" 173 "));

    assertEquals(Long.valueOf(-1), longConverter.convert(" -1 "));
    assertEquals(Long.valueOf(1), longConverter.convert(" +1 "));
    assertEquals(Long.valueOf(9223372036854775807L), longConverter.convert(" +9223372036854775807 "));
    assertEquals(Long.valueOf(-9223372036854775808L), longConverter.convert(" -9223372036854775808 "));

    try {
      longConverter.convert("9223372036854775808");
      fail();
    } catch (TypeConversionException ignore) {
    }
    try {
      longConverter.convert("-9223372036854775809");
      fail();
    } catch (TypeConversionException ignore) {
    }
    try {
      longConverter.convert("a");
      fail();
    } catch (TypeConversionException ignore) {
    }
  }
View Full Code Here

TOP

Related Classes of jodd.typeconverter.impl.LongConverter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.