mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 06:25:30 +00:00
ICU-6076 Reduce crashes and valgrind errors in tests for easier diagnostics.
X-SVN-Rev: 23457
This commit is contained in:
parent
8244ab6864
commit
8bc5d287d9
4 changed files with 34 additions and 52 deletions
|
@ -61,7 +61,7 @@ static void TestCalendar()
|
|||
UCalendar *caldef = 0, *caldef2 = 0, *calfr = 0, *calit = 0;
|
||||
UEnumeration* uenum = NULL;
|
||||
int32_t count, count2, i,j;
|
||||
UChar *tzID = 0;
|
||||
UChar tzID[4];
|
||||
UChar *tzdname = 0;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UDate now;
|
||||
|
@ -215,7 +215,6 @@ static void TestCalendar()
|
|||
/*Testing the ucal_open() function*/
|
||||
status = U_ZERO_ERROR;
|
||||
log_verbose("\nTesting the ucal_open()\n");
|
||||
tzID=(UChar*)malloc(sizeof(UChar) * 4);
|
||||
u_uastrcpy(tzID, "PST");
|
||||
caldef=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status);
|
||||
if(U_FAILURE(status)){
|
||||
|
@ -393,7 +392,6 @@ static void TestCalendar()
|
|||
ucal_close(calit);
|
||||
/*closing the UDateFormat used */
|
||||
udat_close(datdef);
|
||||
free(tzID);
|
||||
free(result);
|
||||
free(tzdname);
|
||||
}
|
||||
|
@ -404,7 +402,7 @@ static void TestCalendar()
|
|||
static void TestGetSetDateAPI()
|
||||
{
|
||||
UCalendar *caldef = 0, *caldef2 = 0;
|
||||
UChar *tzID =0;
|
||||
UChar tzID[4];
|
||||
UDate d1;
|
||||
int32_t hour;
|
||||
int32_t zoneOffset;
|
||||
|
@ -414,7 +412,6 @@ static void TestGetSetDateAPI()
|
|||
UChar temp[30];
|
||||
|
||||
log_verbose("\nOpening the calendars()\n");
|
||||
tzID=(UChar*)malloc(sizeof(UChar) * 4);
|
||||
u_strcpy(tzID, fgGMTID);
|
||||
/*open the calendars used */
|
||||
caldef=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status);
|
||||
|
@ -588,8 +585,6 @@ static void TestGetSetDateAPI()
|
|||
ucal_close(caldef);
|
||||
ucal_close(caldef2);
|
||||
udat_close(datdef);
|
||||
free(tzID);
|
||||
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------- */
|
||||
|
@ -599,12 +594,11 @@ static void TestGetSetDateAPI()
|
|||
static void TestFieldGetSet()
|
||||
{
|
||||
UCalendar *cal = 0;
|
||||
UChar *tzID = 0;
|
||||
UChar tzID[4];
|
||||
UDateFormat *datdef = 0;
|
||||
UDate d1;
|
||||
UErrorCode status=U_ZERO_ERROR;
|
||||
log_verbose("\nFetching pointer to UCalendar using the ucal_open()\n");
|
||||
tzID=(UChar*)malloc(sizeof(UChar) * 4);
|
||||
u_strcpy(tzID, fgGMTID);
|
||||
/*open the calendar used */
|
||||
cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status);
|
||||
|
@ -730,8 +724,6 @@ static void TestFieldGetSet()
|
|||
|
||||
ucal_close(cal);
|
||||
udat_close(datdef);
|
||||
free(tzID);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -744,7 +736,7 @@ static void TestAddRollExtensive()
|
|||
{
|
||||
UCalendar *cal = 0;
|
||||
int32_t i,limit;
|
||||
UChar* tzID = 0;
|
||||
UChar tzID[4];
|
||||
UCalendarDateFields e;
|
||||
int32_t y,m,d,hr,min,sec,ms;
|
||||
int32_t maxlimit = 40;
|
||||
|
@ -753,7 +745,6 @@ static void TestAddRollExtensive()
|
|||
|
||||
log_verbose("Testing add and roll extensively\n");
|
||||
|
||||
tzID=(UChar*)malloc(sizeof(UChar) * 4);
|
||||
u_uastrcpy(tzID, "PST");
|
||||
/*open the calendar used */
|
||||
cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_GREGORIAN, &status);;
|
||||
|
@ -900,7 +891,6 @@ static void TestAddRollExtensive()
|
|||
}
|
||||
|
||||
ucal_close(cal);
|
||||
free(tzID);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------ */
|
||||
|
@ -909,11 +899,10 @@ static void TestGetLimits()
|
|||
{
|
||||
UCalendar *cal = 0;
|
||||
int32_t min, max, gr_min, le_max, ac_min, ac_max, val;
|
||||
UChar* tzID = 0;
|
||||
UChar tzID[4];
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
|
||||
tzID=(UChar*)malloc(sizeof(UChar) * 4);
|
||||
u_uastrcpy(tzID, "PST");
|
||||
/*open the calendar used */
|
||||
cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_GREGORIAN, &status);;
|
||||
|
@ -992,7 +981,6 @@ static void TestGetLimits()
|
|||
|
||||
|
||||
ucal_close(cal);
|
||||
free(tzID);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1011,9 +999,8 @@ static void TestDOWProgression()
|
|||
UDate date1;
|
||||
int32_t delta=24;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UChar* tzID = 0;
|
||||
UChar tzID[4];
|
||||
char tempMsgBuf[256];
|
||||
tzID=(UChar*)malloc(sizeof(UChar) * 4);
|
||||
u_strcpy(tzID, fgGMTID);
|
||||
/*open the calendar used */
|
||||
cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status);;
|
||||
|
@ -1060,8 +1047,6 @@ static void TestDOWProgression()
|
|||
|
||||
ucal_close(cal);
|
||||
udat_close(datfor);
|
||||
free(tzID);
|
||||
|
||||
}
|
||||
|
||||
/* ------------------------------------- */
|
||||
|
@ -1087,10 +1072,9 @@ static void testZones(int32_t yr, int32_t mo, int32_t dt, int32_t hr, int32_t mn
|
|||
double temp;
|
||||
UDateFormat *datfor = 0;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UChar* tzID = 0;
|
||||
UChar tzID[4];
|
||||
char tempMsgBuf[256];
|
||||
|
||||
tzID=(UChar*)malloc(sizeof(UChar) * 4);
|
||||
u_strcpy(tzID, fgGMTID);
|
||||
gmtcal=ucal_open(tzID, 3, "en_US", UCAL_TRADITIONAL, &status);;
|
||||
if (U_FAILURE(status)) {
|
||||
|
@ -1158,7 +1142,6 @@ static void testZones(int32_t yr, int32_t mo, int32_t dt, int32_t hr, int32_t mn
|
|||
ucal_close(gmtcal);
|
||||
ucal_close(cal);
|
||||
udat_close(datfor);
|
||||
free(tzID);
|
||||
}
|
||||
|
||||
/* ------------------------------------- */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/********************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 1997-2006, International Business Machines Corporation and
|
||||
* Copyright (c) 1997-2008, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
********************************************************************/
|
||||
/********************************************************************************
|
||||
|
@ -202,12 +202,11 @@ void Test4059917()
|
|||
UDateFormat* def;
|
||||
UChar *myDate;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UChar *pattern;
|
||||
UChar pattern[11];
|
||||
UChar tzID[4];
|
||||
|
||||
log_verbose("Testing apply pattern and to pattern regressively\n");
|
||||
u_uastrcpy(tzID, "PST");
|
||||
pattern=(UChar*)malloc(sizeof(UChar) * 11);
|
||||
u_uastrcpy(pattern, "yyyy/MM/dd");
|
||||
log_verbose("%s\n", austrdup(pattern) );
|
||||
def = udat_open(UDAT_IGNORE,UDAT_IGNORE,NULL,tzID,-1,pattern, u_strlen(pattern),&status);
|
||||
|
@ -232,9 +231,7 @@ void Test4059917()
|
|||
u_uastrcpy(myDate, "19700112");
|
||||
aux917( def, myDate );
|
||||
udat_close(def);
|
||||
free(pattern);
|
||||
free(myDate);
|
||||
|
||||
}
|
||||
|
||||
void aux917( UDateFormat *fmt, UChar* str)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/********************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 1997-2006, International Business Machines Corporation and
|
||||
* Copyright (c) 1997-2008, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
********************************************************************/
|
||||
/********************************************************************************
|
||||
|
@ -131,6 +131,7 @@ static void MessageFormatTest( void )
|
|||
}
|
||||
if(U_FAILURE(status)){
|
||||
log_err("ERROR: failure in message format on testcase %d: %s\n", i, myErrorName(status) );
|
||||
continue;
|
||||
}
|
||||
if(u_strcmp(result, testResultStrings[i])==0){
|
||||
log_verbose("PASS: MessagFormat successful on testcase : %d\n", i);
|
||||
|
@ -287,7 +288,7 @@ static void TestSampleMessageFormat(void)
|
|||
if(U_FAILURE(status)){
|
||||
log_err("Error: failure in message format on test#1: %s\n", myErrorName(status));
|
||||
}
|
||||
if(u_strcmp(result, expected)==0)
|
||||
else if(u_strcmp(result, expected)==0)
|
||||
log_verbose("PASS: MessagFormat successful on test#1\n");
|
||||
else{
|
||||
log_err("FAIL: Error in MessageFormat on test#1 \n GOT: %s EXPECTED: %s\n",
|
||||
|
@ -318,7 +319,7 @@ static void TestSampleMessageFormat(void)
|
|||
if(U_FAILURE(status)){
|
||||
log_err("Error: failure in message format on test#2 : %s\n", myErrorName(status));
|
||||
}
|
||||
if(u_strcmp(result, expected)==0)
|
||||
else if(u_strcmp(result, expected)==0)
|
||||
log_verbose("PASS: MessagFormat successful on test#2\n");
|
||||
else{
|
||||
log_err("FAIL: Error in MessageFormat on test#2\n GOT: %s EXPECTED: %s\n",
|
||||
|
@ -343,7 +344,7 @@ static void TestSampleMessageFormat(void)
|
|||
if(U_FAILURE(status)){
|
||||
log_err("Error: failure in message format on test#3 : %s\n", myErrorName(status));
|
||||
}
|
||||
if(u_strcmp(result, expected)==0)
|
||||
else if(u_strcmp(result, expected)==0)
|
||||
log_verbose("PASS: MessagFormat successful on test#3\n");
|
||||
else{
|
||||
log_err("FAIL: Error in MessageFormat on test#3\n GOT: %s EXPECTED %s\n", austrdup(result),
|
||||
|
@ -360,7 +361,7 @@ static void TestSampleMessageFormat(void)
|
|||
static void TestNewFormatAndParseAPI(void)
|
||||
{
|
||||
|
||||
UChar *result, *tzID, *str;
|
||||
UChar *result, tzID[4], str[25];
|
||||
UChar pattern[100];
|
||||
UChar expected[100];
|
||||
int32_t resultLengthOut, resultlength;
|
||||
|
@ -378,9 +379,7 @@ static void TestNewFormatAndParseAPI(void)
|
|||
|
||||
log_verbose("Testing format and parse with parse error\n");
|
||||
|
||||
str=(UChar*)malloc(sizeof(UChar) * 25);
|
||||
u_uastrcpy(str, "disturbance in force");
|
||||
tzID=(UChar*)malloc(sizeof(UChar) * 4);
|
||||
u_uastrcpy(tzID, "PST");
|
||||
cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status);
|
||||
if(U_FAILURE(status)){
|
||||
|
@ -455,8 +454,6 @@ static void TestNewFormatAndParseAPI(void)
|
|||
ucal_close(cal);
|
||||
|
||||
free(result);
|
||||
free(str);
|
||||
free(tzID);
|
||||
|
||||
ctest_resetTimeZone();
|
||||
}
|
||||
|
@ -513,7 +510,7 @@ static void TestSampleFormatAndParseWithError(void)
|
|||
if(U_FAILURE(status)){
|
||||
log_err("ERROR: failure in message format test#4: %s\n", myErrorName(status));
|
||||
}
|
||||
if(u_strcmp(result, expected)==0)
|
||||
else if(u_strcmp(result, expected)==0)
|
||||
log_verbose("PASS: MessagFormat successful on test#4\n");
|
||||
else{
|
||||
log_err("FAIL: Error in MessageFormat on test#4\n GOT: %s EXPECTED: %s\n", austrdup(result),
|
||||
|
@ -528,7 +525,7 @@ static void TestSampleFormatAndParseWithError(void)
|
|||
if(U_FAILURE(status)){
|
||||
log_err("ERROR: error in parsing: test#5: %s\n", myErrorName(status));
|
||||
}
|
||||
if(value!=7 && u_strcmp(str,ret)!=0)
|
||||
else if(value!=7 && u_strcmp(str,ret)!=0)
|
||||
log_err("FAIL: Error in parseMessage on test#5 \n");
|
||||
else
|
||||
log_verbose("PASS: parseMessage successful on test#5\n");
|
||||
|
@ -606,7 +603,7 @@ static void TestSampleFormatAndParse(void)
|
|||
if(U_FAILURE(status)){
|
||||
log_err("ERROR: failure in message format test#4: %s\n", myErrorName(status));
|
||||
}
|
||||
if(u_strcmp(result, expected)==0)
|
||||
else if(u_strcmp(result, expected)==0)
|
||||
log_verbose("PASS: MessagFormat successful on test#4\n");
|
||||
else{
|
||||
log_err("FAIL: Error in MessageFormat on test#4\n GOT: %s EXPECTED: %s\n", austrdup(result),
|
||||
|
@ -621,7 +618,7 @@ static void TestSampleFormatAndParse(void)
|
|||
if(U_FAILURE(status)){
|
||||
log_err("ERROR: error in parsing: test#5: %s\n", myErrorName(status));
|
||||
}
|
||||
if(value!=7 && u_strcmp(str,ret)!=0)
|
||||
else if(value!=7 && u_strcmp(str,ret)!=0)
|
||||
log_err("FAIL: Error in parseMessage on test#5 \n");
|
||||
else
|
||||
log_verbose("PASS: parseMessage successful on test#5\n");
|
||||
|
@ -756,7 +753,7 @@ static void TestParseMessage(void)
|
|||
if(U_FAILURE(status)){
|
||||
log_err("ERROR: failure in parse Message on test#9: %s\n", myErrorName(status));
|
||||
}
|
||||
if(value==500.00 && u_strcmp(str,res)==0)
|
||||
else if(value==500.00 && u_strcmp(str,res)==0)
|
||||
log_verbose("PASS: parseMessage successful on test#9\n");
|
||||
else
|
||||
log_err("FAIL: Error in parseMessage on test#9 \n");
|
||||
|
@ -773,7 +770,7 @@ static void TestParseMessage(void)
|
|||
if(U_FAILURE(status)){
|
||||
log_err("ERROR: failure in parse Message on test#10: %s\n", myErrorName(status));
|
||||
}
|
||||
if(value==123.00 && u_strcmp(str,res)==0)
|
||||
else if(value==123.00 && u_strcmp(str,res)==0)
|
||||
log_verbose("PASS: parseMessage successful on test#10\n");
|
||||
else
|
||||
log_err("FAIL: Error in parseMessage on test#10 \n");
|
||||
|
@ -827,7 +824,7 @@ static void TestMessageFormatWithValist( void )
|
|||
if(U_FAILURE(status)){
|
||||
log_err("ERROR: failure in message format on testcase %d: %s\n", i, myErrorName(status) );
|
||||
}
|
||||
if(u_strcmp(result, testResultStrings[i])==0){
|
||||
else if(u_strcmp(result, testResultStrings[i])==0){
|
||||
log_verbose("PASS: MessagFormat successful on testcase : %d\n", i);
|
||||
}
|
||||
else{
|
||||
|
@ -887,7 +884,7 @@ static void TestParseMessageWithValist(void)
|
|||
if(U_FAILURE(status)){
|
||||
log_err("ERROR: failure in parse Message on test#10: %s\n", myErrorName(status));
|
||||
}
|
||||
if(value==123.00 && u_strcmp(str,res)==0)
|
||||
else if(value==123.00 && u_strcmp(str,res)==0)
|
||||
log_verbose("PASS: parseMessage successful on test#10\n");
|
||||
else
|
||||
log_err("FAIL: Error in parseMessage on test#10 \n");
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/********************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 1997-2007, International Business Machines Corporation and
|
||||
* Copyright (c) 1997-2008, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
********************************************************************/
|
||||
/********************************************************************************
|
||||
|
@ -775,6 +775,7 @@ static void TestSignificantDigits()
|
|||
fmt=unum_open(UNUM_IGNORE, temp, -1, NULL, NULL,&status);
|
||||
if (U_FAILURE(status)) {
|
||||
log_err("got unexpected error for unum_open: '%s'\n", u_errorName(status));
|
||||
return;
|
||||
}
|
||||
unum_setAttribute(fmt, UNUM_SIGNIFICANT_DIGITS_USED, TRUE);
|
||||
unum_setAttribute(fmt, UNUM_MAX_SIGNIFICANT_DIGITS, 6);
|
||||
|
@ -1224,25 +1225,25 @@ static void TestRBNFFormat() {
|
|||
u_uastrcpy(pat, "#,##0.0#;(#,##0.0#)");
|
||||
formats[0] = unum_open(UNUM_PATTERN_DECIMAL, pat, -1, "en_US", &perr, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
log_err("unable to open decimal pattern");
|
||||
log_err("unable to open decimal pattern\n");
|
||||
}
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
formats[1] = unum_open(UNUM_SPELLOUT, NULL, 0, "en_US", &perr, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
log_err("unable to open spellout");
|
||||
log_err("unable to open spellout\n");
|
||||
}
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
formats[2] = unum_open(UNUM_ORDINAL, NULL, 0, "en_US", &perr, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
log_err("unable to open ordinal");
|
||||
log_err("unable to open ordinal\n");
|
||||
}
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
formats[3] = unum_open(UNUM_DURATION, NULL, 0, "en_US", &perr, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
log_err("unable to open duration");
|
||||
log_err("unable to open duration\n");
|
||||
}
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
|
@ -1285,7 +1286,11 @@ static void TestRBNFFormat() {
|
|||
u_strcat(pat, tempUChars);
|
||||
formats[4] = unum_open(UNUM_PATTERN_RULEBASED, pat, -1, "en_US", &perr, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
log_err("unable to open rulebased pattern");
|
||||
log_err("unable to open rulebased pattern\n");
|
||||
}
|
||||
if (U_FAILURE(status)) {
|
||||
log_err("Something failed with %s\n", u_errorName(status));
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < COUNT; ++i) {
|
||||
|
|
Loading…
Add table
Reference in a new issue