Exemplo n.º 1
0
 @Test
 public void testNullBoxing() {
   BoxedClass boxed = new BoxedClass();
   PrimitiveClass primitive = ubiquity.map(boxed, PrimitiveClass.class);
   assertEquals(false, primitive.isMyBoolean());
   assertEquals(0, primitive.getMyByte());
   assertEquals(0, primitive.getMyCharacter());
   assertEquals(0, primitive.getMyInt());
   assertEquals(0, primitive.getMyShort());
   assertEquals(0, primitive.getMyLong());
   assertEquals(0, primitive.getMyFloat(), 0.01);
   assertEquals(0, primitive.getMyDouble(), 0.01);
 }
Exemplo n.º 2
0
 private void checkEquality(PrimitiveClass primitive, BoxedClass boxed) {
   assertEquals(primitive.isMyBoolean(), boxed.getMyBoolean());
   assertEquals(primitive.getMyByte(), boxed.getMyByte().byteValue());
   assertEquals(primitive.getMyCharacter(), boxed.getMyCharacter().charValue());
   assertEquals(primitive.getMyDouble(), boxed.getMyDouble(), 0.001);
   assertEquals(primitive.getMyFloat(), boxed.getMyFloat(), 0.001);
   assertEquals(primitive.getMyInt(), boxed.getMyInt().intValue());
   assertEquals(primitive.getMyLong(), boxed.getMyLong().longValue());
   assertEquals(primitive.getMyShort(), boxed.getMyShort().shortValue());
 }
Exemplo n.º 3
0
  @Test
  public void testPrimitiveToBoxed() {
    PrimitiveClass primitive = new PrimitiveClass();
    primitive.setMyBoolean(true);
    primitive.setMyByte((byte) 0xC);
    primitive.setMyCharacter('F');
    primitive.setMyDouble(123.321d);
    primitive.setMyFloat(21.21f);
    primitive.setMyInt(42);
    primitive.setMyLong(123456789L);
    primitive.setMyShort((short) 3);

    BoxedClass boxed = ubiquity.map(primitive, BoxedClass.class);
    checkEquality(primitive, boxed);
  }