ICU-3259 Remove the time zone option.

After fixing the time zone memory leak, I discovered that some tests call u_cleanup to test the heap functions.
So setting the time zone at the beginning of the process won't help because the value doesn't stay around.
Any tests that depend on the timezone need to set and reset the timezone.

X-SVN-Rev: 13349
This commit is contained in:
George Rhoten 2003-10-07 21:52:15 +00:00
parent 8f1deb1ece
commit 00e21ff118
5 changed files with 48 additions and 3 deletions

View File

@ -415,7 +415,8 @@ static void TestGetSetDateAPI()
ctest_setTimeZone(NULL, &status);
/*testing ucal_setTimeZone() function*/
log_verbose("\nTesting if the function ucal_setTimeZone() works fine\n");
ucal_setMillis(caldef2, d2, &status);
@ -474,6 +475,9 @@ static void TestGetSetDateAPI()
else if (zoneOffset != -28800000) {
log_err("Error in getting the time zone using ucal_get() after using ucal_setTimeZone() offset=%d\n", zoneOffset);
}
ctest_resetTimeZone();
/*----------------------------* */

View File

@ -60,6 +60,9 @@ static void TestDateFormat()
/*const char* str="yyyy.MM.dd G 'at' hh:mm:ss z";
const char t[]="2/3/76 2:50 AM";*/
/*Testing udat_open() to open a dateformat */
ctest_setTimeZone(NULL, &status);
log_verbose("\nTesting udat_open() with various parameters\n");
fr = udat_open(UDAT_FULL, UDAT_DEFAULT, "fr_FR", NULL,0, NULL, 0,&status);
if(U_FAILURE(status))
@ -325,6 +328,7 @@ static void TestDateFormat()
udat_close(fr_pat);
udat_close(copy);
ctest_resetTimeZone();
}
/*Testing udat_getSymbols() and udat_setSymbols() and udat_countSymbols()*/
@ -558,6 +562,8 @@ static void TestDateFormatCalendar() {
UDate when;
UErrorCode ec = U_ZERO_ERROR;
ctest_setTimeZone(NULL, &ec);
/* Create a formatter for date fields. */
date = udat_open(UDAT_NONE, UDAT_SHORT, "en_US", NULL, 0, NULL, 0, &ec);
if (U_FAILURE(ec)) {
@ -627,7 +633,7 @@ static void TestDateFormatCalendar() {
if (when == 986517900000.0) {
log_verbose("Ok: Parsed result: %s\n", cbuf);
} else {
log_err("FAIL: Parsed result: %s, exp 4/5/2001 5:45 PM", cbuf);
log_err("FAIL: Parsed result: %s, exp 4/5/2001 5:45 PM\n", cbuf);
}
FAIL:
@ -635,6 +641,8 @@ static void TestDateFormatCalendar() {
udat_close(time);
udat_close(full);
ucal_close(cal);
ctest_resetTimeZone();
}
/*INTERNAL FUNCTIONS USED*/

View File

@ -53,6 +53,8 @@ void TestTwoDigitYearDSTParse()
UChar *s;
int32_t pos;
ctest_setTimeZone(NULL, &status);
pattern=(UChar*)malloc(sizeof(UChar) * (strlen("EEE MMM dd HH:mm:ss.SSS zzz yyyy G")+1 ));
u_uastrcpy(pattern, "EEE MMM dd HH:mm:ss.SSS zzz yyyy G");
fullFmt= udat_open(UDAT_IGNORE, UDAT_IGNORE,"en_US",NULL,0,pattern, u_strlen(pattern),&status);
@ -94,6 +96,8 @@ void TestTwoDigitYearDSTParse()
udat_close(fmt);
free(pattern);
free(s);
ctest_resetTimeZone();
}
@ -292,6 +296,9 @@ void TestQuotePattern161()
UChar *dateString;
UErrorCode status = U_ZERO_ERROR;
const char* expStr = "04/13/1999 at 10:42:28 AM ";
ctest_setTimeZone(NULL, &status);
pattern=(UChar*)malloc(sizeof(UChar) * (strlen("MM/dd/yyyy 'at' hh:mm:ss a zzz")+1) );
u_uastrcpy(pattern, "MM/dd/yyyy 'at' hh:mm:ss a zzz");
@ -328,6 +335,7 @@ void TestQuotePattern161()
free(tzID);
free(pattern);
ctest_resetTimeZone();
}
#endif /* #if !UCONFIG_NO_FORMATTING */

View File

@ -474,6 +474,8 @@ void Test714(void)
UChar *result;
const char* expect = "7:25:43 AM";
ctest_setTimeZone(NULL, &status);
fmt= udat_open(UDAT_MEDIUM,UDAT_NONE ,"en_US_CA", NULL, -1, NULL, 0, &status);
if(U_FAILURE(status))
{
@ -495,6 +497,8 @@ void Test714(void)
}
udat_close(fmt);
ctest_resetTimeZone();
}
/*INTERNAL FUNCTION USED */

View File

@ -96,6 +96,9 @@ static void MessageFormatTest( void )
int32_t resultLengthOut,resultlength,i, patternlength;
UErrorCode status = U_ZERO_ERROR;
UDate d1=1000000000.0;
ctest_setTimeZone(NULL, &status);
str=(UChar*)malloc(sizeof(UChar) * 7);
u_uastrncpy(str, "MyDisk", 7);
resultlength=1;
@ -232,6 +235,8 @@ static void MessageFormatTest( void )
umsg_close(formatter);
}
FreeStrings();
ctest_resetTimeZone();
}
@ -347,6 +352,9 @@ static void TestNewFormatAndParseAPI(void)
UParseError parseError;
UMessageFormat* fmt = NULL;
int32_t count=0;
ctest_setTimeZone(NULL, &status);
log_verbose("Testing format and parse with parse error\n");
str=(UChar*)malloc(sizeof(UChar) * 25);
@ -428,7 +436,8 @@ static void TestNewFormatAndParseAPI(void)
free(result);
free(str);
free(tzID);
ctest_resetTimeZone();
}
/* Test u_formatMessageWithError() and u_parseMessageWithError() , format and parse sequence and round trip */
@ -448,6 +457,8 @@ static void TestSampleFormatAndParseWithError(void)
UChar ret[30];
UParseError parseError;
ctest_setTimeZone(NULL, &status);
log_verbose("Testing format and parse with parse error\n");
str=(UChar*)malloc(sizeof(UChar) * 25);
@ -521,6 +532,7 @@ static void TestSampleFormatAndParseWithError(void)
free(str);
free(tzID);
ctest_resetTimeZone();
}
/* Test u_formatMessage() and u_parseMessage() , format and parse sequence and round trip */
@ -537,6 +549,9 @@ static void TestSampleFormatAndParse()
UErrorCode status = U_ZERO_ERROR;
double value = 0.0;
UChar ret[30];
ctest_setTimeZone(NULL, &status);
log_verbose("Testing format and parse\n");
str=(UChar*)malloc(sizeof(UChar) * 25);
@ -610,6 +625,7 @@ static void TestSampleFormatAndParse()
free(str);
free(tzID);
ctest_resetTimeZone();
}
/* test message format with a choice option */
@ -765,6 +781,9 @@ static void TestMessageFormatWithValist( void )
int32_t resultLengthOut,resultlength,i, patternlength;
UErrorCode status = U_ZERO_ERROR;
UDate d1=1000000000.0;
ctest_setTimeZone(NULL, &status);
str=(UChar*)malloc(sizeof(UChar) * 7);
u_uastrcpy(str, "MyDisk");
resultlength=1;
@ -798,6 +817,8 @@ static void TestMessageFormatWithValist( void )
free(result);
free(str);
FreeStrings();
ctest_resetTimeZone();
}
static void CallParseMessage(const char* locale, UChar* pattern, int32_t patternLength,