2000-01-15 02:00:06 +00:00
|
|
|
/********************************************************************
|
|
|
|
* COPYRIGHT:
|
2001-03-21 19:46:49 +00:00
|
|
|
* Copyright (c) 1997-2001, International Business Machines Corporation and
|
2000-01-15 02:00:06 +00:00
|
|
|
* others. All Rights Reserved.
|
|
|
|
********************************************************************/
|
|
|
|
/********************************************************************************
|
1999-08-16 21:50:52 +00:00
|
|
|
*
|
|
|
|
* File CFORMTST.C
|
|
|
|
*
|
|
|
|
* Modification History:
|
|
|
|
* Name Description
|
|
|
|
* Madhu Katragadda Creation
|
|
|
|
*********************************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* FormatTest is a medium top level test for everything in the C FORMAT API */
|
|
|
|
|
2002-09-20 17:54:45 +00:00
|
|
|
#include "unicode/utypes.h"
|
|
|
|
|
|
|
|
#if !UCONFIG_NO_FORMATTING
|
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
#include "cintltst.h"
|
|
|
|
#include "cformtst.h"
|
|
|
|
|
|
|
|
void addCalTest(TestNode**);
|
|
|
|
void addDateForTest(TestNode**);
|
|
|
|
void addNumForTest(TestNode**);
|
|
|
|
void addMsgForTest(TestNode**);
|
|
|
|
void addDateForRgrTest(TestNode**);
|
|
|
|
void addNumFrDepTest(TestNode**);
|
|
|
|
void addDtFrDepTest(TestNode**);
|
|
|
|
|
2001-05-31 23:42:59 +00:00
|
|
|
void addFormatTest(TestNode** root);
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
void addFormatTest(TestNode** root)
|
|
|
|
{
|
|
|
|
addCalTest(root);
|
|
|
|
addDateForTest(root);
|
|
|
|
addNumForTest(root);
|
|
|
|
addNumFrDepTest(root);
|
|
|
|
addMsgForTest(root);
|
|
|
|
addDateForRgrTest(root);
|
|
|
|
addDtFrDepTest(root);
|
2000-08-28 21:43:03 +00:00
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
|
|
|
/*INternal functions used*/
|
|
|
|
|
|
|
|
UChar* myDateFormat(UDateFormat* dat, UDate d1)
|
|
|
|
{
|
2000-08-14 17:13:09 +00:00
|
|
|
UChar *result1=NULL;
|
1999-08-16 21:50:52 +00:00
|
|
|
int32_t resultlength, resultlengthneeded;
|
1999-10-07 00:07:53 +00:00
|
|
|
UErrorCode status = U_ZERO_ERROR;
|
2000-08-28 21:43:03 +00:00
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
resultlength=0;
|
2001-03-08 23:41:16 +00:00
|
|
|
resultlengthneeded=udat_format(dat, d1, NULL, resultlength, NULL, &status);
|
1999-10-07 00:07:53 +00:00
|
|
|
if(status==U_BUFFER_OVERFLOW_ERROR)
|
1999-08-16 21:50:52 +00:00
|
|
|
{
|
1999-10-07 00:07:53 +00:00
|
|
|
status=U_ZERO_ERROR;
|
1999-08-16 21:50:52 +00:00
|
|
|
resultlength=resultlengthneeded+1;
|
2000-07-06 23:01:50 +00:00
|
|
|
result1=(UChar*)ctst_malloc(sizeof(UChar) * resultlength);
|
2001-05-22 22:44:37 +00:00
|
|
|
udat_format(dat, d1, result1, resultlength, NULL, &status);
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
1999-10-18 22:48:32 +00:00
|
|
|
if(U_FAILURE(status))
|
1999-08-16 21:50:52 +00:00
|
|
|
{
|
|
|
|
log_err("Error in formatting using udat_format(.....): %s\n", myErrorName(status));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return result1;
|
|
|
|
|
|
|
|
}
|
2002-09-20 17:54:45 +00:00
|
|
|
|
|
|
|
#endif /* #if !UCONFIG_NO_FORMATTING */
|