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