Search in sources :

Example 31 with NumberValue

use of javax.money.NumberValue in project jsr354-ri-bp by JavaMoney.

the class DefaultNumberValueTest method shouldReturnFloat.

@Test
public void shouldReturnFloat() {
    NumberValue numberValue = DefaultNumberValue.of(BigDecimal.valueOf(132.21));
    assertEquals(numberValue.floatValue(), 132.21F);
}
Also used : NumberValue(javax.money.NumberValue) Test(org.testng.annotations.Test)

Example 32 with NumberValue

use of javax.money.NumberValue in project jsr354-ri-bp by JavaMoney.

the class DefaultNumberValueTest method shouldReturnDouble.

@Test
public void shouldReturnDouble() {
    NumberValue numberValue = DefaultNumberValue.of(BigDecimal.valueOf(132.21));
    assertEquals(numberValue.doubleValue(), 132.21);
}
Also used : NumberValue(javax.money.NumberValue) Test(org.testng.annotations.Test)

Example 33 with NumberValue

use of javax.money.NumberValue in project jsr354-ri-bp by JavaMoney.

the class DefaultNumberValueTest method shouldReturnScale.

@Test
public void shouldReturnScale() {
    NumberValue numberValue = DefaultNumberValue.of(BigDecimal.valueOf(132.21));
    assertEquals(numberValue.getScale(), 2);
}
Also used : NumberValue(javax.money.NumberValue) Test(org.testng.annotations.Test)

Example 34 with NumberValue

use of javax.money.NumberValue in project jsr354-ri-bp by JavaMoney.

the class DefaultNumberValueTest method shouldReturnPrecision.

@Test
public void shouldReturnPrecision() {
    NumberValue numberValue = DefaultNumberValue.of(BigDecimal.valueOf(132.21));
    assertEquals(numberValue.getPrecision(), 5);
}
Also used : NumberValue(javax.money.NumberValue) Test(org.testng.annotations.Test)

Example 35 with NumberValue

use of javax.money.NumberValue in project jsr354-ri-bp by JavaMoney.

the class DefaultNumberValueTest method shouldReturnIntValue.

@Test
public void shouldReturnIntValue() {
    NumberValue numberValue = DefaultNumberValue.of(BigDecimal.valueOf(132.21));
    assertEquals(numberValue.intValue(), 132);
}
Also used : NumberValue(javax.money.NumberValue) Test(org.testng.annotations.Test)

Aggregations

NumberValue (javax.money.NumberValue)40 Test (org.testng.annotations.Test)36 BigDecimal (java.math.BigDecimal)6 BigInteger (java.math.BigInteger)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 AtomicLong (java.util.concurrent.atomic.AtomicLong)4 CurrencyConversionException (javax.money.convert.CurrencyConversionException)2 ExchangeRate (javax.money.convert.ExchangeRate)2