ICU-5196 Skip Windows locales that don't have a corresponding ICU locale ID. Generate random doubles as the quotient of two int64_ts.

X-SVN-Rev: 19619
This commit is contained in:
Eric Mader 2006-05-05 23:21:23 +00:00
parent 5b3447592a
commit 79df33682b
3 changed files with 19 additions and 3 deletions

View file

@ -236,10 +236,10 @@ void Win32DateFormat::formatDate(const SYSTEMTIME *st, UnicodeString &appendTo)
if (result == 0) {
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
int newLength = GetDateFormatW(fLCID, dfFlags[fDateStyle], st, NULL, NULL, 0);
int newLength = GetDateFormatW(fLCID, dfFlags[fDateStyle - kDateOffset], st, NULL, NULL, 0);
buffer = NEW_ARRAY(UChar, newLength);
GetDateFormatW(fLCID, dfFlags[fDateStyle], st, NULL, buffer, newLength);
GetDateFormatW(fLCID, dfFlags[fDateStyle - kDateOffset], st, NULL, buffer, newLength);
}
}

View file

@ -114,6 +114,11 @@ void Win32DateTimeTest::testLocales(TestLog *log)
WCHAR longDateFormat[81], longTimeFormat[81], wdBuffer[256], wtBuffer[256];
int32_t calType = 0;
// NULL localeID means ICU didn't recognize this locale
if (lcidRecords[i].localeID == NULL) {
continue;
}
GetLocaleInfoW(lcidRecords[i].lcid, LOCALE_SLONGDATE, longDateFormat, 81);
GetLocaleInfoW(lcidRecords[i].lcid, LOCALE_STIMEFORMAT, longTimeFormat, 81);
GetLocaleInfoW(lcidRecords[i].lcid, LOCALE_RETURN_NUMBER|LOCALE_ICALENDARTYPE, (LPWSTR) calType, sizeof(int32_t));

View file

@ -86,13 +86,19 @@ static double randomDouble(void)
srand((unsigned)time(NULL));
initialized = TRUE;
}
#if 0
do {
/* Assume rand has at least 12 bits of precision */
for (i = 0; i < sizeof(ran); i += 1) {
((char*)&ran)[i] = (char)((rand() & 0x0FF0) >> 4);
}
} while (_isnan(ran));
#else
int64_t numerator = randomInt64();
int64_t denomenator = randomInt64();
ran = (double)numerator / (double)denomenator;
#endif
return ran;
}
@ -259,6 +265,11 @@ void Win32NumberTest::testLocales(TestLog *log)
UErrorCode status = U_ZERO_ERROR;
char localeID[128];
// NULL localeID means ICU didn't recognize the lcid
if (lcidRecords[i].localeID == NULL) {
continue;
}
strcpy(localeID, lcidRecords[i].localeID);
if (strchr(localeID, '@') > 0) {