Beispiel #1
0
  public static void checkNullDecimal(IonDecimal value) {
    assertSame(IonType.DECIMAL, value.getType());
    assertTrue("isNullValue is false", value.isNullValue());

    try {
      value.floatValue();
      fail("Expected NullValueException");
    } catch (NullValueException e) {
    }

    try {
      value.doubleValue();
      fail("Expected NullValueException");
    } catch (NullValueException e) {
    }

    assertNull("bigDecimalValue() isn't null", value.bigDecimalValue());
  }
Beispiel #2
0
  @Test
  public void testDecimals() {
    IonDecimal value = (IonDecimal) oneValue("1.0");
    assertSame(IonType.DECIMAL, value.getType());
    assertFalse(value.isNullValue());
    assertArrayEquals(new String[0], value.getTypeAnnotations());
    assertEquals(1.0F, value.floatValue());
    assertEquals(1.0D, value.doubleValue());

    assertEquals(new BigDecimal(1).setScale(1), value.bigDecimalValue());
    // TODO more...

    value = (IonDecimal) oneValue("a::1.0");
    assertFalse(value.isNullValue());
    checkAnnotation("a", value);

    // Ensure that annotation makes it through value mods
    modifyDecimal(value);
    checkAnnotation("a", value);
  }