summaryrefslogtreecommitdiff
path: root/Build/source/libs/icu-xetex/test/intltest/numfmtst.h
blob: 80baa1456e3690ba08d4da97adfcf6d88b93d94e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
/********************************************************************
 * COPYRIGHT: 
 * Copyright (c) 1997-2007, International Business Machines Corporation and
 * others. All Rights Reserved.
 ********************************************************************/
 
#ifndef _NUMBERFORMATTEST_
#define _NUMBERFORMATTEST_

#include "unicode/utypes.h"

#if !UCONFIG_NO_FORMATTING

#include "unicode/numfmt.h"
#include "unicode/decimfmt.h" 
#include "caltztst.h"

/**
 * Performs various in-depth test on NumberFormat
 **/
class NumberFormatTest: public CalendarTimeZoneTest {

    // IntlTest override
    void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par );
 public:

    /**
     * Test APIs (to increase code coverage)
     */   
    void TestAPI(void);

    void TestCoverage(void);

    /**
     * Test the handling of quotes
     **/
    void TestQuotes(void);
    /**
     * Test patterns with exponential representation
     **/
    void TestExponential(void);
    /**
     * Test handling of patterns with currency symbols
     **/
    void TestCurrencySign(void);
    /**
     * Test different format patterns
     **/
    void TestPatterns(void);
    /**
     * API coverage for DigitList
     **/
    //void TestDigitList(void);
    
    /**
     * Test localized currency patterns.
     */
    void TestCurrency(void);

    /**
     * Test the Currency object handling, new as of ICU 2.2.
     */
    void TestCurrencyObject(void);

    void TestCurrencyPatterns(void);

    /**
     * Do rudimentary testing of parsing.
     */
    void TestParse(void);
    /**
     * Test proper rounding by the format method.
     */
    void TestRounding487(void);

    // New tests for alphaWorks upgrade
    void TestExponent(void);

    void TestScientific(void);

    void TestScientific2(void);

    void TestScientificGrouping(void);

    void TestInt64(void);

    void TestSurrogateSupport(void);

    /**
     * Test the functioning of the secondary grouping value.
     */
    void TestSecondaryGrouping(void);

    void TestWhiteSpaceParsing(void);
        
    void TestComplexCurrency(void);
        
    void TestPad(void);
    void TestPatterns2(void);

    /**
     * Test currency registration.
     */
    void TestRegCurrency(void);

    void TestCurrencyNames(void);

    void TestCurrencyAmount(void);

    void TestCurrencyUnit(void);

    void TestSymbolsWithBadLocale(void);

    void TestAdoptDecimalFormatSymbols(void);

    void TestPerMill(void);

    void TestIllegalPatterns(void);
    
    void TestCases(void);

    void TestJB3832(void);

    void TestHost(void);

    void TestHostClone(void);

    void TestCurrencyFormat(void);
    
    /* Port of ICU4J rounding test. */
    void TestRounding(void);
 private:

    static UBool equalValue(const Formattable& a, const Formattable& b);

    void expect2(NumberFormat& fmt, const Formattable& n, const UnicodeString& str);

    void expect2(NumberFormat& fmt, const Formattable& n, const char* str) {
        expect2(fmt, n, UnicodeString(str, ""));
    }

    void expect2(NumberFormat* fmt, const Formattable& n, const UnicodeString& str, UErrorCode ec);

    void expect2(NumberFormat* fmt, const Formattable& n, const char* str, UErrorCode ec) {
        expect2(fmt, n, UnicodeString(str, ""), ec);
    }

    void expect(NumberFormat& fmt, const UnicodeString& str, const Formattable& n);

    void expect(NumberFormat& fmt, const char *str, const Formattable& n) {
        expect(fmt, UnicodeString(str, ""), n);
    }

    void expect(NumberFormat& fmt, const Formattable& n,
                const UnicodeString& exp, UBool rt=TRUE);

    void expect(NumberFormat& fmt, const Formattable& n,
                const char *exp, UBool rt=TRUE) {
        expect(fmt, n, UnicodeString(exp, ""), rt);
    }

    void expect(NumberFormat* fmt, const Formattable& n,
                const UnicodeString& exp, UErrorCode);

    void expect(NumberFormat* fmt, const Formattable& n,
                const char *exp, UErrorCode errorCode) {
        expect(fmt, n, UnicodeString(exp, ""), errorCode);
    }

    void expectCurrency(NumberFormat& nf, const Locale& locale,
                        double value, const UnicodeString& string);

    void expectPad(DecimalFormat& fmt, const UnicodeString& pat,
                   int32_t pos, int32_t width, UChar pad);

    void expectPad(DecimalFormat& fmt, const char *pat,
                   int32_t pos, int32_t width, UChar pad) {
        expectPad(fmt, UnicodeString(pat, ""), pos, width, pad);
    }

    void expectPad(DecimalFormat& fmt, const UnicodeString& pat,
                   int32_t pos, int32_t width, const UnicodeString& pad);

    void expectPad(DecimalFormat& fmt, const char *pat,
                   int32_t pos, int32_t width, const UnicodeString& pad) {
        expectPad(fmt, UnicodeString(pat, ""), pos, width, pad);
    }

    void expectPat(DecimalFormat& fmt, const UnicodeString& exp);

    void expectPat(DecimalFormat& fmt, const char *exp) {
        expectPat(fmt, UnicodeString(exp, ""));
    }

    void expectPad(DecimalFormat& fmt, const UnicodeString& pat,
                   int32_t pos);

    void expectPad(DecimalFormat& fmt, const char *pat,
                   int32_t pos) {
        expectPad(fmt, pat, pos, 0, (UChar)0);
    }

    // internal utility routine
    static UnicodeString& escape(UnicodeString& s);

    enum { ILLEGAL = -1 };

    // internal subtest used by TestRounding487
    void roundingTest(NumberFormat& nf, double x, int32_t maxFractionDigits, const char* expected);
    
    // internal rounding checking for TestRounding
    void checkRounding(DecimalFormat* df, double base, int iterations, double increment);
    
    double checkRound(DecimalFormat* df, double iValue, double lastParsed);
};

#endif /* #if !UCONFIG_NO_FORMATTING */
 
#endif // _NUMBERFORMATTEST_