]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/numfmtst.h
1 /************************************************************************
3 * Copyright (c) 1997-2014, International Business Machines Corporation
4 * and others. All Rights Reserved.
5 ************************************************************************/
7 #ifndef _NUMBERFORMATTEST_
8 #define _NUMBERFORMATTEST_
10 #include "unicode/utypes.h"
12 #if !UCONFIG_NO_FORMATTING
14 #include "unicode/numfmt.h"
15 #include "unicode/decimfmt.h"
19 * Performs various in-depth test on NumberFormat
21 class NumberFormatTest
: public CalendarTimeZoneTest
{
24 void runIndexedTest( int32_t index
, UBool exec
, const char* &name
, char* par
);
28 * Test APIs (to increase code coverage)
32 void TestCoverage(void);
35 * Test the handling of quotes
37 void TestQuotes(void);
39 * Test patterns with exponential representation
41 void TestExponential(void);
43 * Test handling of patterns with currency symbols
45 void TestCurrencySign(void);
47 * Test different format patterns
49 void TestPatterns(void);
51 * API coverage for DigitList
53 //void TestDigitList(void);
56 * Test localized currency patterns.
58 void TestCurrency(void);
61 * Test the Currency object handling, new as of ICU 2.2.
63 void TestCurrencyObject(void);
65 void TestCurrencyPatterns(void);
68 * Do rudimentary testing of parsing.
72 * Test proper rounding by the format method.
74 void TestRounding487(void);
76 // New tests for alphaWorks upgrade
77 void TestExponent(void);
79 void TestScientific(void);
81 void TestScientific2(void);
83 void TestScientificGrouping(void);
87 void TestSurrogateSupport(void);
90 * Test the functioning of the secondary grouping value.
92 void TestSecondaryGrouping(void);
94 void TestWhiteSpaceParsing(void);
96 void TestComplexCurrency(void);
99 void TestPatterns2(void);
102 * Test currency registration.
104 void TestRegCurrency(void);
106 void TestCurrencyNames(void);
108 void TestCurrencyAmount(void);
110 void TestCurrencyUnit(void);
112 void TestSymbolsWithBadLocale(void);
114 void TestAdoptDecimalFormatSymbols(void);
116 void TestPerMill(void);
118 void TestIllegalPatterns(void);
120 void TestCases(void);
122 void TestJB3832(void);
126 void TestHostClone(void);
128 void TestCurrencyFormat(void);
130 /* Port of ICU4J rounding test. */
131 void TestRounding(void);
133 void TestRoundingPattern(void);
135 void TestNonpositiveMultiplier(void);
137 void TestNumberingSystems();
140 void TestSpaceParsing();
141 void TestMultiCurrencySign();
142 void TestCurrencyFormatForMixParsing();
143 void TestDecimalFormatCurrencyParse();
144 void TestCurrencyIsoPluralFormat();
145 void TestCurrencyParsing();
146 void TestParseCurrencyInUCurr();
147 void TestFormatAttributes();
148 void TestFieldPositionIterator();
150 void TestLenientParse();
153 void TestCurrencyFractionDigits();
155 void TestExponentParse();
156 void TestExplicitParents();
157 void TestAvailableNumberingSystems();
159 void TestFormatFastpaths();
161 void TestFormattableSize();
163 void TestUFormattable();
167 void TestSignificantDigits();
170 void TestCompatibleCurrencies();
172 void TestParseNegativeWithFaLocale();
173 void TestParseNegativeWithAlternateMinusSign();
175 void TestCustomCurrencySignAndSeparator();
177 void TestParseSignsAndMarks();
178 void Test10419RoundingWith0FractionDigits();
179 void Test10468ApplyPattern();
180 void TestRoundingScientific10542();
181 void TestZeroScientific10547();
182 void TestAccountingCurrency();
186 UBool
testFormattableAsUFormattable(const char *file
, int line
, Formattable
&f
);
188 void expectParseCurrency(const NumberFormat
&fmt
, const UChar
* currency
, double amount
, const char *text
);
190 static UBool
equalValue(const Formattable
& a
, const Formattable
& b
);
192 void expectPositions(FieldPositionIterator
& iter
, int32_t *values
, int32_t tupleCount
,
193 const UnicodeString
& str
);
195 void expectPosition(FieldPosition
& pos
, int32_t id
, int32_t start
, int32_t limit
,
196 const UnicodeString
& str
);
198 void expect2(NumberFormat
& fmt
, const Formattable
& n
, const UnicodeString
& str
);
200 void expect3(NumberFormat
& fmt
, const Formattable
& n
, const UnicodeString
& str
);
202 void expect2(NumberFormat
& fmt
, const Formattable
& n
, const char* str
) {
203 expect2(fmt
, n
, UnicodeString(str
, ""));
206 void expect2(NumberFormat
* fmt
, const Formattable
& n
, const UnicodeString
& str
, UErrorCode ec
);
208 void expect2(NumberFormat
* fmt
, const Formattable
& n
, const char* str
, UErrorCode ec
) {
209 expect2(fmt
, n
, UnicodeString(str
, ""), ec
);
212 void expect(NumberFormat
& fmt
, const UnicodeString
& str
, const Formattable
& n
);
214 void expect(NumberFormat
& fmt
, const char *str
, const Formattable
& n
) {
215 expect(fmt
, UnicodeString(str
, ""), n
);
218 void expect(NumberFormat
& fmt
, const Formattable
& n
,
219 const UnicodeString
& exp
, UBool rt
=TRUE
);
221 void expect(NumberFormat
& fmt
, const Formattable
& n
,
222 const char *exp
, UBool rt
=TRUE
) {
223 expect(fmt
, n
, UnicodeString(exp
, ""), rt
);
226 void expect(NumberFormat
* fmt
, const Formattable
& n
,
227 const UnicodeString
& exp
, UBool rt
, UErrorCode errorCode
);
229 void expect(NumberFormat
* fmt
, const Formattable
& n
,
230 const char *exp
, UBool rt
, UErrorCode errorCode
) {
231 expect(fmt
, n
, UnicodeString(exp
, ""), rt
, errorCode
);
234 void expect(NumberFormat
* fmt
, const Formattable
& n
,
235 const UnicodeString
& exp
, UErrorCode errorCode
) {
236 expect(fmt
, n
, exp
, TRUE
, errorCode
);
239 void expect(NumberFormat
* fmt
, const Formattable
& n
,
240 const char *exp
, UErrorCode errorCode
) {
241 expect(fmt
, n
, UnicodeString(exp
, ""), TRUE
, errorCode
);
244 void expectCurrency(NumberFormat
& nf
, const Locale
& locale
,
245 double value
, const UnicodeString
& string
);
247 void expectPad(DecimalFormat
& fmt
, const UnicodeString
& pat
,
248 int32_t pos
, int32_t width
, UChar pad
);
250 void expectPad(DecimalFormat
& fmt
, const char *pat
,
251 int32_t pos
, int32_t width
, UChar pad
) {
252 expectPad(fmt
, UnicodeString(pat
, ""), pos
, width
, pad
);
255 void expectPad(DecimalFormat
& fmt
, const UnicodeString
& pat
,
256 int32_t pos
, int32_t width
, const UnicodeString
& pad
);
258 void expectPad(DecimalFormat
& fmt
, const char *pat
,
259 int32_t pos
, int32_t width
, const UnicodeString
& pad
) {
260 expectPad(fmt
, UnicodeString(pat
, ""), pos
, width
, pad
);
263 void expectPat(DecimalFormat
& fmt
, const UnicodeString
& exp
);
265 void expectPat(DecimalFormat
& fmt
, const char *exp
) {
266 expectPat(fmt
, UnicodeString(exp
, ""));
269 void expectPad(DecimalFormat
& fmt
, const UnicodeString
& pat
,
272 void expectPad(DecimalFormat
& fmt
, const char *pat
,
274 expectPad(fmt
, pat
, pos
, 0, (UChar
)0);
277 void expect_rbnf(NumberFormat
& fmt
, const UnicodeString
& str
, const Formattable
& n
);
279 void expect_rbnf(NumberFormat
& fmt
, const Formattable
& n
,
280 const UnicodeString
& exp
, UBool rt
=TRUE
);
282 // internal utility routine
283 static UnicodeString
& escape(UnicodeString
& s
);
285 enum { ILLEGAL
= -1 };
287 // internal subtest used by TestRounding487
288 void roundingTest(NumberFormat
& nf
, double x
, int32_t maxFractionDigits
, const char* expected
);
290 // internal rounding checking for TestRounding
291 void checkRounding(DecimalFormat
* df
, double base
, int iterations
, double increment
);
293 double checkRound(DecimalFormat
* df
, double iValue
, double lastParsed
);
296 DecimalFormat
& format
,
297 const double *values
,
298 const char * const *expected
,
299 const DecimalFormat::ERoundingMode
*roundingModes
,
300 const char * const *descriptions
,
302 int32_t roundingModeSize
);
306 #endif /* #if !UCONFIG_NO_FORMATTING */
308 #endif // _NUMBERFORMATTEST_