]> git.saurik.com Git - apple/icu.git/blame_incremental - icuSources/test/cintltst/cformtst.c
ICU-57163.0.1.tar.gz
[apple/icu.git] / icuSources / test / cintltst / cformtst.c
... / ...
CommitLineData
1/********************************************************************
2 * COPYRIGHT:
3 * Copyright (c) 1997-2016, International Business Machines
4 * Corporation and others. All Rights Reserved.
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 addDateTimePatternGeneratorTest(TestNode**);
28void addDateIntervalFormatTest(TestNode**);
29void addRelativeDateFormatTest(TestNode**);
30void addNumForTest(TestNode**);
31void addMsgForTest(TestNode**);
32void addDateForRgrTest(TestNode**);
33void addNumFrDepTest(TestNode**);
34void addDtFrDepTest(TestNode**);
35void addUtmsTest(TestNode**);
36void addCurrencyTest(TestNode**);
37void addPluralRulesTest(TestNode**);
38void addURegionTest(TestNode** root);
39void addUListFmtTest(TestNode** root);
40void addMeasureFormatTest(TestNode** root);
41
42void addFormatTest(TestNode** root);
43
44void addFormatTest(TestNode** root)
45{
46 addCalTest(root);
47 addDateForTest(root);
48 addDateTimePatternGeneratorTest(root);
49 addDateIntervalFormatTest(root);
50#if !UCONFIG_NO_BREAK_ITERATION
51 addRelativeDateFormatTest(root);
52#endif /* !UCONFIG_NO_BREAK_ITERATION */
53 addNumForTest(root);
54 addNumFrDepTest(root);
55 addMsgForTest(root);
56 addDateForRgrTest(root);
57 addDtFrDepTest(root);
58 addUtmsTest(root);
59 addCurrencyTest(root);
60 addPluralRulesTest(root);
61 addURegionTest(root);
62 addUListFmtTest(root);
63 addMeasureFormatTest(root);
64}
65/*Internal functions used*/
66
67UChar* myDateFormat(UDateFormat* dat, UDate d1)
68{
69 UChar *result1=NULL;
70 int32_t resultlength, resultlengthneeded;
71 UErrorCode status = U_ZERO_ERROR;
72
73
74 resultlength=0;
75 resultlengthneeded=udat_format(dat, d1, NULL, resultlength, NULL, &status);
76 if(status==U_BUFFER_OVERFLOW_ERROR)
77 {
78 status=U_ZERO_ERROR;
79 resultlength=resultlengthneeded+1;
80 result1=(UChar*)ctst_malloc(sizeof(UChar) * resultlength);
81 udat_format(dat, d1, result1, resultlength, NULL, &status);
82 }
83 if(U_FAILURE(status))
84 {
85 log_err("Error in formatting using udat_format(.....): %s\n", myErrorName(status));
86 return 0;
87 }
88 return result1;
89
90}
91
92#endif /* #if !UCONFIG_NO_FORMATTING */