]> git.saurik.com Git - apple/icu.git/blame - icuSources/test/cintltst/cformtst.c
ICU-461.12.tar.gz
[apple/icu.git] / icuSources / test / cintltst / cformtst.c
CommitLineData
b75a7d8f
A
1/********************************************************************
2 * COPYRIGHT:
46f4442e 3 * Copyright (c) 1997-2007, 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**);
46f4442e 27void addDateTimePatternGeneratorTest(TestNode** root);
b75a7d8f
A
28void addNumForTest(TestNode**);
29void addMsgForTest(TestNode**);
30void addDateForRgrTest(TestNode**);
31void addNumFrDepTest(TestNode**);
32void addDtFrDepTest(TestNode**);
374ca955 33void addUtmsTest(TestNode**);
73c04bcf 34void addCurrencyTest(TestNode**);
b75a7d8f
A
35
36void addFormatTest(TestNode** root);
37
38void addFormatTest(TestNode** root)
39{
40 addCalTest(root);
41 addDateForTest(root);
46f4442e 42 addDateTimePatternGeneratorTest(root);
b75a7d8f
A
43 addNumForTest(root);
44 addNumFrDepTest(root);
45 addMsgForTest(root);
46 addDateForRgrTest(root);
47 addDtFrDepTest(root);
374ca955 48 addUtmsTest(root);
73c04bcf 49 addCurrencyTest(root);
b75a7d8f 50}
374ca955 51/*Internal functions used*/
b75a7d8f
A
52
53UChar* myDateFormat(UDateFormat* dat, UDate d1)
54{
55 UChar *result1=NULL;
56 int32_t resultlength, resultlengthneeded;
57 UErrorCode status = U_ZERO_ERROR;
58
59
60 resultlength=0;
61 resultlengthneeded=udat_format(dat, d1, NULL, resultlength, NULL, &status);
62 if(status==U_BUFFER_OVERFLOW_ERROR)
63 {
64 status=U_ZERO_ERROR;
65 resultlength=resultlengthneeded+1;
66 result1=(UChar*)ctst_malloc(sizeof(UChar) * resultlength);
67 udat_format(dat, d1, result1, resultlength, NULL, &status);
68 }
69 if(U_FAILURE(status))
70 {
71 log_err("Error in formatting using udat_format(.....): %s\n", myErrorName(status));
72 return 0;
73 }
74 return result1;
75
76}
77
78#endif /* #if !UCONFIG_NO_FORMATTING */