use of android.icu.util.Currency in project j2objc by google.
the class CurrencyTest method testGetName_Locale_Int_String_BooleanArray.
@Test
public void testGetName_Locale_Int_String_BooleanArray() {
Currency currency = Currency.getInstance(ULocale.CHINA);
boolean[] isChoiceFormat = new boolean[1];
int nameStyle = Currency.LONG_NAME;
String pluralCount = "";
String ulocaleName = currency.getName(ULocale.CANADA, nameStyle, pluralCount, isChoiceFormat);
assertEquals("currency name mismatch", "Chinese Yuan", ulocaleName);
String localeName = currency.getName(Locale.CANADA, nameStyle, pluralCount, isChoiceFormat);
assertEquals("currency name mismatch", ulocaleName, localeName);
}
use of android.icu.util.Currency in project j2objc by google.
the class CurrencyTest method TestGetNumericCode.
/**
* Test case for getNumericCode()
*/
@Test
public void TestGetNumericCode() {
final Object[][] NUMCODE_TESTDATA = { { "USD", 840 }, { "Usd", 840 }, /* mixed casing */
{ "EUR", 978 }, { "JPY", 392 }, { "XFU", 0 }, /* XFU: no numeric code */
{ "ZZZ", 0 } /* ZZZ: undefined ISO currency code */
};
for (Object[] data : NUMCODE_TESTDATA) {
Currency cur = Currency.getInstance((String) data[0]);
int numCode = cur.getNumericCode();
int expected = ((Integer) data[1]).intValue();
if (numCode != expected) {
errln("FAIL: getNumericCode returned " + numCode + " for " + cur.getCurrencyCode() + " - expected: " + expected);
}
}
}
use of android.icu.util.Currency in project j2objc by google.
the class CurrencyTest method TestAPI.
/**
* Test of basic API.
*/
@Test
public void TestAPI() {
Currency usd = Currency.getInstance("USD");
/*int hash = */
usd.hashCode();
Currency jpy = Currency.getInstance("JPY");
if (usd.equals(jpy)) {
errln("FAIL: USD == JPY");
}
if (usd.equals("abc")) {
errln("FAIL: USD == (String)");
}
if (usd.equals(null)) {
errln("FAIL: USD == (null)");
}
if (!usd.equals(usd)) {
errln("FAIL: USD != USD");
}
try {
Currency nullCurrency = Currency.getInstance((String) null);
errln("FAIL: Expected getInstance(null) to throw " + "a NullPointerException, but returned " + nullCurrency);
} catch (NullPointerException npe) {
logln("PASS: getInstance(null) threw a NullPointerException");
}
try {
Currency bogusCurrency = Currency.getInstance("BOGUS");
errln("FAIL: Expected getInstance(\"BOGUS\") to throw " + "an IllegalArgumentException, but returned " + bogusCurrency);
} catch (IllegalArgumentException iae) {
logln("PASS: getInstance(\"BOGUS\") threw an IllegalArgumentException");
}
Locale[] avail = Currency.getAvailableLocales();
if (avail == null) {
errln("FAIL: getAvailableLocales returned null");
}
try {
usd.getName(ULocale.US, 5, new boolean[1]);
errln("expected getName with invalid type parameter to throw exception");
} catch (Exception e) {
logln("PASS: getName failed as expected");
}
}
use of android.icu.util.Currency in project j2objc by google.
the class CurrencyTest method testGetRoundingIncrement.
@Test
public void testGetRoundingIncrement() {
Currency currency = Currency.getInstance(ULocale.JAPAN);
// It appears as though this always returns 0 irrespective of the currency.
double roundingIncrement = currency.getRoundingIncrement();
assertEquals("Rounding increment not zero", 0.0, roundingIncrement, 0.0);
}
use of android.icu.util.Currency in project j2objc by google.
the class CurrencyTest method TestCoverage.
@Test
public void TestCoverage() {
Currency usd = Currency.getInstance("USD");
assertEquals("USD.getSymbol()", "$", usd.getSymbol());
}
Aggregations