jdk/test/java/util/Locale/LocaleEnhanceTest.java
changeset 6843 6ab7e78c51eb
parent 6501 684810d882b3
child 7513 7091fccbc86d
equal deleted inserted replaced
6842:3cf2f818d3e9 6843:6ab7e78c51eb
   612         // this should break when we have localization data for DE
   612         // this should break when we have localization data for DE
   613         assertEquals("latn DE", "Latin", latnLocale.getDisplayScript(Locale.GERMANY));
   613         assertEquals("latn DE", "Latin", latnLocale.getDisplayScript(Locale.GERMANY));
   614         assertEquals("hans DE", "Simplified Han", hansLocale.getDisplayScript(Locale.GERMANY));
   614         assertEquals("hans DE", "Simplified Han", hansLocale.getDisplayScript(Locale.GERMANY));
   615     }
   615     }
   616 
   616 
       
   617     public void testGetDisplayName() {
       
   618         final Locale[] testLocales = {
       
   619                 Locale.ROOT,
       
   620                 new Locale("en"),
       
   621                 new Locale("en", "US"),
       
   622                 new Locale("", "US"),
       
   623                 new Locale("no", "NO", "NY"),
       
   624                 new Locale("", "", "NY"),
       
   625                 Locale.forLanguageTag("zh-Hans"),
       
   626                 Locale.forLanguageTag("zh-Hant"),
       
   627                 Locale.forLanguageTag("zh-Hans-CN"),
       
   628                 Locale.forLanguageTag("und-Hans"),
       
   629         };
       
   630 
       
   631         final String[] displayNameEnglish = {
       
   632                 "",
       
   633                 "English",
       
   634                 "English (United States)",
       
   635                 "United States",
       
   636                 "Norwegian (Norway,Nynorsk)",
       
   637                 "Nynorsk",
       
   638                 "Chinese (Simplified Han)",
       
   639                 "Chinese (Traditional Han)",
       
   640                 "Chinese (Simplified Han,China)",
       
   641                 "Simplified Han",
       
   642         };
       
   643 
       
   644         final String[] displayNameSimplifiedChinese = {
       
   645                 "",
       
   646                 "\u82f1\u6587",
       
   647                 "\u82f1\u6587 (\u7f8e\u56fd)",
       
   648                 "\u7f8e\u56fd",
       
   649                 "\u632a\u5a01\u6587 (\u632a\u5a01,Nynorsk)",
       
   650                 "Nynorsk",
       
   651                 "\u4e2d\u6587 (\u7b80\u4f53\u4e2d\u6587)",
       
   652                 "\u4e2d\u6587 (\u7e41\u4f53\u4e2d\u6587)",
       
   653                 "\u4e2d\u6587 (\u7b80\u4f53\u4e2d\u6587,\u4e2d\u56fd)",
       
   654                 "\u7b80\u4f53\u4e2d\u6587",
       
   655         };
       
   656 
       
   657         for (int i = 0; i < testLocales.length; i++) {
       
   658             Locale loc = testLocales[i];
       
   659             assertEquals("English display name for " + loc.toLanguageTag(),
       
   660                     displayNameEnglish[i], loc.getDisplayName(Locale.ENGLISH));
       
   661             assertEquals("Simplified Chinese display name for " + loc.toLanguageTag(),
       
   662                     displayNameSimplifiedChinese[i], loc.getDisplayName(Locale.CHINA));
       
   663         }
       
   664     }
       
   665 
   617     ///
   666     ///
   618     /// Builder tests
   667     /// Builder tests
   619     ///
   668     ///
   620 
   669 
   621     public void testBuilderSetLocale() {
   670     public void testBuilderSetLocale() {