]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/numfmtst.h
1 /********************************************************************
3 * Copyright (c) 1997-2006, International Business Machines Corporation and
4 * 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 TestCurrencyFormat(void);
129 static UBool
equalValue(const Formattable
& a
, const Formattable
& b
);
131 void expect2(NumberFormat
& fmt
, const Formattable
& n
, const UnicodeString
& str
);
133 void expect2(NumberFormat
& fmt
, const Formattable
& n
, const char* str
) {
134 expect2(fmt
, n
, UnicodeString(str
, ""));
137 void expect2(NumberFormat
* fmt
, const Formattable
& n
, const UnicodeString
& str
, UErrorCode ec
);
139 void expect2(NumberFormat
* fmt
, const Formattable
& n
, const char* str
, UErrorCode ec
) {
140 expect2(fmt
, n
, UnicodeString(str
, ""), ec
);
143 void expect(NumberFormat
& fmt
, const UnicodeString
& str
, const Formattable
& n
);
145 void expect(NumberFormat
& fmt
, const char *str
, const Formattable
& n
) {
146 expect(fmt
, UnicodeString(str
, ""), n
);
149 void expect(NumberFormat
& fmt
, const Formattable
& n
,
150 const UnicodeString
& exp
, UBool rt
=TRUE
);
152 void expect(NumberFormat
& fmt
, const Formattable
& n
,
153 const char *exp
, UBool rt
=TRUE
) {
154 expect(fmt
, n
, UnicodeString(exp
, ""), rt
);
157 void expect(NumberFormat
* fmt
, const Formattable
& n
,
158 const UnicodeString
& exp
, UErrorCode
);
160 void expect(NumberFormat
* fmt
, const Formattable
& n
,
161 const char *exp
, UErrorCode errorCode
) {
162 expect(fmt
, n
, UnicodeString(exp
, ""), errorCode
);
165 void expectCurrency(NumberFormat
& nf
, const Locale
& locale
,
166 double value
, const UnicodeString
& string
);
168 void expectPad(DecimalFormat
& fmt
, const UnicodeString
& pat
,
169 int32_t pos
, int32_t width
, UChar pad
);
171 void expectPad(DecimalFormat
& fmt
, const char *pat
,
172 int32_t pos
, int32_t width
, UChar pad
) {
173 expectPad(fmt
, UnicodeString(pat
, ""), pos
, width
, pad
);
176 void expectPad(DecimalFormat
& fmt
, const UnicodeString
& pat
,
177 int32_t pos
, int32_t width
, const UnicodeString
& pad
);
179 void expectPad(DecimalFormat
& fmt
, const char *pat
,
180 int32_t pos
, int32_t width
, const UnicodeString
& pad
) {
181 expectPad(fmt
, UnicodeString(pat
, ""), pos
, width
, pad
);
184 void expectPat(DecimalFormat
& fmt
, const UnicodeString
& exp
);
186 void expectPat(DecimalFormat
& fmt
, const char *exp
) {
187 expectPat(fmt
, UnicodeString(exp
, ""));
190 void expectPad(DecimalFormat
& fmt
, const UnicodeString
& pat
,
193 void expectPad(DecimalFormat
& fmt
, const char *pat
,
195 expectPad(fmt
, pat
, pos
, 0, (UChar
)0);
198 // internal utility routine
199 static UnicodeString
& escape(UnicodeString
& s
);
201 enum { ILLEGAL
= -1 };
203 // internal subtest used by TestRounding487
204 void roundingTest(NumberFormat
& nf
, double x
, int32_t maxFractionDigits
, const char* expected
);
207 #endif /* #if !UCONFIG_NO_FORMATTING */
209 #endif // _NUMBERFORMATTEST_