/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2004, International Business Machines Corporation and
+ * Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/********************************************************************************
"Quotes ', {, a 1 {0}",
"Quotes ', {, a 1 {0}",
"You deposited 1 times an amount of $3,456.00 on 1/12/70",
- "{2,time,full}, for 3,456, 1 is 5:46:40 AM PST and full date is Monday, January 12, 1970",
+ "{2,time,full}, for 3,456, 1 is 5:46:40 AM PT and full date is Monday, January 12, 1970",
"{1,number,percent} for 1 is 345,600%"
};
/*test u_formatMessage() with sample patterns */
-static void TestSampleMessageFormat()
+static void TestSampleMessageFormat(void)
{
UChar *str;
UChar *result;
UDate d1,d;
UDateFormat *def1;
UErrorCode status = U_ZERO_ERROR;
- double value = 0.0;
+ int32_t value = 0;
UChar ret[30];
UParseError parseError;
UMessageFormat* fmt = NULL;
if(U_FAILURE(status)){
log_err("ERROR: error in parsing: test#5: %s\n", myErrorName(status));
}
- if(value!=7.00 && u_strcmp(str,ret)!=0)
+ 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");
UDate d1,d;
UDateFormat *def1;
UErrorCode status = U_ZERO_ERROR;
- double value = 0.0;
+ int32_t value = 0;
UChar ret[30];
UParseError parseError;
if(U_FAILURE(status)){
log_err("ERROR: error in parsing: test#5: %s\n", myErrorName(status));
}
- if(value!=7.00 && u_strcmp(str,ret)!=0)
+ 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");
}
/* Test u_formatMessage() and u_parseMessage() , format and parse sequence and round trip */
-static void TestSampleFormatAndParse()
+static void TestSampleFormatAndParse(void)
{
UChar *result, *tzID, *str;
UDate d1,d;
UDateFormat *def1;
UErrorCode status = U_ZERO_ERROR;
- double value = 0.0;
+ int32_t value = 0;
UChar ret[30];
ctest_setTimeZone(NULL, &status);
if(U_FAILURE(status)){
log_err("ERROR: error in parsing: test#5: %s\n", myErrorName(status));
}
- if(value!=7.00 && u_strcmp(str,ret)!=0)
+ 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");
}
/* test message format with a choice option */
-static void TestMsgFormatChoice()
+static void TestMsgFormatChoice(void)
{
UChar* str;
UErrorCode status = U_ZERO_ERROR;
}
/*test u_parseMessage() with various test patterns */
-static void TestParseMessage()
+static void TestParseMessage(void)
{
UChar pattern[100];
UChar source[100];
umsg_toPattern(f1,result,256,&status);
if(U_FAILURE(status) ){
log_err("umsg_toPattern method failed. Error: %s \n",u_errorName(status));
- }
- if(u_strcmp(result,pattern)!=0){
- u_UCharsToChars(result,cresult,256);
- log_err("umsg_toPattern method failed. Expected: %s Got: %s \n",PAT,cresult);
+ } else {
+ if(u_strcmp(result,pattern)!=0){
+ u_UCharsToChars(result,cresult,256);
+ log_err("umsg_toPattern method failed. Expected: %s Got: %s \n",PAT,cresult);
+ }
}
/* umsg_format umsg_parse */
}
}
+static void TestErrorChaining(void) {
+ UErrorCode status = U_USELESS_COLLATOR_ERROR;
+
+ umsg_open(NULL, 0, NULL, NULL, &status);
+ umsg_applyPattern(NULL, NULL, 0, NULL, &status);
+ umsg_clone(NULL, &status);
+ umsg_close(NULL);
+
+ /* All of this code should have done nothing. */
+ if (status != U_USELESS_COLLATOR_ERROR) {
+ log_err("Status got changed to %s\n", u_errorName(status));
+ }
+}
void addMsgForTest(TestNode** root);
addTest(root, &TestParseMessageWithValist, "tsformat/cmsgtst/TestParseMessageWithValist");
addTest(root, &TestJ904, "tsformat/cmsgtst/TestJ904");
addTest(root, &MessageLength, "tsformat/cmsgtst/MessageLength");
+ addTest(root, &TestErrorChaining, "tsformat/cmsgtst/TestErrorChaining");
}
#endif /* #if !UCONFIG_NO_FORMATTING */