use of javax.money.NumberValue in project jsr354-ri by JavaMoney.
the class DefaultNumberValueTest method shouldReturnErrorWhenLongValueExactMustBeTruncated.
@Test(expectedExceptions = ArithmeticException.class)
public void shouldReturnErrorWhenLongValueExactMustBeTruncated() {
NumberValue numberValue = DefaultNumberValue.of(BigDecimal.valueOf(132.12));
numberValue.longValueExact();
}
use of javax.money.NumberValue in project jsr354-ri by JavaMoney.
the class DefaultNumberValueTest method shouldReturnNumberType.
@Test
public void shouldReturnNumberType() {
NumberValue numberValueLong = DefaultNumberValue.of(10L);
NumberValue numberValueInteger = DefaultNumberValue.of(10);
NumberValue numberValueDouble = DefaultNumberValue.of(10D);
NumberValue numberValueBigDecimal = DefaultNumberValue.of(BigDecimal.TEN);
NumberValue numberValueBigInteger = DefaultNumberValue.of(BigInteger.TEN);
assertEquals(numberValueLong.getNumberType(), Long.class);
assertEquals(numberValueInteger.getNumberType(), Integer.class);
assertEquals(numberValueDouble.getNumberType(), Double.class);
assertEquals(numberValueBigDecimal.getNumberType(), BigDecimal.class);
assertEquals(numberValueBigInteger.getNumberType(), BigInteger.class);
}
use of javax.money.NumberValue in project jsr354-ri by JavaMoney.
the class DefaultNumberValueTest method shouldReturnErrorWhenIntValueExactMustBeTruncated.
@Test(expectedExceptions = ArithmeticException.class)
public void shouldReturnErrorWhenIntValueExactMustBeTruncated() {
NumberValue numberValue = DefaultNumberValue.of(BigDecimal.valueOf(132.12));
numberValue.intValueExact();
}
use of javax.money.NumberValue in project jsr354-ri by JavaMoney.
the class DefaultNumberValueTest method shouldReturnIntValue.
@Test
public void shouldReturnIntValue() {
NumberValue numberValue = DefaultNumberValue.of(BigDecimal.valueOf(132.21));
assertEquals(numberValue.intValue(), 132);
}
use of javax.money.NumberValue in project jsr354-ri by JavaMoney.
the class DefaultNumberValueTest method shoudReturnAmountFractionNumerator.
@Test
public void shoudReturnAmountFractionNumerator() {
NumberValue numberValue = DefaultNumberValue.of(BigDecimal.valueOf(62.5));
assertEquals(5L, numberValue.getAmountFractionNumerator());
assertEquals(10L, numberValue.getAmountFractionDenominator());
}
Aggregations