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