2000-01-15 02:00:06 +00:00
|
|
|
/********************************************************************
|
|
|
|
* COPYRIGHT:
|
2001-03-21 20:09:56 +00:00
|
|
|
* Copyright (c) 1997-2001, 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_
|
|
|
|
|
|
|
|
#include "caltztst.h"
|
|
|
|
class NumberFormat;
|
|
|
|
class DecimalFormat;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Performs various in-depth test on NumberFormat
|
|
|
|
**/
|
|
|
|
class NumberFormatTest: public CalendarTimeZoneTest {
|
|
|
|
// IntlTest override
|
2000-08-14 21:42:36 +00:00
|
|
|
void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par );
|
1999-08-16 21:50:52 +00:00
|
|
|
public:
|
|
|
|
/*
|
|
|
|
* Test the handling of quotes
|
|
|
|
**/
|
1999-12-22 22:57:04 +00:00
|
|
|
virtual void TestQuotes(void);
|
1999-08-16 21:50:52 +00:00
|
|
|
/**
|
|
|
|
* Test patterns with exponential representation
|
|
|
|
**/
|
1999-12-22 22:57:04 +00:00
|
|
|
virtual void TestExponential(void);
|
1999-08-16 21:50:52 +00:00
|
|
|
/**
|
|
|
|
* Test handling of patterns with currency symbols
|
|
|
|
**/
|
1999-12-22 22:57:04 +00:00
|
|
|
virtual void TestCurrencySign(void);
|
1999-08-16 21:50:52 +00:00
|
|
|
/**
|
|
|
|
* Test different format patterns
|
|
|
|
**/
|
1999-12-22 22:57:04 +00:00
|
|
|
virtual void TestPatterns(void);
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
public: // package
|
|
|
|
// internal utility routine
|
|
|
|
static UnicodeString& escape(UnicodeString& s);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Test localized currency patterns.
|
|
|
|
*/
|
1999-12-22 22:57:04 +00:00
|
|
|
virtual void TestCurrency(void);
|
1999-08-16 21:50:52 +00:00
|
|
|
/**
|
|
|
|
* Do rudimentary testing of parsing.
|
|
|
|
*/
|
1999-12-22 22:57:04 +00:00
|
|
|
virtual void TestParse(void);
|
1999-08-16 21:50:52 +00:00
|
|
|
/**
|
|
|
|
* Test proper rounding by the format method.
|
|
|
|
*/
|
1999-12-22 22:57:04 +00:00
|
|
|
virtual void TestRounding487(void);
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
// New tests for alphaWorks upgrade
|
1999-12-22 22:57:04 +00:00
|
|
|
virtual void TestExponent(void);
|
|
|
|
virtual void TestScientific(void);
|
2000-06-07 00:17:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test the functioning of the secondary grouping value.
|
|
|
|
*/
|
|
|
|
void TestSecondaryGrouping(void);
|
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
void expect(NumberFormat& fmt, const UnicodeString& str, int32_t n);
|
2000-03-31 22:02:12 +00:00
|
|
|
void expect(NumberFormat& fmt, const char *str, int32_t n) {
|
|
|
|
expect(fmt, UnicodeString(str, ""), n);
|
|
|
|
}
|
1999-08-16 21:50:52 +00:00
|
|
|
void expect(NumberFormat& fmt, const Formattable& n,
|
|
|
|
const UnicodeString& exp);
|
2000-03-31 22:02:12 +00:00
|
|
|
void expect(NumberFormat& fmt, const Formattable& n,
|
|
|
|
const char *exp) {
|
|
|
|
expect(fmt, n, UnicodeString(exp, ""));
|
|
|
|
}
|
1999-08-16 21:50:52 +00:00
|
|
|
void expect(NumberFormat* fmt, const Formattable& n,
|
|
|
|
const UnicodeString& exp, UErrorCode);
|
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);
|
|
|
|
}
|
1999-12-22 22:57:04 +00:00
|
|
|
void TestPad(void);
|
|
|
|
void TestPatterns2(void);
|
1999-08-16 21:50:52 +00:00
|
|
|
void expectPad(DecimalFormat& fmt, const UnicodeString& pat,
|
|
|
|
int32_t pos);
|
2000-03-31 22:02:12 +00:00
|
|
|
void expectPad(DecimalFormat& fmt, const char *pat,
|
|
|
|
int32_t pos) {
|
|
|
|
expectPad(fmt, pat, pos, 0, (UChar)0);
|
|
|
|
}
|
1999-08-16 21:50:52 +00:00
|
|
|
void expectPad(DecimalFormat& fmt, const UnicodeString& pat,
|
|
|
|
int32_t pos, int32_t width, UChar pad);
|
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);
|
|
|
|
}
|
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);
|
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);
|
|
|
|
}
|
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
void expectPat(DecimalFormat& fmt, const UnicodeString& exp);
|
2000-03-31 22:02:12 +00:00
|
|
|
void expectPat(DecimalFormat& fmt, const char *exp) {
|
|
|
|
expectPat(fmt, UnicodeString(exp, ""));
|
|
|
|
}
|
1999-08-16 21:50:52 +00:00
|
|
|
enum { ILLEGAL = -1 };
|
|
|
|
|
|
|
|
public: // package
|
|
|
|
// 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
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _NUMBERFORMATTEST_
|