From: Peter Edberg Date: Thu, 26 Mar 2020 06:21:17 +0000 (-0700) Subject: ICU-13259 Check whether ulocdata_getDelimiter works in various locales including... X-Git-Tag: release-68-rc~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0583afebf33cffe4a8560f64acfa75b3e14f34d8;p=icu ICU-13259 Check whether ulocdata_getDelimiter works in various locales including fr_CA --- diff --git a/icu4c/source/test/cintltst/cldrtest.c b/icu4c/source/test/cintltst/cldrtest.c index c13ceb9e906..e50ccb3cd1f 100644 --- a/icu4c/source/test/cintltst/cldrtest.c +++ b/icu4c/source/test/cintltst/cldrtest.c @@ -1333,7 +1333,7 @@ static void TestCoverage(void){ status = U_ZERO_ERROR; ulocdata_getDelimiter(uld, types[i], result, 32, &status); if (U_FAILURE(status)){ - log_err("ulocdata_getgetDelimiter error with type %d", types[i]); + log_err("ulocdata_getDelimiter error with type %d", types[i]); } } @@ -1342,6 +1342,49 @@ static void TestCoverage(void){ ulocdata_close(uld); } +typedef struct { + const char* locale; + const UChar* quoteStart; + const UChar* quoteEnd; +} TestDelimitersItem; + +static const TestDelimitersItem testDelimsItems[] = { + { "fr_CA", u"«", u"»" }, // inherited from fr + { "de_CH", u"„", u"“" }, // inherited from de + { "es_MX", u"“", u"”" }, // inherited from es_419 + { "ja", u"「", u"」" }, + { NULL, NULL, NULL } +}; + +enum { kUDelimMax = 8, kBDelimMax = 16 }; +static void TestDelimiters(void){ + const TestDelimitersItem* itemPtr = testDelimsItems; + for (; itemPtr->locale != NULL; itemPtr++) { + UErrorCode status = U_ZERO_ERROR; + ULocaleData *uld = ulocdata_open(itemPtr->locale, &status); + if (U_FAILURE(status)) { + log_data_err("ulocdata_open for locale %s fails: %s\n", itemPtr->locale, u_errorName(status)); + } else { + UChar quoteStart[kUDelimMax], quoteEnd[kUDelimMax]; + (void)ulocdata_getDelimiter(uld, ULOCDATA_QUOTATION_START, quoteStart, kUDelimMax, &status); + (void)ulocdata_getDelimiter(uld, ULOCDATA_QUOTATION_END, quoteEnd, kUDelimMax, &status); + if (U_FAILURE(status)) { + log_err("ulocdata_getDelimiter ULOCDATA_QUOTATION_START/END for locale %s fails: %s\n", itemPtr->locale, u_errorName(status)); + } else if (u_strcmp(quoteStart,itemPtr->quoteStart)!=0 || u_strcmp(quoteEnd,itemPtr->quoteEnd)!=0) { + char expStart[kBDelimMax], expEnd[kBDelimMax], getStart[kBDelimMax], getEnd[kBDelimMax]; + u_austrcpy(expStart, itemPtr->quoteStart); + u_austrcpy(expEnd, itemPtr->quoteEnd); + u_austrcpy(getStart, quoteStart); + u_austrcpy(getEnd, quoteEnd); + log_err("ulocdata_getDelimiter ULOCDATA_QUOTATION_START/END for locale %s, expect %s..%s, get %s..%s\n", + itemPtr->locale, expStart, expEnd, getStart, getEnd); + } + ulocdata_close(uld); + } + } +} + + static void TestIndexChars(void) { /* Very basic test of ULOCDATA_ES_INDEX. * No comprehensive test of data, just basic check that the code path is alive. @@ -1531,6 +1574,7 @@ void addCLDRTest(TestNode** root) TESTCASE(TestExemplarSet); TESTCASE(TestLocaleDisplayPattern); TESTCASE(TestCoverage); + TESTCASE(TestDelimiters); TESTCASE(TestIndexChars); TESTCASE(TestAvailableIsoCodes); }