use of javax.money.CurrencyUnit in project jsr354-ri by JavaMoney.
the class CurrenciesTest method testGetDifferentCurrencyCodes.
/**
* Test method for
* {@link javax.money.Monetary#getCurrency(java.lang.String, String...)}.
*/
@Test
public void testGetDifferentCurrencyCodes() {
CurrencyUnit cur = Monetary.getCurrency("USD");
assertEquals("USD", cur.getCurrencyCode());
cur = Monetary.getCurrency("EUR");
assertEquals("EUR", cur.getCurrencyCode());
}
use of javax.money.CurrencyUnit in project jsr354-ri by JavaMoney.
the class CurrenciesTest method testGetCurrencyString.
/**
* Test method for
* {@link javax.money.Monetary#getCurrency(java.lang.String, String...)} .
*/
@Test
public void testGetCurrencyString() {
CurrencyUnit cur = Monetary.getCurrency("CHF");
assertNotNull(cur);
Currency jdkCurrency = Currency.getInstance("CHF");
assertEquals(jdkCurrency.getCurrencyCode(), cur.getCurrencyCode());
assertEquals(jdkCurrency.getNumericCode(), cur.getNumericCode());
assertEquals(jdkCurrency.getDefaultFractionDigits(), cur.getDefaultFractionDigits());
}
use of javax.money.CurrencyUnit in project jsr354-ri by JavaMoney.
the class CurrenciesTest method testGetMultipleInstancesString.
/**
* Test method for
* {@link javax.money.Monetary#getCurrency(java.lang.String, String...)}.
* .
*/
@Test
public void testGetMultipleInstancesString() {
CurrencyUnit cur = Monetary.getCurrency("USD");
CurrencyUnit cur2 = Monetary.getCurrency("USD");
assertNotNull(cur2);
assertTrue(cur == cur2);
Currency jdkCurrency = Currency.getInstance("USD");
assertEquals(jdkCurrency.getCurrencyCode(), cur.getCurrencyCode());
assertEquals(jdkCurrency.getNumericCode(), cur.getNumericCode());
assertEquals(jdkCurrency.getDefaultFractionDigits(), cur.getDefaultFractionDigits());
}
use of javax.money.CurrencyUnit in project jsr354-ri by JavaMoney.
the class CurrenciesTest method testCompareTo.
/**
* Test Comparable method for
* {@link javax.money.CurrencyUnit}s.
*/
@Test
public void testCompareTo() {
CurrencyUnit cur1 = Monetary.getCurrency("USD");
CurrencyUnit cur2 = Monetary.getCurrency("EUR");
assertNotNull(cur1);
assertNotNull(cur2);
assertTrue(0 < cur1.compareTo(cur2));
assertTrue(0 > cur2.compareTo(cur1));
assertEquals(0, cur1.compareTo(cur1));
assertEquals(0, cur2.compareTo(cur2));
}
use of javax.money.CurrencyUnit in project jsr354-ri by JavaMoney.
the class CurrenciesTest method testToString.
/**
* Test method for {@link CurrencyUnit#toString()}
* .
*/
@Test
public void testToString() {
CurrencyUnit cur1 = Monetary.getCurrency("USD");
String toString = cur1.toString();
assertNotNull(toString);
assertTrue(toString.contains("USD"), "Does not contain currency code.");
}
Aggregations