ICU-4061 Make sure that all locales have a valid date/time format.

X-SVN-Rev: 18094
This commit is contained in:
George Rhoten 2005-06-30 05:10:59 +00:00
parent d7cc623449
commit 1ed751762f

View file

@ -32,6 +32,7 @@
#include <math.h>
static void TestExtremeDates(void);
static void TestAllLocales(void);
#define LEN(a) (sizeof(a)/sizeof(a[0]))
@ -45,6 +46,7 @@ void addDateForTest(TestNode** root)
TESTCASE(TestSymbols);
TESTCASE(TestDateFormatCalendar);
TESTCASE(TestExtremeDates);
TESTCASE(TestAllLocales);
}
/* Testing the DateFormat API */
static void TestDateFormat()
@ -904,4 +906,25 @@ static void TestExtremeDates() {
udat_close(fmt);
}
static void TestAllLocales(void) {
int32_t idx, dateIdx, timeIdx, localeCount;
static const UDateFormatStyle style[] = {
UDAT_FULL, UDAT_LONG, UDAT_MEDIUM, UDAT_SHORT
};
localeCount = uloc_countAvailable();
for (idx = 0; idx < localeCount; idx++) {
for (dateIdx = 0; dateIdx < (int32_t)(sizeof(style)/sizeof(style[0])); dateIdx++) {
for (timeIdx = 0; timeIdx < (int32_t)(sizeof(style)/sizeof(style[0])); timeIdx++) {
UErrorCode status = U_ZERO_ERROR;
udat_close(udat_open(style[dateIdx], style[timeIdx],
uloc_getAvailable(idx), NULL, 0, NULL, 0, &status));
if (U_FAILURE(status)) {
log_err("FAIL: udat_open(%s) failed with (%s) dateIdx=%d, timeIdx=%d\n",
uloc_getAvailable(idx), u_errorName(status), dateIdx, timeIdx);
}
}
}
}
}
#endif /* #if !UCONFIG_NO_FORMATTING */