]> git.saurik.com Git - apple/icu.git/blame - icuSources/test/cintltst/cformtst.c
ICU-8.11.4.tar.gz
[apple/icu.git] / icuSources / test / cintltst / cformtst.c
CommitLineData
b75a7d8f
A
1/********************************************************************
2 * COPYRIGHT:
73c04bcf 3 * Copyright (c) 1997-2005, International Business Machines Corporation
374ca955 4 * and others. All Rights Reserved.
b75a7d8f
A
5 ********************************************************************/
6/********************************************************************************
7*
8* File CFORMTST.C
9*
10* Modification History:
11* Name Description
12* Madhu Katragadda Creation
13*********************************************************************************
14*/
15
16/* FormatTest is a medium top level test for everything in the C FORMAT API */
17
18#include "unicode/utypes.h"
19
20#if !UCONFIG_NO_FORMATTING
21
22#include "cintltst.h"
23#include "cformtst.h"
24
25void addCalTest(TestNode**);
26void addDateForTest(TestNode**);
27void addNumForTest(TestNode**);
28void addMsgForTest(TestNode**);
29void addDateForRgrTest(TestNode**);
30void addNumFrDepTest(TestNode**);
31void addDtFrDepTest(TestNode**);
374ca955 32void addUtmsTest(TestNode**);
73c04bcf 33void addCurrencyTest(TestNode**);
b75a7d8f
A
34
35void addFormatTest(TestNode** root);
36
37void addFormatTest(TestNode** root)
38{
39 addCalTest(root);
40 addDateForTest(root);
41 addNumForTest(root);
42 addNumFrDepTest(root);
43 addMsgForTest(root);
44 addDateForRgrTest(root);
45 addDtFrDepTest(root);
374ca955 46 addUtmsTest(root);
73c04bcf 47 addCurrencyTest(root);
b75a7d8f 48}
374ca955 49/*Internal functions used*/
b75a7d8f
A
50
51UChar* myDateFormat(UDateFormat* dat, UDate d1)
52{
53 UChar *result1=NULL;
54 int32_t resultlength, resultlengthneeded;
55 UErrorCode status = U_ZERO_ERROR;
56
57
58 resultlength=0;
59 resultlengthneeded=udat_format(dat, d1, NULL, resultlength, NULL, &status);
60 if(status==U_BUFFER_OVERFLOW_ERROR)
61 {
62 status=U_ZERO_ERROR;
63 resultlength=resultlengthneeded+1;
64 result1=(UChar*)ctst_malloc(sizeof(UChar) * resultlength);
65 udat_format(dat, d1, result1, resultlength, NULL, &status);
66 }
67 if(U_FAILURE(status))
68 {
69 log_err("Error in formatting using udat_format(.....): %s\n", myErrorName(status));
70 return 0;
71 }
72 return result1;
73
74}
75
76#endif /* #if !UCONFIG_NO_FORMATTING */