diff options
author | Neil Fuller <nfuller@google.com> | 2014-06-19 12:21:07 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-06-17 21:55:36 +0000 |
commit | 2eb56b69de339978a29d94531759b465742f027f (patch) | |
tree | cb06bed91cb411ef902abc7a91b3a5bc08bcc50f /luni/src/test | |
parent | 0be123572d8d243ca6018ce8b61b0476e629e37d (diff) | |
parent | 1d3d40749170e945b778e74786543520fbe9d14c (diff) | |
download | libcore-2eb56b69de339978a29d94531759b465742f027f.zip libcore-2eb56b69de339978a29d94531759b465742f027f.tar.gz libcore-2eb56b69de339978a29d94531759b465742f027f.tar.bz2 |
Merge "Fix CurrencyTest.test_getSymbol for unknown variants"
Diffstat (limited to 'luni/src/test')
-rw-r--r-- | luni/src/test/java/libcore/icu/ICUTest.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/luni/src/test/java/libcore/icu/ICUTest.java b/luni/src/test/java/libcore/icu/ICUTest.java index be2da25..3fa1f46 100644 --- a/luni/src/test/java/libcore/icu/ICUTest.java +++ b/luni/src/test/java/libcore/icu/ICUTest.java @@ -216,4 +216,39 @@ public class ICUTest extends junit.framework.TestCase { assertTrue(c.compare("รค", "AF") < 0); assertTrue(c.compare("AF", "af") < 0); } + + // Test for the behavior of currency symbol lookup when an unrecognized locale has been set as the + // default. + public void testIcuDefaultAffectsCurrencySymbol() { + // A locale that is not going to be recognized by ICU and should fallback to "root" for the + // currency symbol. + final Locale unrecognizedLocale = new Locale("xy", "KR"); + + // A known locale with a relatively stable representation for its currency symbol. + final Locale enUsLocale = new Locale("en", "US"); + final String usDollar = "USD"; + + String initialDefaultLocale = ICU.getDefaultLocale(); + try { + // Confirm the "$" symbol for USD in en-US. + assertEquals("$", ICU.getCurrencySymbol(enUsLocale, usDollar)); + + // Set the default so this will be used as fallback for the unrecognized locale symbol lookup. + ICU.setDefaultLocale(enUsLocale.toLanguageTag()); + + // Demonstrate the USD symbol is reported as "$" for the unrecognized locale (which is using + // the default). + assertEquals("$", ICU.getCurrencySymbol(unrecognizedLocale, usDollar)); + + // Change the default. + ICU.setDefaultLocale(unrecognizedLocale.toLanguageTag()); + + String currencySymbolAfterDefaultChange = ICU.getCurrencySymbol(unrecognizedLocale, usDollar); + // "$US" is the value from root. With an unrecognized locale argument, and an unrecognized + // locale as the default, ICU has returns the value in root. + assertEquals("US$", currencySymbolAfterDefaultChange); + } finally { + ICU.setDefaultLocale(initialDefaultLocale); + } + } } |