X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/57a6839dcb3bba09e8228b822b290604668416fe..0f5d89e82340278ed3d7d50029f37cab2c41a57e:/icuSources/test/intltest/locnmtst.cpp?ds=sidebyside diff --git a/icuSources/test/intltest/locnmtst.cpp b/icuSources/test/intltest/locnmtst.cpp index 2b99adf2..e367e6bb 100644 --- a/icuSources/test/intltest/locnmtst.cpp +++ b/icuSources/test/intltest/locnmtst.cpp @@ -1,10 +1,13 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /********************************************************************* * COPYRIGHT: - * Copyright (c) 2010-2014, International Business Machines Corporation and + * Copyright (c) 2010-2016, International Business Machines Corporation and * others. All Rights Reserved. *********************************************************************/ #include "locnmtst.h" +#include "unicode/ustring.h" #include "cstring.h" /* @@ -61,7 +64,7 @@ LocaleDisplayNamesTest::LocaleDisplayNamesTest() { LocaleDisplayNamesTest::~LocaleDisplayNamesTest() { } -void LocaleDisplayNamesTest::runIndexedTest(int32_t index, UBool exec, const char* &name, +void LocaleDisplayNamesTest::runIndexedTest(int32_t index, UBool exec, const char* &name, char* /*par*/) { switch (index) { #if !UCONFIG_NO_FORMATTING @@ -73,10 +76,12 @@ void LocaleDisplayNamesTest::runIndexedTest(int32_t index, UBool exec, const cha TESTCASE(5, TestUldnWithKeywordsAndEverything); TESTCASE(6, TestUldnComponents); TESTCASE(7, TestRootEtc); - TESTCASE(8, TestKeywords); - TESTCASE(9, TestUntranslatedKeywords); - TESTCASE(10, TestPrivateUse); - TESTCASE(11, TestUldnDisplayContext); + TESTCASE(8, TestCurrencyKeyword); + TESTCASE(9, TestUnknownCurrencyKeyword); + TESTCASE(10, TestUntranslatedKeywords); + TESTCASE(11, TestPrivateUse); + TESTCASE(12, TestUldnDisplayContext); + TESTCASE(13, TestUldnWithGarbage); #endif default: name = ""; @@ -105,14 +110,24 @@ void LocaleDisplayNamesTest::TestWithKeywordsAndEverything() { UnicodeString temp; LocaleDisplayNames *ldn = LocaleDisplayNames::createInstance(Locale::getUS()); const char *locname = "en_Hant_US_VALLEY@calendar=gregorian;collation=phonebook"; - const char *target = "English (Traditional, U.S., VALLEY, " - "Gregorian Calendar, Phonebook Sort Order)"; + const char *target = "English (Traditional, US, VALLEY, " + "Gregorian Calendar, Phonebook Sort Order)"; // Apple change ldn->localeDisplayName(locname, temp); delete ldn; test_assert_equal(target, temp); } -void LocaleDisplayNamesTest::TestKeywords() { +void LocaleDisplayNamesTest::TestCurrencyKeyword() { + UnicodeString temp; + LocaleDisplayNames *ldn = LocaleDisplayNames::createInstance(Locale::getUS()); + const char *locname = "ja@currency=JPY"; + const char *target = "Japanese (Japanese Yen)"; + ldn->localeDisplayName(locname, temp); + delete ldn; + test_assert_equal(target, temp); +} + +void LocaleDisplayNamesTest::TestUnknownCurrencyKeyword() { UnicodeString temp; LocaleDisplayNames *ldn = LocaleDisplayNames::createInstance(Locale::getUS()); const char *locname = "de@currency=XYZ"; @@ -177,13 +192,23 @@ void LocaleDisplayNamesTest::TestUldnOpenDialect() { test_assert_equal("British English", str); } +void LocaleDisplayNamesTest::TestUldnWithGarbage() { + UErrorCode status = U_ZERO_ERROR; + const int32_t kMaxResultSize = 150; // long enough + UChar result[150]; + ULocaleDisplayNames *ldn = uldn_open(Locale::getUS().getName(), ULDN_DIALECT_NAMES, &status); + int32_t len = uldn_localeDisplayName(ldn, "english (United States) [w", result, kMaxResultSize, &status); + uldn_close(ldn); + test_assert(U_FAILURE(status) && len == 0); +} + void LocaleDisplayNamesTest::TestUldnWithKeywordsAndEverything() { UErrorCode status = U_ZERO_ERROR; const int32_t kMaxResultSize = 150; // long enough UChar result[150]; const char *locname = "en_Hant_US_VALLEY@calendar=gregorian;collation=phonebook"; - const char *target = "English (Traditional, U.S., VALLEY, " - "Gregorian Calendar, Phonebook Sort Order)"; + const char *target = "English (Traditional, US, VALLEY, " + "Gregorian Calendar, Phonebook Sort Order)"; // Apple change ULocaleDisplayNames *ldn = uldn_open(Locale::getUS().getName(), ULDN_STANDARD_NAMES, &status); int32_t len = uldn_localeDisplayName(ldn, locname, result, kMaxResultSize, &status); uldn_close(ldn); @@ -216,14 +241,14 @@ void LocaleDisplayNamesTest::TestUldnComponents() { { int32_t len = uldn_scriptDisplayName(ldn, "Hant", result, kMaxResultSize, &status); UnicodeString str(result, len, kMaxResultSize); - test_assert_equal("Traditionell", str); + test_assert_equal("Traditionelles Chinesisch", str); } { - int32_t len = uldn_scriptCodeDisplayName(ldn, USCRIPT_TRADITIONAL_HAN, result, kMaxResultSize, + int32_t len = uldn_scriptCodeDisplayName(ldn, USCRIPT_TRADITIONAL_HAN, result, kMaxResultSize, &status); UnicodeString str(result, len, kMaxResultSize); - test_assert_equal("Traditionell", str); + test_assert_equal("Traditionelles Chinesisch", str); } { @@ -245,7 +270,7 @@ void LocaleDisplayNamesTest::TestUldnComponents() { } { - int32_t len = uldn_keyValueDisplayName(ldn, "calendar", "gregorian", result, + int32_t len = uldn_keyValueDisplayName(ldn, "calendar", "gregorian", result, kMaxResultSize, &status); UnicodeString str(result, len, kMaxResultSize); test_assert_equal("Gregorianischer Kalender", str); @@ -259,76 +284,110 @@ typedef struct { const char * displayLocale; UDisplayContext dialectHandling; UDisplayContext capitalization; + UDisplayContext displayLength; const char * localeToBeNamed; const UChar * result; } LocNameDispContextItem; -static char en[] = "en"; -static char en_US[] = "en_US"; +static char en[] = "en"; +static char en_cabud[] = "en@calendar=buddhist"; +static char en_GB[] = "en_GB"; +static char uz_Latn[] = "uz_Latn"; static UChar daFor_en[] = {0x65,0x6E,0x67,0x65,0x6C,0x73,0x6B,0}; //"engelsk" -static UChar daFor_en_US[] = {0x65,0x6E,0x67,0x65,0x6C,0x73,0x6B,0x20,0x28,0x55,0x53,0x41,0x29,0}; //"engelsk (USA)" -static UChar daFor_en_US_D[] = {0x61,0x6D,0x65,0x72,0x69,0x6B,0x61,0x6E,0x73,0x6B,0x20,0x65,0x6E,0x67,0x65,0x6C,0x73,0x6B,0}; //"amerikansk engelsk" -static UChar esFor_en[] = {0x69,0x6E,0x67,0x6C,0xE9,0x73,0}; //"ingles" with acute on e -static UChar esFor_en_US[] = {0x69,0x6E,0x67,0x6C,0xE9,0x73,0x20,0x28,0x45,0x45,0x2E,0x20,0x55,0x55,0x2E,0x29,0}; //"ingles (EE. UU.)" ... -static UChar esFor_en_US_D[] = {0x69,0x6E,0x67,0x6C,0xE9,0x73,0x20,0x65,0x73,0x74,0x61,0x64,0x6F,0x75,0x6E,0x69,0x64,0x65,0x6E,0x73,0x65,0}; //"ingles estadounidense" ... +static UChar daFor_en_cabud[] = {0x65,0x6E,0x67,0x65,0x6C,0x73,0x6B,0x20,0x28,0x62,0x75,0x64,0x64,0x68,0x69,0x73,0x74,0x69,0x73,0x6B,0x20, + 0x6B,0x61,0x6C,0x65,0x6E,0x64,0x65,0x72,0x29,0}; //"engelsk (buddhistisk kalender)" +static UChar daFor_en_GB[] = {0x65,0x6E,0x67,0x65,0x6C,0x73,0x6B,0x20,0x28,0x55,0x4B,0x29,0}; //"engelsk (UK)" // Apple change +static UChar daFor_en_GB_S[] = {0x65,0x6E,0x67,0x65,0x6C,0x73,0x6B,0x20,0x28,0x55,0x4B,0x29,0}; //"engelsk (UK)" +static UChar daFor_en_GB_D[] = {0x62,0x72,0x69,0x74,0x69,0x73,0x6B,0x20,0x65,0x6E,0x67,0x65,0x6C,0x73,0x6B,0}; //"britisk engelsk" +static UChar esFor_en[] = {0x69,0x6E,0x67,0x6C,0xE9,0x73,0}; //"ingles" with acute on the e +static UChar esFor_en_GB[] = {0x69,0x6E,0x67,0x6C,0xE9,0x73,0x20,0x28,0x52,0x55,0x29,0}; //"ingles (RU)" ... // Apple change +static UChar esFor_en_GB_S[] = {0x69,0x6E,0x67,0x6C,0xE9,0x73,0x20,0x28,0x52,0x55,0x29,0}; //"ingles (RU)" ... +static UChar esFor_en_GB_D[] = {0x69,0x6E,0x67,0x6C,0xE9,0x73,0x20,0x62,0x72,0x69,0x74,0xE1,0x6E,0x69,0x63,0x6F,0}; //"ingles britanico" with acute on the e, a +static UChar ruFor_uz_Latn[] = {0x0443,0x0437,0x0431,0x0435,0x043A,0x0441,0x043A,0x0438,0x0439,0x20,0x28,0x043B,0x0430,0x0442,0x0438,0x043D,0x0438,0x0446,0x0430,0x29,0}; // all lowercase #if !UCONFIG_NO_BREAK_ITERATION static UChar daFor_en_T[] = {0x45,0x6E,0x67,0x65,0x6C,0x73,0x6B,0}; //"Engelsk" -static UChar daFor_en_US_T[] = {0x45,0x6E,0x67,0x65,0x6C,0x73,0x6B,0x20,0x28,0x55,0x53,0x41,0x29,0}; //"Engelsk (USA)" -static UChar daFor_en_US_DT[] = {0x41,0x6D,0x65,0x72,0x69,0x6B,0x61,0x6E,0x73,0x6B,0x20,0x65,0x6E,0x67,0x65,0x6C,0x73,0x6B,0}; //"Amerikansk engelsk" -static UChar esFor_en_T[] = {0x49,0x6E,0x67,0x6C,0xE9,0x73,0}; //"Ingles" ... -static UChar esFor_en_US_T[] = {0x49,0x6E,0x67,0x6C,0xE9,0x73,0x20,0x28,0x45,0x45,0x2E,0x20,0x55,0x55,0x2E,0x29,0}; //"Ingles (EE. UU.)" ... -static UChar esFor_en_US_DT[] = {0x49,0x6E,0x67,0x6C,0xE9,0x73,0x20,0x65,0x73,0x74,0x61,0x64,0x6F,0x75,0x6E,0x69,0x64,0x65,0x6E,0x73,0x65,0}; //"Ingles estadounidense" ... +static UChar daFor_en_cabudT[]= {0x45,0x6E,0x67,0x65,0x6C,0x73,0x6B,0x20,0x28,0x62,0x75,0x64,0x64,0x68,0x69,0x73,0x74,0x69,0x73,0x6B,0x20, + 0x6B,0x61,0x6C,0x65,0x6E,0x64,0x65,0x72,0x29,0}; //"Engelsk (buddhistisk kalender)" +static UChar daFor_en_GB_T[] = {0x45,0x6E,0x67,0x65,0x6C,0x73,0x6B,0x20,0x28,0x55,0x4B,0x29,0}; //"Engelsk (UK)" // Apple change +static UChar daFor_en_GB_ST[] = {0x45,0x6E,0x67,0x65,0x6C,0x73,0x6B,0x20,0x28,0x55,0x4B,0x29,0}; //"Engelsk (UK)" +static UChar daFor_en_GB_DT[] = {0x42,0x72,0x69,0x74,0x69,0x73,0x6B,0x20,0x65,0x6E,0x67,0x65,0x6C,0x73,0x6B,0}; //"Britisk engelsk" +static UChar esFor_en_T[] = {0x49,0x6E,0x67,0x6C,0xE9,0x73,0}; //"Ingles" with acute on the e +static UChar esFor_en_GB_T[] = {0x49,0x6E,0x67,0x6C,0xE9,0x73,0x20,0x28,0x52,0x55,0x29,0}; //"Ingles (RU)" ... // Apple change +static UChar esFor_en_GB_ST[] = {0x49,0x6E,0x67,0x6C,0xE9,0x73,0x20,0x28,0x52,0x55,0x29,0}; //"Ingles (RU)" ... +static UChar esFor_en_GB_DT[] = {0x49,0x6E,0x67,0x6C,0xE9,0x73,0x20,0x62,0x72,0x69,0x74,0xE1,0x6E,0x69,0x63,0x6F,0}; //"Ingles britanico" with acute on the e, a +static UChar ruFor_uz_Latn_T[]= {0x0423,0x0437,0x0431,0x0435,0x043A,0x0441,0x043A,0x0438,0x0439,0x20,0x28,0x043B,0x0430,0x0442,0x0438,0x043D,0x0438,0x0446,0x0430,0x29,0}; // first char upper #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ static const LocNameDispContextItem ctxtItems[] = { - { "da", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, en, daFor_en }, - { "da", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, en_US, daFor_en_US }, - { "da", UDISPCTX_DIALECT_NAMES, UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, en_US, daFor_en_US_D }, - { "es", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, en, esFor_en }, - { "es", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, en_US, esFor_en_US }, - { "es", UDISPCTX_DIALECT_NAMES, UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, en_US, esFor_en_US_D }, + { "da", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, UDISPCTX_LENGTH_FULL, en, daFor_en }, + { "da", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, UDISPCTX_LENGTH_FULL, en_cabud, daFor_en_cabud }, + { "da", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, UDISPCTX_LENGTH_FULL, en_GB, daFor_en_GB }, + { "da", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, UDISPCTX_LENGTH_SHORT, en_GB, daFor_en_GB_S }, + { "da", UDISPCTX_DIALECT_NAMES, UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, UDISPCTX_LENGTH_FULL, en_GB, daFor_en_GB_D }, + { "es", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, UDISPCTX_LENGTH_FULL, en, esFor_en }, + { "es", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, UDISPCTX_LENGTH_FULL, en_GB, esFor_en_GB }, + { "es", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, UDISPCTX_LENGTH_SHORT, en_GB, esFor_en_GB_S }, + { "es", UDISPCTX_DIALECT_NAMES, UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, UDISPCTX_LENGTH_FULL, en_GB, esFor_en_GB_D }, + { "ru", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, UDISPCTX_LENGTH_FULL, uz_Latn, ruFor_uz_Latn }, #if !UCONFIG_NO_BREAK_ITERATION - { "da", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, en, daFor_en_T }, - { "da", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, en_US, daFor_en_US_T }, - { "da", UDISPCTX_DIALECT_NAMES, UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, en_US, daFor_en_US_DT }, - { "es", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, en, esFor_en_T }, - { "es", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, en_US, esFor_en_US_T }, - { "es", UDISPCTX_DIALECT_NAMES, UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, en_US, esFor_en_US_DT }, - - { "da", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU, en, daFor_en_T }, - { "da", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU, en_US, daFor_en_US_T }, - { "da", UDISPCTX_DIALECT_NAMES, UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU, en_US, daFor_en_US_DT }, - { "es", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU, en, esFor_en_T }, - { "es", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU, en_US, esFor_en_US_T }, - { "es", UDISPCTX_DIALECT_NAMES, UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU, en_US, esFor_en_US_DT }, - - { "da", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_STANDALONE, en, daFor_en }, - { "da", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_STANDALONE, en_US, daFor_en_US }, - { "da", UDISPCTX_DIALECT_NAMES, UDISPCTX_CAPITALIZATION_FOR_STANDALONE, en_US, daFor_en_US_D }, - { "es", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_STANDALONE, en, esFor_en_T }, - { "es", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_STANDALONE, en_US, esFor_en_US_T }, - { "es", UDISPCTX_DIALECT_NAMES, UDISPCTX_CAPITALIZATION_FOR_STANDALONE, en_US, esFor_en_US_DT }, + { "da", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, UDISPCTX_LENGTH_FULL, en, daFor_en_T }, + { "da", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, UDISPCTX_LENGTH_FULL, en_cabud, daFor_en_cabudT }, + { "da", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, UDISPCTX_LENGTH_FULL, en_GB, daFor_en_GB_T }, + { "da", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, UDISPCTX_LENGTH_SHORT, en_GB, daFor_en_GB_ST }, + { "da", UDISPCTX_DIALECT_NAMES, UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, UDISPCTX_LENGTH_FULL, en_GB, daFor_en_GB_DT }, + { "es", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, UDISPCTX_LENGTH_FULL, en, esFor_en_T }, + { "es", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, UDISPCTX_LENGTH_FULL, en_GB, esFor_en_GB_T }, + { "es", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, UDISPCTX_LENGTH_SHORT, en_GB, esFor_en_GB_ST }, + { "es", UDISPCTX_DIALECT_NAMES, UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, UDISPCTX_LENGTH_FULL, en_GB, esFor_en_GB_DT }, + { "ru", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, UDISPCTX_LENGTH_FULL, uz_Latn, ruFor_uz_Latn_T }, + + { "da", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU, UDISPCTX_LENGTH_FULL, en, daFor_en_T }, + { "da", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU, UDISPCTX_LENGTH_FULL, en_cabud, daFor_en_cabudT }, + { "da", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU, UDISPCTX_LENGTH_FULL, en_GB, daFor_en_GB_T }, + { "da", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU, UDISPCTX_LENGTH_SHORT, en_GB, daFor_en_GB_ST }, + { "da", UDISPCTX_DIALECT_NAMES, UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU, UDISPCTX_LENGTH_FULL, en_GB, daFor_en_GB_DT }, + { "es", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU, UDISPCTX_LENGTH_FULL, en, esFor_en_T }, + { "es", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU, UDISPCTX_LENGTH_FULL, en_GB, esFor_en_GB_T }, + { "es", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU, UDISPCTX_LENGTH_SHORT, en_GB, esFor_en_GB_ST }, + { "es", UDISPCTX_DIALECT_NAMES, UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU, UDISPCTX_LENGTH_FULL, en_GB, esFor_en_GB_DT }, + { "ru", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU, UDISPCTX_LENGTH_FULL, uz_Latn, ruFor_uz_Latn_T }, + + { "da", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_STANDALONE, UDISPCTX_LENGTH_FULL, en, daFor_en }, + { "da", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_STANDALONE, UDISPCTX_LENGTH_FULL, en_cabud, daFor_en_cabud }, + { "da", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_STANDALONE, UDISPCTX_LENGTH_FULL, en_GB, daFor_en_GB }, + { "da", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_STANDALONE, UDISPCTX_LENGTH_SHORT, en_GB, daFor_en_GB_S }, + { "da", UDISPCTX_DIALECT_NAMES, UDISPCTX_CAPITALIZATION_FOR_STANDALONE, UDISPCTX_LENGTH_FULL, en_GB, daFor_en_GB_D }, + { "es", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_STANDALONE, UDISPCTX_LENGTH_FULL, en, esFor_en_T }, + { "es", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_STANDALONE, UDISPCTX_LENGTH_FULL, en_GB, esFor_en_GB_T }, + { "es", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_STANDALONE, UDISPCTX_LENGTH_SHORT, en_GB, esFor_en_GB_ST }, + { "es", UDISPCTX_DIALECT_NAMES, UDISPCTX_CAPITALIZATION_FOR_STANDALONE, UDISPCTX_LENGTH_FULL, en_GB, esFor_en_GB_DT }, + { "ru", UDISPCTX_STANDARD_NAMES, UDISPCTX_CAPITALIZATION_FOR_STANDALONE, UDISPCTX_LENGTH_FULL, uz_Latn, ruFor_uz_Latn_T }, #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ - { NULL, (UDisplayContext)0, (UDisplayContext)0, NULL, NULL } + { NULL, (UDisplayContext)0, (UDisplayContext)0, (UDisplayContext)0, NULL, NULL } }; void LocaleDisplayNamesTest::TestUldnDisplayContext() { const LocNameDispContextItem * ctxtItemPtr; for (ctxtItemPtr = ctxtItems; ctxtItemPtr->displayLocale != NULL; ctxtItemPtr++) { - UDisplayContext contexts[2] = {ctxtItemPtr->dialectHandling, ctxtItemPtr->capitalization}; + UDisplayContext contexts[3] = {ctxtItemPtr->dialectHandling, ctxtItemPtr->capitalization, ctxtItemPtr->displayLength}; UErrorCode status = U_ZERO_ERROR; - ULocaleDisplayNames * uldn = uldn_openForContext(ctxtItemPtr->displayLocale, contexts, 2, &status); + ULocaleDisplayNames * uldn = uldn_openForContext(ctxtItemPtr->displayLocale, contexts, 3, &status); if (U_FAILURE(status)) { errln(UnicodeString("FAIL: uldn_openForContext failed for locale ") + ctxtItemPtr->displayLocale + - ", dialectHandling " + ctxtItemPtr->dialectHandling + ", capitalization " + ctxtItemPtr->capitalization); + ", dialectHandling " + ctxtItemPtr->dialectHandling + + ", capitalization " + ctxtItemPtr->capitalization + + ", displayLength " + ctxtItemPtr->displayLength); } else { UDisplayContext dialectHandling = uldn_getContext(uldn, UDISPCTX_TYPE_DIALECT_HANDLING, &status); UDisplayContext capitalization = uldn_getContext(uldn, UDISPCTX_TYPE_CAPITALIZATION, &status); + UDisplayContext displayLength = uldn_getContext(uldn, UDISPCTX_TYPE_DISPLAY_LENGTH, &status); if (U_FAILURE(status)) { errln(UnicodeString("FAIL: uldn_getContext status ") + (int)status); - } else if (dialectHandling != ctxtItemPtr->dialectHandling || capitalization != ctxtItemPtr->capitalization) { - errln("FAIL: uldn_getContext retrieved incorrect dialectHandling or capitalization"); + } else if (dialectHandling != ctxtItemPtr->dialectHandling || + capitalization != ctxtItemPtr->capitalization || + displayLength != ctxtItemPtr->displayLength) { + errln("FAIL: uldn_getContext retrieved incorrect dialectHandling, capitalization, or displayLength"); } else { UChar nameBuf[ULOC_FULLNAME_CAPACITY]; int32_t len = uldn_localeDisplayName(uldn, ctxtItemPtr->localeToBeNamed, nameBuf, ULOC_FULLNAME_CAPACITY, &status);