2000-01-15 02:00:06 +00:00
|
|
|
/********************************************************************
|
|
|
|
* COPYRIGHT:
|
2006-01-09 23:03:31 +00:00
|
|
|
* Copyright (c) 1997-2006, International Business Machines Corporation and
|
2000-01-15 02:00:06 +00:00
|
|
|
* others. All Rights Reserved.
|
|
|
|
********************************************************************/
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
#ifndef _NUMBERFORMATTEST_
|
|
|
|
#define _NUMBERFORMATTEST_
|
2001-10-08 23:26:58 +00:00
|
|
|
|
2002-09-21 00:43:14 +00:00
|
|
|
#include "unicode/utypes.h"
|
|
|
|
|
|
|
|
#if !UCONFIG_NO_FORMATTING
|
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
#include "unicode/numfmt.h"
|
|
|
|
#include "unicode/decimfmt.h"
|
1999-08-16 21:50:52 +00:00
|
|
|
#include "caltztst.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Performs various in-depth test on NumberFormat
|
|
|
|
**/
|
|
|
|
class NumberFormatTest: public CalendarTimeZoneTest {
|
2003-04-21 19:16:38 +00:00
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
// IntlTest override
|
2000-08-14 21:42:36 +00:00
|
|
|
void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par );
|
2003-04-21 19:16:38 +00:00
|
|
|
public:
|
|
|
|
|
2001-11-28 22:28:16 +00:00
|
|
|
/**
|
|
|
|
* Test APIs (to increase code coverage)
|
|
|
|
*/
|
2003-04-21 19:16:38 +00:00
|
|
|
void TestAPI(void);
|
2005-07-14 23:24:38 +00:00
|
|
|
|
|
|
|
void TestCoverage(void);
|
|
|
|
|
2001-11-28 22:28:16 +00:00
|
|
|
/**
|
1999-08-16 21:50:52 +00:00
|
|
|
* Test the handling of quotes
|
|
|
|
**/
|
2003-04-21 19:16:38 +00:00
|
|
|
void TestQuotes(void);
|
1999-08-16 21:50:52 +00:00
|
|
|
/**
|
|
|
|
* Test patterns with exponential representation
|
|
|
|
**/
|
2003-04-21 19:16:38 +00:00
|
|
|
void TestExponential(void);
|
1999-08-16 21:50:52 +00:00
|
|
|
/**
|
|
|
|
* Test handling of patterns with currency symbols
|
|
|
|
**/
|
2003-04-21 19:16:38 +00:00
|
|
|
void TestCurrencySign(void);
|
1999-08-16 21:50:52 +00:00
|
|
|
/**
|
|
|
|
* Test different format patterns
|
|
|
|
**/
|
2003-04-21 19:16:38 +00:00
|
|
|
void TestPatterns(void);
|
2002-11-22 18:17:42 +00:00
|
|
|
/**
|
|
|
|
* API coverage for DigitList
|
|
|
|
**/
|
2003-04-23 05:23:01 +00:00
|
|
|
void TestDigitList(void);
|
2002-11-22 18:17:42 +00:00
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
/**
|
|
|
|
* Test localized currency patterns.
|
|
|
|
*/
|
2003-04-21 19:16:38 +00:00
|
|
|
void TestCurrency(void);
|
2002-05-13 19:37:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test the Currency object handling, new as of ICU 2.2.
|
|
|
|
*/
|
|
|
|
void TestCurrencyObject(void);
|
|
|
|
|
2002-07-31 19:17:34 +00:00
|
|
|
void TestCurrencyPatterns(void);
|
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
/**
|
|
|
|
* Do rudimentary testing of parsing.
|
|
|
|
*/
|
2003-04-21 19:16:38 +00:00
|
|
|
void TestParse(void);
|
1999-08-16 21:50:52 +00:00
|
|
|
/**
|
|
|
|
* Test proper rounding by the format method.
|
|
|
|
*/
|
2003-04-21 19:16:38 +00:00
|
|
|
void TestRounding487(void);
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
// New tests for alphaWorks upgrade
|
2003-04-21 19:16:38 +00:00
|
|
|
void TestExponent(void);
|
|
|
|
|
|
|
|
void TestScientific(void);
|
2000-06-07 00:17:23 +00:00
|
|
|
|
2003-10-29 00:20:05 +00:00
|
|
|
void TestScientific2(void);
|
|
|
|
|
|
|
|
void TestScientificGrouping(void);
|
|
|
|
|
2003-10-31 22:47:25 +00:00
|
|
|
void TestInt64(void);
|
|
|
|
|
2003-04-21 19:16:38 +00:00
|
|
|
void TestSurrogateSupport(void);
|
2001-09-20 21:34:19 +00:00
|
|
|
|
2000-06-07 00:17:23 +00:00
|
|
|
/**
|
|
|
|
* Test the functioning of the secondary grouping value.
|
|
|
|
*/
|
|
|
|
void TestSecondaryGrouping(void);
|
2003-04-04 20:55:10 +00:00
|
|
|
|
|
|
|
void TestWhiteSpaceParsing(void);
|
2000-06-07 00:17:23 +00:00
|
|
|
|
2003-04-21 22:48:41 +00:00
|
|
|
void TestComplexCurrency(void);
|
|
|
|
|
2003-04-21 19:16:38 +00:00
|
|
|
void TestPad(void);
|
|
|
|
void TestPatterns2(void);
|
|
|
|
|
2003-04-25 18:02:09 +00:00
|
|
|
/**
|
|
|
|
* Test currency registration.
|
|
|
|
*/
|
|
|
|
void TestRegCurrency(void);
|
|
|
|
|
2004-06-04 22:33:20 +00:00
|
|
|
void TestCurrencyNames(void);
|
|
|
|
|
2005-06-30 22:45:24 +00:00
|
|
|
void TestCurrencyAmount(void);
|
|
|
|
|
|
|
|
void TestCurrencyUnit(void);
|
|
|
|
|
2003-05-08 23:17:49 +00:00
|
|
|
void TestSymbolsWithBadLocale(void);
|
|
|
|
|
2003-05-26 20:21:40 +00:00
|
|
|
void TestAdoptDecimalFormatSymbols(void);
|
|
|
|
|
2004-02-12 01:10:19 +00:00
|
|
|
void TestPerMill(void);
|
|
|
|
|
2004-02-20 19:40:31 +00:00
|
|
|
void TestIllegalPatterns(void);
|
2006-01-09 23:03:31 +00:00
|
|
|
|
2004-03-25 17:42:28 +00:00
|
|
|
void TestCases(void);
|
|
|
|
|
2006-01-09 23:03:31 +00:00
|
|
|
void TestJB3832(void);
|
2006-01-23 23:25:00 +00:00
|
|
|
|
|
|
|
void TestHost(void);
|
2003-04-21 19:16:38 +00:00
|
|
|
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) {
|
2000-03-31 22:02:12 +00:00
|
|
|
expect(fmt, UnicodeString(str, ""), n);
|
|
|
|
}
|
2003-04-21 19:16:38 +00:00
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
void expect(NumberFormat& fmt, const Formattable& n,
|
2003-04-21 19:16:38 +00:00
|
|
|
const UnicodeString& exp, UBool rt=TRUE);
|
|
|
|
|
2000-03-31 22:02:12 +00:00
|
|
|
void expect(NumberFormat& fmt, const Formattable& n,
|
2003-04-21 19:16:38 +00:00
|
|
|
const char *exp, UBool rt=TRUE) {
|
|
|
|
expect(fmt, n, UnicodeString(exp, ""), rt);
|
2000-03-31 22:02:12 +00:00
|
|
|
}
|
2003-04-21 19:16:38 +00:00
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
void expect(NumberFormat* fmt, const Formattable& n,
|
|
|
|
const UnicodeString& exp, UErrorCode);
|
2003-04-21 19:16:38 +00:00
|
|
|
|
2000-03-31 22:02:12 +00:00
|
|
|
void expect(NumberFormat* fmt, const Formattable& n,
|
|
|
|
const char *exp, UErrorCode errorCode) {
|
|
|
|
expect(fmt, n, UnicodeString(exp, ""), errorCode);
|
|
|
|
}
|
2003-04-21 19:16:38 +00:00
|
|
|
|
|
|
|
void expectCurrency(NumberFormat& nf, const Locale& locale,
|
|
|
|
double value, const UnicodeString& string);
|
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
void expectPad(DecimalFormat& fmt, const UnicodeString& pat,
|
|
|
|
int32_t pos, int32_t width, UChar pad);
|
2003-04-21 19:16:38 +00:00
|
|
|
|
2000-03-31 22:02:12 +00:00
|
|
|
void expectPad(DecimalFormat& fmt, const char *pat,
|
|
|
|
int32_t pos, int32_t width, UChar pad) {
|
|
|
|
expectPad(fmt, UnicodeString(pat, ""), pos, width, pad);
|
|
|
|
}
|
2003-04-21 19:16:38 +00:00
|
|
|
|
2000-06-01 18:46:31 +00:00
|
|
|
void expectPad(DecimalFormat& fmt, const UnicodeString& pat,
|
2000-06-02 00:36:28 +00:00
|
|
|
int32_t pos, int32_t width, const UnicodeString& pad);
|
2003-04-21 19:16:38 +00:00
|
|
|
|
2000-06-01 18:46:31 +00:00
|
|
|
void expectPad(DecimalFormat& fmt, const char *pat,
|
2000-06-02 00:36:28 +00:00
|
|
|
int32_t pos, int32_t width, const UnicodeString& pad) {
|
2000-06-01 18:46:31 +00:00
|
|
|
expectPad(fmt, UnicodeString(pat, ""), pos, width, pad);
|
|
|
|
}
|
|
|
|
|
2005-01-02 19:30:11 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2003-04-21 19:16:38 +00:00
|
|
|
// internal utility routine
|
|
|
|
static UnicodeString& escape(UnicodeString& s);
|
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
enum { ILLEGAL = -1 };
|
|
|
|
|
|
|
|
// internal subtest used by TestRounding487
|
2000-06-07 00:17:23 +00:00
|
|
|
void roundingTest(NumberFormat& nf, double x, int32_t maxFractionDigits, const char* expected);
|
1999-08-16 21:50:52 +00:00
|
|
|
};
|
2002-09-21 00:43:14 +00:00
|
|
|
|
|
|
|
#endif /* #if !UCONFIG_NO_FORMATTING */
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
#endif // _NUMBERFORMATTEST_
|