Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: source/test/cintltst/cloctst.c

Issue 1621843002: ICU 56 update step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@561
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/test/cintltst/cldrtest.c ('k') | source/test/cintltst/cmsccoll.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /******************************************************************** 1 /********************************************************************
2 * COPYRIGHT: 2 * COPYRIGHT:
3 * Copyright (c) 1997-2014, International Business Machines Corporation and 3 * Copyright (c) 1997-2015, International Business Machines Corporation and
4 * others. All Rights Reserved. 4 * others. All Rights Reserved.
5 ********************************************************************/ 5 ********************************************************************/
6 /***************************************************************************** 6 /*****************************************************************************
7 * 7 *
8 * File CLOCTST.C 8 * File CLOCTST.C
9 * 9 *
10 * Modification History: 10 * Modification History:
11 * Name Description 11 * Name Description
12 * Madhu Katragadda Ported for C API 12 * Madhu Katragadda Ported for C API
13 ****************************************************************************** 13 ******************************************************************************
(...skipping 1653 matching lines...) Expand 10 before | Expand all | Expand 10 after
1667 } 1667 }
1668 1668
1669 #endif 1669 #endif
1670 1670
1671 } 1671 }
1672 1672
1673 static void TestKeywordVariants(void) 1673 static void TestKeywordVariants(void)
1674 { 1674 {
1675 static const struct { 1675 static const struct {
1676 const char *localeID; 1676 const char *localeID;
1677 const char *expectedLocaleID; 1677 const char *expectedLocaleID; /* uloc_getName */
1678 const char *expectedLocaleIDNoKeywords; 1678 const char *expectedLocaleIDNoKeywords; /* uloc_getBaseName */
1679 const char *expectedCanonicalID; 1679 const char *expectedCanonicalID; /* uloc_canonicalize */
1680 const char *expectedKeywords[10]; 1680 const char *expectedKeywords[10];
1681 int32_t numKeywords; 1681 int32_t numKeywords;
1682 UErrorCode expectedStatus; /* from uloc_openKeywords */ 1682 UErrorCode expectedStatus; /* from uloc_openKeywords */
1683 } testCases[] = { 1683 } testCases[] = {
1684 { 1684 {
1685 "de_DE@ currency = euro; C o ll A t i o n = Phonebook ; C alen dar = buddhist ", 1685 "de_DE@ currency = euro; C o ll A t i o n = Phonebook ; C alen dar = buddhist ",
1686 "de_DE@calendar=buddhist;collation=Phonebook;currency=euro", 1686 "de_DE@calendar=buddhist;collation=Phonebook;currency=euro",
1687 "de_DE", 1687 "de_DE",
1688 "de_DE@calendar=buddhist;collation=Phonebook;currency=euro", 1688 "de_DE@calendar=buddhist;collation=Phonebook;currency=euro",
1689 {"calendar", "collation", "currency"}, 1689 {"calendar", "collation", "currency"},
1690 3, 1690 3,
1691 U_ZERO_ERROR 1691 U_ZERO_ERROR
1692 }, 1692 },
1693 { 1693 {
1694 "de_DE@euro", 1694 "de_DE@euro",
1695 "de_DE@euro", 1695 "de_DE@euro",
1696 "de_DE", 1696 "de_DE@euro", /* we probably should strip off the POSIX style vari ant @euro see #11690 */
1697 "de_DE@currency=EUR", 1697 "de_DE@currency=EUR",
1698 {"","","","","","",""}, 1698 {"","","","","","",""},
1699 0, 1699 0,
1700 U_INVALID_FORMAT_ERROR /* must have '=' after '@' */ 1700 U_INVALID_FORMAT_ERROR /* must have '=' after '@' */
1701 }, 1701 },
1702 { 1702 {
1703 "de_DE@euro;collation=phonebook", 1703 "de_DE@euro;collation=phonebook", /* The POSIX style variant @euro cannot be combined with key=value? */
1704 "de_DE", /* error result; bad format */ 1704 "de_DE", /* getName returns de_DE - should be INVALID_FORMAT_ERROR? */
1705 "de_DE", /* error result; bad format */ 1705 "de_DE", /* getBaseName returns de_DE - should be INVALID_FORMAT_ERR OR? see #11690 */
1706 "de_DE", /* error result; bad format */ 1706 "de_DE", /* canonicalize returns de_DE - should be INVALID_FORMAT_ER ROR? */
1707 {"","","","","","",""}, 1707 {"","","","","","",""},
1708 0, 1708 0,
1709 U_INVALID_FORMAT_ERROR 1709 U_INVALID_FORMAT_ERROR
1710 },
1711 {
1712 "de_DE@collation=",
1713 0, /* expected getName to fail */
1714 "de_DE", /* getBaseName returns de_DE - should be INVALID_FORMAT_ERR OR? see #11690 */
1715 0, /* expected canonicalize to fail */
1716 {"","","","","","",""},
1717 0,
1718 U_INVALID_FORMAT_ERROR /* must have '=' after '@' */
1710 } 1719 }
1711 }; 1720 };
1712 UErrorCode status = U_ZERO_ERROR; 1721 UErrorCode status = U_ZERO_ERROR;
1713 1722
1714 int32_t i = 0, j = 0; 1723 int32_t i = 0, j = 0;
1715 int32_t resultLen = 0; 1724 int32_t resultLen = 0;
1716 char buffer[256]; 1725 char buffer[256];
1717 UEnumeration *keywords; 1726 UEnumeration *keywords;
1718 int32_t keyCount = 0; 1727 int32_t keyCount = 0;
1719 const char *keyword = NULL; 1728 const char *keyword = NULL;
(...skipping 26 matching lines...) Expand all
1746 uenum_reset(keywords, &status); 1755 uenum_reset(keywords, &status);
1747 while((keyword = uenum_next(keywords, &keywordLen, &status))) { 1756 while((keyword = uenum_next(keywords, &keywordLen, &status))) {
1748 if(strcmp(keyword, testCases[i].expectedKeywords[j]) != 0) { 1757 if(strcmp(keyword, testCases[i].expectedKeywords[j]) != 0) {
1749 log_err("Expected to get keyword value %s, got %s\n", te stCases[i].expectedKeywords[j], keyword); 1758 log_err("Expected to get keyword value %s, got %s\n", te stCases[i].expectedKeywords[j], keyword);
1750 } 1759 }
1751 j++; 1760 j++;
1752 } 1761 }
1753 } 1762 }
1754 uenum_close(keywords); 1763 uenum_close(keywords);
1755 } 1764 }
1765
1766 status = U_ZERO_ERROR;
1756 resultLen = uloc_getName(testCases[i].localeID, buffer, 256, &status); 1767 resultLen = uloc_getName(testCases[i].localeID, buffer, 256, &status);
1757 (void)resultLen; /* Suppress set but not used warning. */ 1768 if (U_SUCCESS(status)) {
1758 if (uprv_strcmp(testCases[i].expectedLocaleID, buffer) != 0) { 1769 if (testCases[i].expectedLocaleID == 0) {
1759 log_err("Expected uloc_getName(\"%s\") => \"%s\"; got \"%s\"\n", 1770 log_err("Expected uloc_getName(\"%s\") to fail; got \"%s\"\n",
1760 testCases[i].localeID, testCases[i].expectedLocaleID, buffer ); 1771 testCases[i].localeID, buffer);
1772 } else if (uprv_strcmp(testCases[i].expectedLocaleID, buffer) != 0) {
1773 log_err("Expected uloc_getName(\"%s\") => \"%s\"; got \"%s\"\n",
1774 testCases[i].localeID, testCases[i].expectedLocaleID, bu ffer);
1775 }
1776 } else {
1777 if (testCases[i].expectedLocaleID != 0) {
1778 log_err("Expected uloc_getName(\"%s\") => \"%s\"; but returned e rror: %s\n",
1779 testCases[i].localeID, testCases[i].expectedLocaleID, bu ffer, u_errorName(status));
1780 }
1761 } 1781 }
1782
1783 status = U_ZERO_ERROR;
1784 resultLen = uloc_getBaseName(testCases[i].localeID, buffer, 256, &status );
1785 if (U_SUCCESS(status)) {
1786 if (testCases[i].expectedLocaleIDNoKeywords == 0) {
1787 log_err("Expected uloc_getBaseName(\"%s\") to fail; got \"%s\"\n ",
1788 testCases[i].localeID, buffer);
1789 } else if (uprv_strcmp(testCases[i].expectedLocaleIDNoKeywords, buff er) != 0) {
1790 log_err("Expected uloc_getBaseName(\"%s\") => \"%s\"; got \"%s\" \n",
1791 testCases[i].localeID, testCases[i].expectedLocaleIDNoKe ywords, buffer);
1792 }
1793 } else {
1794 if (testCases[i].expectedLocaleIDNoKeywords != 0) {
1795 log_err("Expected uloc_getBaseName(\"%s\") => \"%s\"; but return ed error: %s\n",
1796 testCases[i].localeID, testCases[i].expectedLocaleIDNoKe ywords, buffer, u_errorName(status));
1797 }
1798 }
1799
1800 status = U_ZERO_ERROR;
1762 resultLen = uloc_canonicalize(testCases[i].localeID, buffer, 256, &statu s); 1801 resultLen = uloc_canonicalize(testCases[i].localeID, buffer, 256, &statu s);
1763 if (uprv_strcmp(testCases[i].expectedCanonicalID, buffer) != 0) { 1802 if (U_SUCCESS(status)) {
1764 log_err("Expected uloc_canonicalize(\"%s\") => \"%s\"; got \"%s\"\n" , 1803 if (testCases[i].expectedCanonicalID == 0) {
1765 testCases[i].localeID, testCases[i].expectedCanonicalID, buf fer); 1804 log_err("Expected uloc_canonicalize(\"%s\") to fail; got \"%s\"\ n",
1766 } 1805 testCases[i].localeID, buffer);
1806 } else if (uprv_strcmp(testCases[i].expectedCanonicalID, buffer) != 0) {
1807 log_err("Expected uloc_canonicalize(\"%s\") => \"%s\"; got \"%s\ "\n",
1808 testCases[i].localeID, testCases[i].expectedCanonicalID, buffer);
1809 }
1810 } else {
1811 if (testCases[i].expectedCanonicalID != 0) {
1812 log_err("Expected uloc_canonicalize(\"%s\") => \"%s\"; but retur ned error: %s\n",
1813 testCases[i].localeID, testCases[i].expectedCanonicalID, buffer, u_errorName(status));
1814 }
1815 }
1767 } 1816 }
1768
1769 } 1817 }
1770 1818
1771 static void TestKeywordVariantParsing(void) 1819 static void TestKeywordVariantParsing(void)
1772 { 1820 {
1773 static const struct { 1821 static const struct {
1774 const char *localeID; 1822 const char *localeID;
1775 const char *keyword; 1823 const char *keyword;
1776 const char *expectedValue; 1824 const char *expectedValue;
1777 } testCases[] = { 1825 } testCases[] = {
1778 { "de_DE@ C o ll A t i o n = Phonebook ", "c o ll a t i o n", "Phon ebook" }, 1826 { "de_DE@ C o ll A t i o n = Phonebook ", "c o ll a t i o n", "Phon ebook" },
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
2194 const char *localeID; 2242 const char *localeID;
2195 const char *displayLocale; 2243 const char *displayLocale;
2196 UChar displayKeywordValue[500]; 2244 UChar displayKeywordValue[500];
2197 } testCases[] = { 2245 } testCases[] = {
2198 { "ca_ES@currency=ESP", "de_AT", 2246 { "ca_ES@currency=ESP", "de_AT",
2199 {0x0053, 0x0070, 0x0061, 0x006e, 0x0069, 0x0073, 0x0063, 0x0068, 0x0 065, 0x0020, 0x0050, 0x0065, 0x0073, 0x0065, 0x0074, 0x0061, 0x0000} 2247 {0x0053, 0x0070, 0x0061, 0x006e, 0x0069, 0x0073, 0x0063, 0x0068, 0x0 065, 0x0020, 0x0050, 0x0065, 0x0073, 0x0065, 0x0074, 0x0061, 0x0000}
2200 }, 2248 },
2201 { "de_AT@currency=ATS", "fr_FR", 2249 { "de_AT@currency=ATS", "fr_FR",
2202 {0x0073, 0x0063, 0x0068, 0x0069, 0x006c, 0x006c, 0x0069, 0x006e, 0x0 067, 0x0020, 0x0061, 0x0075, 0x0074, 0x0072, 0x0069, 0x0063, 0x0068, 0x0069, 0x0 065, 0x006e, 0x0000} 2250 {0x0073, 0x0063, 0x0068, 0x0069, 0x006c, 0x006c, 0x0069, 0x006e, 0x0 067, 0x0020, 0x0061, 0x0075, 0x0074, 0x0072, 0x0069, 0x0063, 0x0068, 0x0069, 0x0 065, 0x006e, 0x0000}
2203 }, 2251 },
2204 { "de_DE@currency=DEM", "it", 2252 { "de_DE@currency=DEM", "it",
2205 {0x004d, 0x0061, 0x0072, 0x0063, 0x006f, 0x0020, 0x0054, 0x0065, 0x0 064, 0x0065, 0x0073, 0x0063, 0x006f, 0x0000} 2253 {0x006d, 0x0061, 0x0072, 0x0063, 0x006f, 0x0020, 0x0074, 0x0065, 0x0 064, 0x0065, 0x0073, 0x0063, 0x006f, 0x0000}
2206 }, 2254 },
2207 { "el_GR@currency=GRD", "en", 2255 { "el_GR@currency=GRD", "en",
2208 {0x0047, 0x0072, 0x0065, 0x0065, 0x006b, 0x0020, 0x0044, 0x0072, 0x0 061, 0x0063, 0x0068, 0x006d, 0x0061, 0x0000} 2256 {0x0047, 0x0072, 0x0065, 0x0065, 0x006b, 0x0020, 0x0044, 0x0072, 0x0 061, 0x0063, 0x0068, 0x006d, 0x0061, 0x0000}
2209 }, 2257 },
2210 { "eu_ES@currency=ESP", "it_IT", 2258 { "eu_ES@currency=ESP", "it_IT",
2211 {0x0050, 0x0065, 0x0073, 0x0065, 0x0074, 0x0061, 0x0020, 0x0053, 0x0 070, 0x0061, 0x0067, 0x006e, 0x006f, 0x006c, 0x0061, 0x0000} 2259 {0x0070, 0x0065, 0x0073, 0x0065, 0x0074, 0x0061, 0x0020, 0x0073, 0x0 070, 0x0061, 0x0067, 0x006e, 0x006f, 0x006c, 0x0061, 0x0000}
2212 }, 2260 },
2213 { "de@collation=phonebook", "es", 2261 { "de@collation=phonebook", "es",
2214 {0x006F, 0x0072, 0x0064, 0x0065, 0x006E, 0x0020, 0x0064, 0x0065, 0x0 020, 0x006C, 0x0069, 0x0073, 0x0074, 0x00ED, 0x006E, 0x0020, 0x0074, 0x0065, 0x0 06C, 0x0065, 0x0066, 0x00F3, 0x006E, 0x0069, 0x0063, 0x006F, 0x0000} 2262 {0x006F, 0x0072, 0x0064, 0x0065, 0x006E, 0x0020, 0x0064, 0x0065, 0x0 020, 0x006C, 0x0069, 0x0073, 0x0074, 0x00ED, 0x006E, 0x0020, 0x0074, 0x0065, 0x0 06C, 0x0065, 0x0066, 0x00F3, 0x006E, 0x0069, 0x0063, 0x006F, 0x0000}
2215 }, 2263 },
2216 2264
2217 { "de_DE@collation=phonebook", "es", 2265 { "de_DE@collation=phonebook", "es",
2218 {0x006F, 0x0072, 0x0064, 0x0065, 0x006E, 0x0020, 0x0064, 0x0065, 0x002 0, 0x006C, 0x0069, 0x0073, 0x0074, 0x00ED, 0x006E, 0x0020, 0x0074, 0x0065, 0x006 C, 0x0065, 0x0066, 0x00F3, 0x006E, 0x0069, 0x0063, 0x006F, 0x0000} 2266 {0x006F, 0x0072, 0x0064, 0x0065, 0x006E, 0x0020, 0x0064, 0x0065, 0x002 0, 0x006C, 0x0069, 0x0073, 0x0074, 0x00ED, 0x006E, 0x0020, 0x0074, 0x0065, 0x006 C, 0x0065, 0x0066, 0x00F3, 0x006E, 0x0069, 0x0063, 0x006F, 0x0000}
2219 }, 2267 },
2220 { "es_ES@collation=traditional","de", 2268 { "es_ES@collation=traditional","de",
2221 {0x0054, 0x0072, 0x0061, 0x0064, 0x0069, 0x0074, 0x0069, 0x006f, 0x006 e, 0x0065, 0x006c, 0x006c, 0x0065, 0x0020, 0x0053, 0x006f, 0x0072, 0x0074, 0x006 9, 0x0065, 0x0072, 0x0072, 0x0065, 0x0067, 0x0065, 0x006c, 0x006e, 0x0000} 2269 {0x0054, 0x0072, 0x0061, 0x0064, 0x0069, 0x0074, 0x0069, 0x006f, 0x006 e, 0x0065, 0x006c, 0x006c, 0x0065, 0x0020, 0x0053, 0x006f, 0x0072, 0x0074, 0x006 9, 0x0065, 0x0072, 0x0072, 0x0065, 0x0067, 0x0065, 0x006c, 0x006e, 0x0000}
(...skipping 1895 matching lines...) Expand 10 before | Expand all | Expand 10 after
4117 }, { 4165 }, {
4118 "und_Ethi_ER", 4166 "und_Ethi_ER",
4119 "am_Ethi_ER", 4167 "am_Ethi_ER",
4120 "am_ER" 4168 "am_ER"
4121 }, { 4169 }, {
4122 "und_FI", 4170 "und_FI",
4123 "fi_Latn_FI", 4171 "fi_Latn_FI",
4124 "fi" 4172 "fi"
4125 }, { 4173 }, {
4126 "und_FM", 4174 "und_FM",
4127 "chk_Latn_FM", 4175 "en_Latn_FM",
4128 "chk" 4176 "en_FM"
4129 }, { 4177 }, {
4130 "und_FO", 4178 "und_FO",
4131 "fo_Latn_FO", 4179 "fo_Latn_FO",
4132 "fo" 4180 "fo"
4133 }, { 4181 }, {
4134 "und_FR", 4182 "und_FR",
4135 "fr_Latn_FR", 4183 "fr_Latn_FR",
4136 "fr" 4184 "fr"
4137 }, { 4185 }, {
4138 "und_GA", 4186 "und_GA",
(...skipping 1925 matching lines...) Expand 10 before | Expand all | Expand 10 after
6064 TEST_UNICODE_DEFINE(ULOC_KEYWORD_ASSIGN, ULOC_KEYWORD_ASSIGN_UNICODE); 6112 TEST_UNICODE_DEFINE(ULOC_KEYWORD_ASSIGN, ULOC_KEYWORD_ASSIGN_UNICODE);
6065 TEST_UNICODE_DEFINE(ULOC_KEYWORD_ITEM_SEPARATOR, ULOC_KEYWORD_ITEM_SEPARATOR_U NICODE); 6113 TEST_UNICODE_DEFINE(ULOC_KEYWORD_ITEM_SEPARATOR, ULOC_KEYWORD_ITEM_SEPARATOR_U NICODE);
6066 } 6114 }
6067 6115
6068 static void TestIsRightToLeft() { 6116 static void TestIsRightToLeft() {
6069 // API test only. More test cases in intltest/LocaleTest. 6117 // API test only. More test cases in intltest/LocaleTest.
6070 if(uloc_isRightToLeft("root") || !uloc_isRightToLeft("EN-HEBR")) { 6118 if(uloc_isRightToLeft("root") || !uloc_isRightToLeft("EN-HEBR")) {
6071 log_err("uloc_isRightToLeft() failed"); 6119 log_err("uloc_isRightToLeft() failed");
6072 } 6120 }
6073 } 6121 }
OLDNEW
« no previous file with comments | « source/test/cintltst/cldrtest.c ('k') | source/test/cintltst/cmsccoll.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698