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