ICU-900 Fixed some compiler warnings

X-SVN-Rev: 4868
This commit is contained in:
George Rhoten 2001-06-01 17:17:21 +00:00
parent df717c8605
commit a90bb7540e
4 changed files with 60 additions and 57 deletions

View File

@ -587,6 +587,8 @@ static void TestJ904(void) {
}
}
void addMsgForTest(TestNode** root);
void addMsgForTest(TestNode** root)
{
addTest(root, &MessageFormatTest, "tsformat/cmsgtst/MessageFormatTest");

View File

@ -17,18 +17,18 @@
/* C DEPTH TEST FOR NUMBER FORMAT */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "unicode/uloc.h"
#include "unicode/utypes.h"
#include "unicode/unum.h"
#include "unicode/ustring.h"
#include "cintltst.h"
#include "cnmdptst.h"
#include "cmemory.h"
#define CHECK(status,str) if (U_FAILURE(status)) { log_err("FAIL: %s\n", str); return; }
void addNumFrDepTest(TestNode** root);
void addNumFrDepTest(TestNode** root)
{
addTest(root, &TestPatterns, "tsformat/cnmdptst/TestPatterns");
@ -72,7 +72,7 @@ static void TestPatterns(void)
lneed=unum_toPattern(fmt, FALSE, NULL, lneed, &status);
if(status==U_BUFFER_OVERFLOW_ERROR){
status= U_ZERO_ERROR;
unewp=(UChar*)malloc(sizeof(UChar) * (lneed+1) );
unewp=(UChar*)uprv_malloc(sizeof(UChar) * (lneed+1) );
unum_toPattern(fmt, FALSE, unewp, lneed+1, &status);
}
if(U_FAILURE(status)){
@ -86,7 +86,7 @@ static void TestPatterns(void)
lneed=unum_format(fmt, 0, NULL, lneed, NULL, &status);
if(status==U_BUFFER_OVERFLOW_ERROR){
status=U_ZERO_ERROR;
str=(UChar*)malloc(sizeof(UChar) * (lneed+1) );
str=(UChar*)uprv_malloc(sizeof(UChar) * (lneed+1) );
unum_format(fmt, 0, str, lneed+1, NULL, &status);
}
if(U_FAILURE(status)) {
@ -98,8 +98,8 @@ static void TestPatterns(void)
log_err("FAIL: Pattern %s should format zero as %s; %s Seen instead\n", pat[i], num[i], austrdup(str) );
}
free(unewp);
free(str);
uprv_free(unewp);
uprv_free(str);
unum_close(fmt);
}
}
@ -124,7 +124,7 @@ static void TestQuotes(void)
lneed=unum_format(fmt, 123, NULL, lneed, NULL, &status);
if(status==U_BUFFER_OVERFLOW_ERROR){
status=U_ZERO_ERROR;
str=(UChar*)malloc(sizeof(UChar) * (lneed+1) );
str=(UChar*)uprv_malloc(sizeof(UChar) * (lneed+1) );
unum_format(fmt, 123, str, lneed+1, NULL, &status);
}
if(U_FAILURE(status)) {
@ -136,7 +136,7 @@ static void TestQuotes(void)
if(u_strcmp(str, res) != 0)
log_err("FAIL: Expected afo'ob123");
free(str);
uprv_free(str);
unum_close(fmt);
@ -152,7 +152,7 @@ static void TestQuotes(void)
lneed=unum_format(fmt, 123, NULL, lneed, NULL, &status);
if(status==U_BUFFER_OVERFLOW_ERROR){
status=U_ZERO_ERROR;
str=(UChar*)malloc(sizeof(UChar) * (lneed+1) );
str=(UChar*)uprv_malloc(sizeof(UChar) * (lneed+1) );
unum_format(fmt, 123, str, lneed+1, NULL, &status);
}
if(U_FAILURE(status)) {
@ -165,7 +165,7 @@ static void TestQuotes(void)
if(u_strcmp(str, res) != 0)
log_err("FAIL: Expected a'b123\n");
free(str);
uprv_free(str);
unum_close(fmt);
}
@ -235,7 +235,7 @@ static void TestExponential(void)
ilval = 0;
for (p=0; p < pat_length; ++p)
{
upat=(UChar*)malloc(sizeof(UChar) * (strlen(pat[p])+1) );
upat=(UChar*)uprv_malloc(sizeof(UChar) * (strlen(pat[p])+1) );
u_uastrcpy(upat, pat[p]);
fmt=unum_openPattern(upat, u_strlen(upat), "en_US", &status);
if (U_FAILURE(status)) {
@ -252,7 +252,7 @@ static void TestExponential(void)
lneed=unum_formatDouble(fmt, val[v], NULL, lneed, NULL, &status);
if(status==U_BUFFER_OVERFLOW_ERROR){
status=U_ZERO_ERROR;
str=(UChar*)malloc(sizeof(UChar) * (lneed+1) );
str=(UChar*)uprv_malloc(sizeof(UChar) * (lneed+1) );
unum_formatDouble(fmt, val[v], str, lneed+1, NULL, &status);
}
if(U_FAILURE(status)) {
@ -275,7 +275,7 @@ static void TestExponential(void)
else
log_err(" FAIL: Partial parse ( %d chars ) -> %e\n", ppos, a);
free(str);
uprv_free(str);
}
for (v=0; v<lval_length; ++v)
{
@ -284,7 +284,7 @@ static void TestExponential(void)
lneed=unum_formatDouble(fmt, lval[v], NULL, lneed, NULL, &status);
if(status==U_BUFFER_OVERFLOW_ERROR){
status=U_ZERO_ERROR;
str=(UChar*)malloc(sizeof(UChar) * (lneed+1) );
str=(UChar*)uprv_malloc(sizeof(UChar) * (lneed+1) );
unum_formatDouble(fmt, lval[v], str, lneed+1, NULL, &status);
}
if(U_FAILURE(status)) {
@ -306,13 +306,13 @@ static void TestExponential(void)
else
log_err(" FAIL: Partial parse ( %d chars ) -> %e\n", ppos, a);
free(str);
uprv_free(str);
}
ival += val_length;
ilval += lval_length;
unum_close(fmt);
free(upat);
uprv_free(upat);
}
}
@ -330,7 +330,7 @@ static void TestCurrencySign(void)
UErrorCode status = U_ZERO_ERROR;
char tempBuf[256];
pattern=(UChar*)malloc(sizeof(UChar) * (strlen("*#,##0.00;-*#,##0.00") + 1) );
pattern=(UChar*)uprv_malloc(sizeof(UChar) * (strlen("*#,##0.00;-*#,##0.00") + 1) );
u_uastrcpy(pattern, "*#,##0.00;-*#,##0.00");
pattern[0]=pattern[11]=0xa4; /* insert latin-1 currency symbol */
fmt = unum_openPattern(pattern, u_strlen(pattern), "en_US", &status);
@ -341,7 +341,7 @@ static void TestCurrencySign(void)
lneed=unum_formatDouble(fmt, 1234.56, NULL, lneed, NULL, &status);
if(status==U_BUFFER_OVERFLOW_ERROR){
status=U_ZERO_ERROR;
str=(UChar*)malloc(sizeof(UChar) * (lneed+1) );
str=(UChar*)uprv_malloc(sizeof(UChar) * (lneed+1) );
unum_formatDouble(fmt, 1234.56, str, lneed+1, NULL, &status);
}
if(U_FAILURE(status)) {
@ -351,37 +351,37 @@ static void TestCurrencySign(void)
lneed=unum_toPattern(fmt, FALSE, NULL, lneed, &status);
if(status==U_BUFFER_OVERFLOW_ERROR){
status=U_ZERO_ERROR;
pat=(UChar*)malloc(sizeof(UChar) * (lneed+1) );
pat=(UChar*)uprv_malloc(sizeof(UChar) * (lneed+1) );
unum_formatDouble(fmt, FALSE, pat, lneed+1, NULL, &status);
}
log_verbose("Pattern \" %s \" \n", u_austrcpy(tempBuf, pat));
log_verbose("Format 1234.56 -> %s\n", u_austrcpy(tempBuf, str) );
res=(UChar*)malloc(sizeof(UChar) * (strlen("$1,234.56")+1) );
res=(UChar*)uprv_malloc(sizeof(UChar) * (strlen("$1,234.56")+1) );
u_uastrcpy(res, "$1,234.56");
if (u_strcmp(str, res) !=0) log_err("FAIL: Expected $1,234.56\n");
free(str);
free(res);
free(pat);
uprv_free(str);
uprv_free(res);
uprv_free(pat);
lneed=0;
lneed=unum_formatDouble(fmt, -1234.56, NULL, lneed, NULL, &status);
if(status==U_BUFFER_OVERFLOW_ERROR){
status=U_ZERO_ERROR;
str=(UChar*)malloc(sizeof(UChar) * (lneed+1) );
str=(UChar*)uprv_malloc(sizeof(UChar) * (lneed+1) );
unum_formatDouble(fmt, -1234.56, str, lneed+1, NULL, &status);
}
if(U_FAILURE(status)) {
log_err("Error in formatting using unum_format(.....): %s\n", myErrorName(status) );
}
res=(UChar*)malloc(sizeof(UChar) * (strlen("-$1,234.56")+1) );
res=(UChar*)uprv_malloc(sizeof(UChar) * (strlen("-$1,234.56")+1) );
u_uastrcpy(res, "-$1,234.56");
if (u_strcmp(str, res) != 0) log_err("FAIL: Expected -$1,234.56\n");
free(str);
free(res);
uprv_free(str);
uprv_free(res);
unum_close(fmt);
free(pattern);
uprv_free(pattern);
}
/**
@ -408,19 +408,19 @@ static void TestCurrency(void)
lneed= unum_formatDouble(currencyFmt, 1.50, NULL, lneed, NULL, &status);
if(status==U_BUFFER_OVERFLOW_ERROR){
status=U_ZERO_ERROR;
str=(UChar*)malloc(sizeof(UChar) * (lneed+1) );
str=(UChar*)uprv_malloc(sizeof(UChar) * (lneed+1) );
pos.field = 0;
unum_formatDouble(currencyFmt, 1.50, str, lneed+1, &pos, &status);
}
if(U_FAILURE(status)) {
log_err("Error in formatting using unum_formatDouble(.....): %s\n", myErrorName(status) );
}
res=(UChar*)malloc(sizeof(UChar) * (strlen(result[i])+1) );
res=(UChar*)uprv_malloc(sizeof(UChar) * (strlen(result[i])+1) );
u_uastrcpy(res, result[i]);
if (u_strcmp(str, res) != 0) log_err("FAIL: Expected %s\n", result[i]);
unum_close(currencyFmt);
free(str);
free(res);
uprv_free(str);
uprv_free(res);
}
}
/**
@ -462,7 +462,7 @@ static void roundingTest(UNumberFormat* nf, double x, int32_t maxFractionDigits,
lneed=unum_formatDouble(nf, x, NULL, lneed, NULL, &status);
if(status==U_BUFFER_OVERFLOW_ERROR){
status=U_ZERO_ERROR;
out=(UChar*)malloc(sizeof(UChar) * (lneed+1) );
out=(UChar*)uprv_malloc(sizeof(UChar) * (lneed+1) );
pos.field=0;
unum_formatDouble(nf, x, out, lneed+1, &pos, &status);
}
@ -471,13 +471,13 @@ static void roundingTest(UNumberFormat* nf, double x, int32_t maxFractionDigits,
}
/*Need to use log_verbose here. Problem with the float*/
/*printf("%f format with %d fraction digits to %s\n", x, maxFractionDigits, austrdup(out) );*/
res=(UChar*)malloc(sizeof(UChar) * (strlen(expected)+1) );
res=(UChar*)uprv_malloc(sizeof(UChar) * (strlen(expected)+1) );
u_uastrcpy(res, expected);
if (u_strcmp(out, res) != 0)
log_err("FAIL: Expected: %s or %s\n", expected, austrdup(res) );
free(res);
uprv_free(res);
if(out != NULL) {
free(out);
uprv_free(out);
}
}

View File

@ -19,13 +19,15 @@
/* C API TEST FOR NUMBER FORMAT */
#include <stdlib.h>
#include "unicode/uloc.h"
#include "unicode/utypes.h"
#include "unicode/unum.h"
#include "unicode/ustring.h"
#include "cintltst.h"
#include "cnumtst.h"
#include "cmemory.h"
void addNumForTest(TestNode** root);
void addNumForTest(TestNode** root)
{
@ -149,7 +151,7 @@ static void TestNumberFormat()
{
status=U_ZERO_ERROR;
resultlength=resultlengthneeded+1;
result=(UChar*)malloc(sizeof(UChar) * resultlength);
result=(UChar*)uprv_malloc(sizeof(UChar) * resultlength);
/* for (i = 0; i < 100000; i++) */
{
unum_format(cur_def, l, result, resultlength, &pos1, &status);
@ -170,7 +172,7 @@ static void TestNumberFormat()
log_err("Fail: Error in complete number Formatting using unum_format()\nGot: b=%d end=%d\nExpected: b=1 end=12\n",
pos1.beginIndex, pos1.endIndex);
free(result);
uprv_free(result);
result = 0;
log_verbose("\nTesting unum_formatDouble()\n");
@ -182,7 +184,7 @@ free(result);
{
status=U_ZERO_ERROR;
resultlength=resultlengthneeded+1;
result=(UChar*)malloc(sizeof(UChar) * resultlength);
result=(UChar*)uprv_malloc(sizeof(UChar) * resultlength);
/* for (i = 0; i < 100000; i++) */
{
unum_formatDouble(cur_def, d, result, resultlength, &pos2, &status);
@ -238,7 +240,7 @@ free(result);
else
log_verbose("Pass: parsing successful\n");
free(result);
uprv_free(result);
u_uastrcpy(temp1, "($10,456.3E1])");
parsepos=0;
@ -258,7 +260,7 @@ free(result);
{
status=U_ZERO_ERROR;
resultlength=resultlengthneeded+1;
result=(UChar*)malloc(sizeof(UChar) * resultlength);
result=(UChar*)uprv_malloc(sizeof(UChar) * resultlength);
/* for (i = 0; i < 100000; i++)*/
{
unum_format(per_fr, l, result, resultlength, &pos1, &status);
@ -286,7 +288,7 @@ free(result);
else
log_verbose("Pass: parsing successful\n");
free(result);
uprv_free(result);
/* create a number format using unum_openPattern(....)*/
log_verbose("\nTesting unum_openPattern()\n");
@ -307,7 +309,7 @@ free(result);
{
status=U_ZERO_ERROR;
resultlength=resultlengthneeded+1;
result=(UChar*)malloc(sizeof(UChar) * resultlength);
result=(UChar*)uprv_malloc(sizeof(UChar) * resultlength);
unum_toPattern(pattern, FALSE, result, resultlength, &status);
}
if(U_FAILURE(status))
@ -320,7 +322,7 @@ free(result);
log_err("FAIL: Error in extracting the pattern using unum_toPattern()\n");
else
log_verbose("Pass: extracted the pattern correctly using unum_toPattern()\n");
free(result);
uprv_free(result);
}
/*Testing unum_getSymbols() and unum_setSymbols()*/
@ -332,7 +334,7 @@ free(result);
{
status=U_ZERO_ERROR;
resultlength=resultlengthneeded+1;
result=(UChar*)malloc(sizeof(UChar) * resultlength);
result=(UChar*)uprv_malloc(sizeof(UChar) * resultlength);
unum_toPattern(cur_def, FALSE, result, resultlength, &status);
}
if(U_FAILURE(status))
@ -347,7 +349,7 @@ free(result);
log_err("error in unum_openPattern(): %s\n", myErrorName(status));
}
free(result);
uprv_free(result);
/*getting the symbols of cur_def */
unum_getSymbols(cur_def, &symbols1);
@ -359,7 +361,7 @@ free(result);
{
status=U_ZERO_ERROR;
resultlength=resultlengthneeded+1;
result=(UChar*)malloc(sizeof(UChar) * resultlength);
result=(UChar*)uprv_malloc(sizeof(UChar) * resultlength);
unum_format(cur_def, l, result, resultlength, &pos1, &status);
}
if(U_FAILURE(status))
@ -425,7 +427,7 @@ free(result);
/*----------- */
free(result);
uprv_free(result);
/* Testing unum_get/setSymbol() */
for(i = 0; i < UNUM_FORMAT_SYMBOL_COUNT; ++i) {
@ -650,7 +652,7 @@ static void TestNumberFormatPadding()
{
status=U_ZERO_ERROR;
resultlength=resultlengthneeded+1;
result=(UChar*)malloc(sizeof(UChar) * resultlength);
result=(UChar*)uprv_malloc(sizeof(UChar) * resultlength);
unum_toPattern(pattern, FALSE, result, resultlength, &status);
}
if(U_FAILURE(status))
@ -663,7 +665,7 @@ static void TestNumberFormatPadding()
log_err("FAIL: Error in extracting the padding pattern using unum_toPattern()\n");
else
log_verbose("Pass: extracted the padding pattern correctly using unum_toPattern()\n");
free(result);
uprv_free(result);
}
/* u_uastrcpy(temp1, "(xxxxxxx10,456.37)"); */
u_uastrcpy(temp1, "xxxxx(10,456.37)");
@ -674,7 +676,7 @@ free(result);
{
status=U_ZERO_ERROR;
resultlength=resultlengthneeded+1;
result=(UChar*)malloc(sizeof(UChar) * resultlength);
result=(UChar*)uprv_malloc(sizeof(UChar) * resultlength);
unum_formatDouble(pattern, d, result, resultlength, NULL, &status);
}
if(U_FAILURE(status))
@ -707,7 +709,7 @@ free(result);
log_err("Fail: Error in padding parsing\n");
else
log_verbose("Pass: padding parsing successful\n");
free(result);
uprv_free(result);
}
}

View File

@ -16,8 +16,6 @@
/* C FUNCTIONALITY AND REGRESSION TEST FOR BREAKITERATOR */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "unicode/uloc.h"
#include "unicode/ubrk.h"
#include "unicode/uchar.h"
@ -28,7 +26,7 @@
#include "cregrtst.h"
#include "ccolltst.h"
/* -------------------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/**
* "Vector" structure for holding test tables
* (this strucure is actually a linked list, but we use the name and API of the
@ -1749,6 +1747,7 @@ void sample(UBreakIterator* tb, UChar* text)
}
void addBrkIterRegrTest(TestNode** root);
void addBrkIterRegrTest(TestNode** root)
{