]>
Commit | Line | Data |
---|---|---|
b75a7d8f A |
1 | /******************************************************************** |
2 | * COPYRIGHT: | |
b331163b | 3 | * Copyright (c) 1997-2015, 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**); | |
b75a7d8f A |
29 | void addNumForTest(TestNode**); |
30 | void addMsgForTest(TestNode**); | |
31 | void addDateForRgrTest(TestNode**); | |
32 | void addNumFrDepTest(TestNode**); | |
33 | void addDtFrDepTest(TestNode**); | |
374ca955 | 34 | void addUtmsTest(TestNode**); |
73c04bcf | 35 | void addCurrencyTest(TestNode**); |
4388f060 | 36 | void addPluralRulesTest(TestNode**); |
51004dcb | 37 | void addURegionTest(TestNode** root); |
b331163b | 38 | void addUListFmtTest(TestNode** root); |
b75a7d8f A |
39 | |
40 | void addFormatTest(TestNode** root); | |
41 | ||
42 | void addFormatTest(TestNode** root) | |
43 | { | |
44 | addCalTest(root); | |
45 | addDateForTest(root); | |
46f4442e | 46 | addDateTimePatternGeneratorTest(root); |
4388f060 | 47 | addDateIntervalFormatTest(root); |
b75a7d8f A |
48 | addNumForTest(root); |
49 | addNumFrDepTest(root); | |
50 | addMsgForTest(root); | |
51 | addDateForRgrTest(root); | |
52 | addDtFrDepTest(root); | |
374ca955 | 53 | addUtmsTest(root); |
73c04bcf | 54 | addCurrencyTest(root); |
4388f060 | 55 | addPluralRulesTest(root); |
51004dcb | 56 | addURegionTest(root); |
b331163b | 57 | addUListFmtTest(root); |
b75a7d8f | 58 | } |
374ca955 | 59 | /*Internal functions used*/ |
b75a7d8f A |
60 | |
61 | UChar* myDateFormat(UDateFormat* dat, UDate d1) | |
62 | { | |
63 | UChar *result1=NULL; | |
64 | int32_t resultlength, resultlengthneeded; | |
65 | UErrorCode status = U_ZERO_ERROR; | |
66 | ||
67 | ||
68 | resultlength=0; | |
69 | resultlengthneeded=udat_format(dat, d1, NULL, resultlength, NULL, &status); | |
70 | if(status==U_BUFFER_OVERFLOW_ERROR) | |
71 | { | |
72 | status=U_ZERO_ERROR; | |
73 | resultlength=resultlengthneeded+1; | |
74 | result1=(UChar*)ctst_malloc(sizeof(UChar) * resultlength); | |
75 | udat_format(dat, d1, result1, resultlength, NULL, &status); | |
76 | } | |
77 | if(U_FAILURE(status)) | |
78 | { | |
79 | log_err("Error in formatting using udat_format(.....): %s\n", myErrorName(status)); | |
80 | return 0; | |
81 | } | |
82 | return result1; | |
83 | ||
84 | } | |
85 | ||
86 | #endif /* #if !UCONFIG_NO_FORMATTING */ |