mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 22:44:49 +00:00
ICU-13731 Adding test for default currency symbol.
This commit is contained in:
parent
9cdb660b5e
commit
68168a6067
3 changed files with 47 additions and 0 deletions
|
@ -227,6 +227,7 @@ void NumberFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &n
|
|||
TESTCASE_AUTO(Test13850_EmptyStringCurrency);
|
||||
TESTCASE_AUTO(Test20348_CurrencyPrefixOverride);
|
||||
TESTCASE_AUTO(Test20358_GroupingInPattern);
|
||||
TESTCASE_AUTO(Test13731_DefaultCurrency);
|
||||
TESTCASE_AUTO_END;
|
||||
}
|
||||
|
||||
|
@ -9531,4 +9532,30 @@ void NumberFormatTest::Test20358_GroupingInPattern() {
|
|||
u"54,321", fmt->format(54321, result.remove(), NULL, status));
|
||||
}
|
||||
|
||||
void NumberFormatTest::Test13731_DefaultCurrency() {
|
||||
IcuTestErrorCode status(*this, "Test13731_DefaultCurrency");
|
||||
UnicodeString result;
|
||||
{
|
||||
LocalPointer<NumberFormat> nf(NumberFormat::createInstance(
|
||||
"en", UNumberFormatStyle::UNUM_CURRENCY, status), status);
|
||||
assertEquals("symbol", u"¤1.10",
|
||||
nf->format(1.1, result.remove(), status));
|
||||
assertEquals("currency", u"XXX", nf->getCurrency());
|
||||
}
|
||||
{
|
||||
LocalPointer<NumberFormat> nf(NumberFormat::createInstance(
|
||||
"en", UNumberFormatStyle::UNUM_CURRENCY_ISO, status), status);
|
||||
assertEquals("iso_code", u"XXX 1.10",
|
||||
nf->format(1.1, result.remove(), status));
|
||||
assertEquals("currency", u"XXX", nf->getCurrency());
|
||||
}
|
||||
{
|
||||
LocalPointer<NumberFormat> nf(NumberFormat::createInstance(
|
||||
"en", UNumberFormatStyle::UNUM_CURRENCY_PLURAL, status), status);
|
||||
assertEquals("plural", u"1.10 (unknown currency)",
|
||||
nf->format(1.1, result.remove(), status));
|
||||
assertEquals("currency", u"XXX", nf->getCurrency());
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
|
|
@ -292,6 +292,7 @@ class NumberFormatTest: public CalendarTimeZoneTest {
|
|||
void Test13850_EmptyStringCurrency();
|
||||
void Test20348_CurrencyPrefixOverride();
|
||||
void Test20358_GroupingInPattern();
|
||||
void Test13731_DefaultCurrency();
|
||||
|
||||
private:
|
||||
UBool testFormattableAsUFormattable(const char *file, int line, Formattable &f);
|
||||
|
|
|
@ -6572,4 +6572,23 @@ public class NumberFormatTest extends TestFmwk {
|
|||
assertEquals("Set grouping true format",
|
||||
"54,321", fmt.format(54321));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test13731_DefaultCurrency() {
|
||||
{
|
||||
NumberFormat nf = NumberFormat.getInstance(ULocale.ENGLISH, NumberFormat.CURRENCYSTYLE);
|
||||
assertEquals("symbol", "¤1.10", nf.format(1.1));
|
||||
assertEquals("currency", "XXX", nf.getCurrency().getCurrencyCode());
|
||||
}
|
||||
{
|
||||
NumberFormat nf = NumberFormat.getInstance(ULocale.ENGLISH, NumberFormat.ISOCURRENCYSTYLE);
|
||||
assertEquals("iso_code", "XXX 1.10", nf.format(1.1));
|
||||
assertEquals("currency", "XXX", nf.getCurrency().getCurrencyCode());
|
||||
}
|
||||
{
|
||||
NumberFormat nf = NumberFormat.getInstance(ULocale.ENGLISH, NumberFormat.PLURALCURRENCYSTYLE);
|
||||
assertEquals("plural", "1.10 (unknown currency)", nf.format(1.1));
|
||||
assertEquals("currency", "XXX", nf.getCurrency().getCurrencyCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue