ICU-432 Don't use UFieldPosition when it's not being tested here.
X-SVN-Rev: 3982
This commit is contained in:
parent
7d41bc24c2
commit
4420f4a880
@ -49,7 +49,6 @@ static void TestDateFormat()
|
||||
int32_t resultlength;
|
||||
int32_t resultlengthneeded;
|
||||
int32_t parsepos;
|
||||
UFieldPosition pos;
|
||||
UDate d = 837039928046.0;
|
||||
double num = -10456.37;
|
||||
/*const char* str="yyyy.MM.dd G 'at' hh:mm:ss z";
|
||||
@ -116,7 +115,7 @@ static void TestDateFormat()
|
||||
u_uastrcpy(temp, "7/10/96 4:05 PM");
|
||||
/*format using def */
|
||||
resultlength=0;
|
||||
resultlengthneeded=udat_format(def, d, NULL, resultlength, &pos, &status);
|
||||
resultlengthneeded=udat_format(def, d, NULL, resultlength, NULL, &status);
|
||||
if(status==U_BUFFER_OVERFLOW_ERROR)
|
||||
{
|
||||
status=U_ZERO_ERROR;
|
||||
@ -126,7 +125,7 @@ static void TestDateFormat()
|
||||
result = NULL;
|
||||
}
|
||||
result=(UChar*)malloc(sizeof(UChar) * resultlength);
|
||||
udat_format(def, d, result, resultlength, &pos, &status);
|
||||
udat_format(def, d, result, resultlength, NULL, &status);
|
||||
}
|
||||
if(U_FAILURE(status))
|
||||
{
|
||||
@ -270,6 +269,7 @@ static void TestDateFormat()
|
||||
log_err("FAIL: error in setNumberFormat or getNumberFormat()\n");
|
||||
else
|
||||
log_verbose("PASS:setNumberFormat and getNumberFormat succesful\n");
|
||||
|
||||
/*try setting the number format to another format */
|
||||
numformat1=udat_getNumberFormat(def);
|
||||
udat_setNumberFormat(def1, numformat1);
|
||||
@ -658,18 +658,17 @@ static UChar* myNumformat(const UNumberFormat* numfor, double d)
|
||||
{
|
||||
UChar *result2=NULL;
|
||||
int32_t resultlength, resultlengthneeded;
|
||||
UFieldPosition pos;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
resultlength=0;
|
||||
resultlengthneeded=unum_formatDouble(numfor, d, NULL, resultlength, &pos, &status);
|
||||
resultlengthneeded=unum_formatDouble(numfor, d, NULL, resultlength, NULL, &status);
|
||||
if(status==U_BUFFER_OVERFLOW_ERROR)
|
||||
{
|
||||
status=U_ZERO_ERROR;
|
||||
resultlength=resultlengthneeded+1;
|
||||
/*result2=(UChar*)malloc(sizeof(UChar) * resultlength);*/ /* this leaks */
|
||||
result2=(UChar*)ctst_malloc(sizeof(UChar) * resultlength); /*this won't*/
|
||||
unum_formatDouble(numfor, d, result2, resultlength, &pos, &status);
|
||||
unum_formatDouble(numfor, d, result2, resultlength, NULL, &status);
|
||||
}
|
||||
if(U_FAILURE(status))
|
||||
{
|
||||
|
@ -266,7 +266,7 @@ void Test4060212()
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UDate myDate;
|
||||
UChar *myString;
|
||||
UChar dateString[20], pattern[20], tzID[3];
|
||||
UChar dateString[20], pattern[20], tzID[4];
|
||||
u_uastrcpy(dateString, "1995-040.05:01:29");
|
||||
u_uastrcpy(pattern, "yyyy-DDD.hh:mm:ss");
|
||||
|
||||
@ -481,18 +481,17 @@ UChar* myFormatit(UDateFormat* datdef, UDate d1)
|
||||
{
|
||||
UChar *result1=NULL;
|
||||
int32_t resultlength, resultlengthneeded;
|
||||
UFieldPosition pos;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
resultlength=0;
|
||||
resultlengthneeded=udat_format(datdef, d1, NULL, resultlength, &pos, &status);
|
||||
resultlengthneeded=udat_format(datdef, d1, NULL, resultlength, NULL, &status);
|
||||
if(status==U_BUFFER_OVERFLOW_ERROR)
|
||||
{
|
||||
status=U_ZERO_ERROR;
|
||||
resultlength=resultlengthneeded+1;
|
||||
/*result1=(UChar*)malloc(sizeof(UChar) * resultlength);*/ /*this leaks*/
|
||||
result1=(UChar*)ctst_malloc(sizeof(UChar) * resultlength); /*this won't*/
|
||||
udat_format(datdef, d1, result1, resultlength, &pos, &status);
|
||||
udat_format(datdef, d1, result1, resultlength, NULL, &status);
|
||||
}
|
||||
if(U_FAILURE(status))
|
||||
{
|
||||
|
@ -77,19 +77,18 @@ UChar* myDateFormat(UDateFormat* dat, UDate d1)
|
||||
{
|
||||
UChar *result1=NULL;
|
||||
int32_t resultlength, resultlengthneeded;
|
||||
UFieldPosition pos;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
|
||||
resultlength=0;
|
||||
resultlengthneeded=udat_format(dat, d1, NULL, resultlength, &pos, &status);
|
||||
resultlengthneeded=udat_format(dat, d1, NULL, resultlength, NULL, &status);
|
||||
if(status==U_BUFFER_OVERFLOW_ERROR)
|
||||
{
|
||||
status=U_ZERO_ERROR;
|
||||
resultlength=resultlengthneeded+1;
|
||||
/*result1=(UChar*)malloc(sizeof(UChar) * resultlength); *//* this leaks for now */
|
||||
result1=(UChar*)ctst_malloc(sizeof(UChar) * resultlength);
|
||||
udat_format(dat, d1, result1, resultlength, &pos, &status);
|
||||
udat_format(dat, d1, result1, resultlength, NULL, &status);
|
||||
}
|
||||
if(U_FAILURE(status))
|
||||
{
|
||||
|
@ -47,7 +47,6 @@ static void TestPatterns(void)
|
||||
{
|
||||
int32_t pat_length, i, lneed;
|
||||
UNumberFormat *fmt;
|
||||
UFieldPosition pos;
|
||||
UChar upat[5];
|
||||
UChar unewpat[5];
|
||||
UChar unum[5];
|
||||
@ -84,11 +83,11 @@ static void TestPatterns(void)
|
||||
log_err("FAIL: Pattern %s should be transmute to %s; %s seen instead\n", pat[i], newpat[i], austrdup(unewp) );
|
||||
|
||||
lneed=0;
|
||||
lneed=unum_format(fmt, 0, NULL, lneed, &pos, &status);
|
||||
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) );
|
||||
unum_format(fmt, 0, str, lneed+1, &pos, &status);
|
||||
unum_format(fmt, 0, str, lneed+1, NULL, &status);
|
||||
}
|
||||
if(U_FAILURE(status)) {
|
||||
log_err("Error in formatting using unum_format(.....): %s\n", myErrorName(status) );
|
||||
@ -110,7 +109,6 @@ static void TestQuotes(void)
|
||||
{
|
||||
int32_t lneed;
|
||||
UErrorCode status;
|
||||
UFieldPosition pos;
|
||||
UChar pat[15];
|
||||
UChar res[15];
|
||||
UChar *str=NULL;
|
||||
@ -123,11 +121,11 @@ static void TestQuotes(void)
|
||||
log_err("Error in number format costruction using pattern \"a'fo''o'b#\"\n");
|
||||
}
|
||||
lneed=0;
|
||||
lneed=unum_format(fmt, 123, NULL, lneed, &pos, &status);
|
||||
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) );
|
||||
unum_format(fmt, 123, str, lneed+1, &pos, &status);
|
||||
unum_format(fmt, 123, str, lneed+1, NULL, &status);
|
||||
}
|
||||
if(U_FAILURE(status)) {
|
||||
log_err("Error in formatting using unum_format(.....): %s\n", myErrorName(status) );
|
||||
@ -151,11 +149,11 @@ static void TestQuotes(void)
|
||||
log_err("Error in number format costruction using pattern \"a''b#\"\n");
|
||||
}
|
||||
lneed=0;
|
||||
lneed=unum_format(fmt, 123, NULL, lneed, &pos, &status);
|
||||
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) );
|
||||
unum_format(fmt, 123, str, lneed+1, &pos, &status);
|
||||
unum_format(fmt, 123, str, lneed+1, NULL, &status);
|
||||
}
|
||||
if(U_FAILURE(status)) {
|
||||
log_err("Error in formatting using unum_format(.....): %s\n", myErrorName(status) );
|
||||
@ -177,7 +175,6 @@ static void TestExponential(void)
|
||||
int32_t pat_length, val_length, lval_length;
|
||||
int32_t ival, ilval, p, v, lneed;
|
||||
UNumberFormat *fmt;
|
||||
UFieldPosition pos;
|
||||
int32_t ppos;
|
||||
UChar *upat;
|
||||
UChar pattern[20];
|
||||
@ -251,11 +248,11 @@ static void TestExponential(void)
|
||||
{
|
||||
/*format*/
|
||||
lneed=0;
|
||||
lneed=unum_formatDouble(fmt, val[v], NULL, lneed, &pos, &status);
|
||||
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) );
|
||||
unum_formatDouble(fmt, val[v], str, lneed+1, &pos, &status);
|
||||
unum_formatDouble(fmt, val[v], str, lneed+1, NULL, &status);
|
||||
}
|
||||
if(U_FAILURE(status)) {
|
||||
log_err("Error in formatting using unum_format(.....): %s\n", myErrorName(status) );
|
||||
@ -283,11 +280,11 @@ static void TestExponential(void)
|
||||
{
|
||||
/*format*/
|
||||
lneed=0;
|
||||
lneed=unum_formatDouble(fmt, lval[v], NULL, lneed, &pos, &status);
|
||||
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) );
|
||||
unum_formatDouble(fmt, lval[v], str, lneed+1, &pos, &status);
|
||||
unum_formatDouble(fmt, lval[v], str, lneed+1, NULL, &status);
|
||||
}
|
||||
if(U_FAILURE(status)) {
|
||||
log_err("Error in formatting using unum_format(.....): %s\n", myErrorName(status) );
|
||||
@ -329,7 +326,6 @@ static void TestCurrencySign(void)
|
||||
UChar *str=NULL;
|
||||
UChar *pat=NULL;
|
||||
UChar *res=NULL;
|
||||
UFieldPosition pos;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
pattern=(UChar*)malloc(sizeof(UChar) * (strlen("*#,##0.00;-*#,##0.00") + 1) );
|
||||
u_uastrcpy(pattern, "*#,##0.00;-*#,##0.00");
|
||||
@ -339,11 +335,11 @@ static void TestCurrencySign(void)
|
||||
log_err("Error in number format construction with pattern \"\\xA4#,##0.00;-\\xA4#,##0.00\\\" \n");
|
||||
}
|
||||
lneed=0;
|
||||
lneed=unum_formatDouble(fmt, 1234.56, NULL, lneed, &pos, &status);
|
||||
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) );
|
||||
unum_formatDouble(fmt, 1234.56, str, lneed+1, &pos, &status);
|
||||
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) );
|
||||
@ -353,7 +349,7 @@ static void TestCurrencySign(void)
|
||||
if(status==U_BUFFER_OVERFLOW_ERROR){
|
||||
status=U_ZERO_ERROR;
|
||||
pat=(UChar*)malloc(sizeof(UChar) * (lneed+1) );
|
||||
unum_formatDouble(fmt, FALSE, pat, lneed+1, &pos, &status);
|
||||
unum_formatDouble(fmt, FALSE, pat, lneed+1, NULL, &status);
|
||||
}
|
||||
log_verbose("Pattern \" %s \" \n", austrdup(pat));
|
||||
log_verbose("Format 1234.56 -> %s\n", austrdup(str) );
|
||||
@ -366,11 +362,11 @@ static void TestCurrencySign(void)
|
||||
free(pat);
|
||||
|
||||
lneed=0;
|
||||
lneed=unum_formatDouble(fmt, -1234.56, NULL, lneed, &pos, &status);
|
||||
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) );
|
||||
unum_formatDouble(fmt, -1234.56, str, lneed+1, &pos, &status);
|
||||
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) );
|
||||
|
@ -143,6 +143,7 @@ static void TestNumberFormat()
|
||||
|
||||
log_verbose("\nTesting unum_format() \n");
|
||||
resultlength=0;
|
||||
pos1.field = 0; /* Integer Section */
|
||||
resultlengthneeded=unum_format(cur_def, l, NULL, resultlength, &pos1, &status);
|
||||
if(status==U_BUFFER_OVERFLOW_ERROR)
|
||||
{
|
||||
@ -163,6 +164,11 @@ static void TestNumberFormat()
|
||||
log_verbose("Pass: Number formatting using unum_format() successful\n");
|
||||
else
|
||||
log_err("Fail: Error in number Formatting using unum_format()\n");
|
||||
if(pos1.beginIndex == 1 && pos1.endIndex == 12)
|
||||
log_verbose("Pass: Complete number formatting using unum_format() successful\n");
|
||||
else
|
||||
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);
|
||||
result = 0;
|
||||
@ -170,6 +176,7 @@ free(result);
|
||||
log_verbose("\nTesting unum_formatDouble()\n");
|
||||
u_uastrcpy(temp1, "($10,456.37)");
|
||||
resultlength=0;
|
||||
pos2.field = 1; /* Fractional Section */
|
||||
resultlengthneeded=unum_formatDouble(cur_def, d, NULL, resultlength, &pos2, &status);
|
||||
if(status==U_BUFFER_OVERFLOW_ERROR)
|
||||
{
|
||||
@ -189,6 +196,11 @@ free(result);
|
||||
log_verbose("Pass: Number Formatting using unum_formatDouble() Successful\n");
|
||||
else
|
||||
log_err("FAIL: Error in number formatting using unum_formatDouble()\n");
|
||||
if(pos2.beginIndex == 9 && pos2.endIndex == 11)
|
||||
log_verbose("Pass: Complete number formatting using unum_format() successful\n");
|
||||
else
|
||||
log_err("Fail: Error in complete number Formatting using unum_formatDouble()\nGot: b=%d end=%d\nExpected: b=9 end=11",
|
||||
pos1.beginIndex, pos1.endIndex);
|
||||
|
||||
|
||||
/* Testing unum_parse() and unum_parseDouble() */
|
||||
@ -602,8 +614,8 @@ static void TestNumberFormatPadding()
|
||||
UNumberFormat *pattern;
|
||||
double d1;
|
||||
double d = -10456.37;
|
||||
UFieldPosition pos1;
|
||||
int32_t parsepos;
|
||||
UFieldPosition pos2;
|
||||
|
||||
/* create a number format using unum_openPattern(....)*/
|
||||
log_verbose("\nTesting unum_openPattern() with padding\n");
|
||||
@ -656,13 +668,14 @@ free(result);
|
||||
/* u_uastrcpy(temp1, "(xxxxxxx10,456.37)"); */
|
||||
u_uastrcpy(temp1, "xxxxx(10,456.37)");
|
||||
resultlength=0;
|
||||
resultlengthneeded=unum_formatDouble(pattern, d, NULL, resultlength, &pos2, &status);
|
||||
pos1.field = 1; /* Fraction field */
|
||||
resultlengthneeded=unum_formatDouble(pattern, d, NULL, resultlength, &pos1, &status);
|
||||
if(status==U_BUFFER_OVERFLOW_ERROR)
|
||||
{
|
||||
status=U_ZERO_ERROR;
|
||||
resultlength=resultlengthneeded+1;
|
||||
result=(UChar*)malloc(sizeof(UChar) * resultlength);
|
||||
unum_formatDouble(pattern, d, result, resultlength, &pos2, &status);
|
||||
unum_formatDouble(pattern, d, result, resultlength, NULL, &status);
|
||||
}
|
||||
if(U_FAILURE(status))
|
||||
{
|
||||
@ -674,6 +687,11 @@ free(result);
|
||||
log_verbose("Pass: Number Formatting using unum_formatDouble() padding Successful\n");
|
||||
else
|
||||
log_err("FAIL: Error in number formatting using unum_formatDouble() with padding\n");
|
||||
if(pos1.beginIndex == 13 && pos1.endIndex == 15)
|
||||
log_verbose("Pass: Complete number formatting using unum_formatDouble() successful\n");
|
||||
else
|
||||
log_err("Fail: Error in complete number Formatting using unum_formatDouble()\nGot: b=%d end=%d\nExpected: b=13 end=15\n",
|
||||
pos1.beginIndex, pos1.endIndex);
|
||||
|
||||
|
||||
/* Testing unum_parse() and unum_parseDouble() */
|
||||
|
Loading…
Reference in New Issue
Block a user