]>
Commit | Line | Data |
---|---|---|
b75a7d8f A |
1 | /******************************************************************** |
2 | * COPYRIGHT: | |
2ca993e8 | 3 | * Copyright (c) 1997-2016, International Business Machines |
4388f060 | 4 | * Corporation 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 | ||
25 | void addCalTest(TestNode**); | |
26 | void addDateForTest(TestNode**); | |
4388f060 A |
27 | void addDateTimePatternGeneratorTest(TestNode**); |
28 | void addDateIntervalFormatTest(TestNode**); | |
2ca993e8 | 29 | void addRelativeDateFormatTest(TestNode**); |
b75a7d8f A |
30 | void addNumForTest(TestNode**); |
31 | void addMsgForTest(TestNode**); | |
32 | void addDateForRgrTest(TestNode**); | |
33 | void addNumFrDepTest(TestNode**); | |
34 | void addDtFrDepTest(TestNode**); | |
374ca955 | 35 | void addUtmsTest(TestNode**); |
73c04bcf | 36 | void addCurrencyTest(TestNode**); |
4388f060 | 37 | void addPluralRulesTest(TestNode**); |
51004dcb | 38 | void addURegionTest(TestNode** root); |
b331163b | 39 | void addUListFmtTest(TestNode** root); |
2ca993e8 | 40 | void addMeasureFormatTest(TestNode** root); |
b75a7d8f A |
41 | |
42 | void addFormatTest(TestNode** root); | |
43 | ||
44 | void addFormatTest(TestNode** root) | |
45 | { | |
46 | addCalTest(root); | |
47 | addDateForTest(root); | |
46f4442e | 48 | addDateTimePatternGeneratorTest(root); |
4388f060 | 49 | addDateIntervalFormatTest(root); |
2ca993e8 A |
50 | #if !UCONFIG_NO_BREAK_ITERATION |
51 | addRelativeDateFormatTest(root); | |
52 | #endif /* !UCONFIG_NO_BREAK_ITERATION */ | |
b75a7d8f A |
53 | addNumForTest(root); |
54 | addNumFrDepTest(root); | |
55 | addMsgForTest(root); | |
56 | addDateForRgrTest(root); | |
57 | addDtFrDepTest(root); | |
374ca955 | 58 | addUtmsTest(root); |
73c04bcf | 59 | addCurrencyTest(root); |
4388f060 | 60 | addPluralRulesTest(root); |
51004dcb | 61 | addURegionTest(root); |
b331163b | 62 | addUListFmtTest(root); |
2ca993e8 | 63 | addMeasureFormatTest(root); |
b75a7d8f | 64 | } |
374ca955 | 65 | /*Internal functions used*/ |
b75a7d8f A |
66 | |
67 | UChar* 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 */ |