X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/46f4442e9a5a4f3b98b7c1083586332f6a8a99a4..b331163bffd790ced0e88b73f44f86d49ccc48a5:/icuSources/test/intltest/numfmtst.h?ds=sidebyside diff --git a/icuSources/test/intltest/numfmtst.h b/icuSources/test/intltest/numfmtst.h index 2909abd8..c65c778f 100644 --- a/icuSources/test/intltest/numfmtst.h +++ b/icuSources/test/intltest/numfmtst.h @@ -1,9 +1,9 @@ -/******************************************************************** - * COPYRIGHT: - * Copyright (c) 1997-2007, International Business Machines Corporation and - * others. All Rights Reserved. - ********************************************************************/ - +/************************************************************************ + * COPYRIGHT: + * Copyright (c) 1997-2015, International Business Machines Corporation + * and others. All Rights Reserved. + ************************************************************************/ + #ifndef _NUMBERFORMATTEST_ #define _NUMBERFORMATTEST_ @@ -12,7 +12,7 @@ #if !UCONFIG_NO_FORMATTING #include "unicode/numfmt.h" -#include "unicode/decimfmt.h" +#include "unicode/decimfmt.h" #include "caltztst.h" /** @@ -26,7 +26,7 @@ class NumberFormatTest: public CalendarTimeZoneTest { /** * Test APIs (to increase code coverage) - */ + */ void TestAPI(void); void TestCoverage(void); @@ -51,7 +51,7 @@ class NumberFormatTest: public CalendarTimeZoneTest { * API coverage for DigitList **/ //void TestDigitList(void); - + /** * Test localized currency patterns. */ @@ -92,9 +92,9 @@ class NumberFormatTest: public CalendarTimeZoneTest { void TestSecondaryGrouping(void); void TestWhiteSpaceParsing(void); - + void TestComplexCurrency(void); - + void TestPad(void); void TestPatterns2(void); @@ -116,7 +116,7 @@ class NumberFormatTest: public CalendarTimeZoneTest { void TestPerMill(void); void TestIllegalPatterns(void); - + void TestCases(void); void TestJB3832(void); @@ -126,21 +126,83 @@ class NumberFormatTest: public CalendarTimeZoneTest { void TestHostClone(void); void TestCurrencyFormat(void); - + /* Port of ICU4J rounding test. */ void TestRounding(void); + void TestRoundingPattern(void); + void TestNonpositiveMultiplier(void); - - void TestLenientParse(void); - void TestSpaceParsing(void); - + + void TestNumberingSystems(); + + + void TestSpaceParsing(); + void TestMultiCurrencySign(); + void TestCurrencyFormatForMixParsing(); + void TestDecimalFormatCurrencyParse(); + void TestCurrencyIsoPluralFormat(); + void TestCurrencyParsing(); + void TestParseCurrencyInUCurr(); + void TestFormatAttributes(); + void TestFieldPositionIterator(); + + void TestLenientParse(); + + void TestDecimal(); + void TestCurrencyFractionDigits(); + + void TestExponentParse(); + void TestExplicitParents(); + void TestAvailableNumberingSystems(); + void Test9087(); + void TestFormatFastpaths(); + + void TestFormattableSize(); + + void TestUFormattable(); + + void TestEnumSet(); + + void TestSignificantDigits(); + void TestShowZero(); + + void TestCompatibleCurrencies(); + void TestBug9936(); + void TestParseNegativeWithFaLocale(); + void TestParseNegativeWithAlternateMinusSign(); + + void TestCustomCurrencySignAndSeparator(); + + void TestParseSignsAndMarks(); + void Test10419RoundingWith0FractionDigits(); + void Test10468ApplyPattern(); + void TestRoundingScientific10542(); + void TestZeroScientific10547(); + void TestAccountingCurrency(); + void TestEquality(); + + void TestCurrencyUsage(); + void TestDoubleLimit11439(); + void TestFastPathConsistent11524(); + private: + UBool testFormattableAsUFormattable(const char *file, int line, Formattable &f); + + void expectParseCurrency(const NumberFormat &fmt, const UChar* currency, double amount, const char *text); static UBool equalValue(const Formattable& a, const Formattable& b); + void expectPositions(FieldPositionIterator& iter, int32_t *values, int32_t tupleCount, + const UnicodeString& str); + + void expectPosition(FieldPosition& pos, int32_t id, int32_t start, int32_t limit, + const UnicodeString& str); + void expect2(NumberFormat& fmt, const Formattable& n, const UnicodeString& str); + void expect3(NumberFormat& fmt, const Formattable& n, const UnicodeString& str); + void expect2(NumberFormat& fmt, const Formattable& n, const char* str) { expect2(fmt, n, UnicodeString(str, "")); } @@ -166,11 +228,21 @@ class NumberFormatTest: public CalendarTimeZoneTest { } void expect(NumberFormat* fmt, const Formattable& n, - const UnicodeString& exp, UErrorCode); + const UnicodeString& exp, UBool rt, UErrorCode errorCode); + + void expect(NumberFormat* fmt, const Formattable& n, + const char *exp, UBool rt, UErrorCode errorCode) { + expect(fmt, n, UnicodeString(exp, ""), rt, errorCode); + } + + void expect(NumberFormat* fmt, const Formattable& n, + const UnicodeString& exp, UErrorCode errorCode) { + expect(fmt, n, exp, TRUE, errorCode); + } void expect(NumberFormat* fmt, const Formattable& n, const char *exp, UErrorCode errorCode) { - expect(fmt, n, UnicodeString(exp, ""), errorCode); + expect(fmt, n, UnicodeString(exp, ""), TRUE, errorCode); } void expectCurrency(NumberFormat& nf, const Locale& locale, @@ -206,6 +278,11 @@ class NumberFormatTest: public CalendarTimeZoneTest { expectPad(fmt, pat, pos, 0, (UChar)0); } + void expect_rbnf(NumberFormat& fmt, const UnicodeString& str, const Formattable& n); + + void expect_rbnf(NumberFormat& fmt, const Formattable& n, + const UnicodeString& exp, UBool rt=TRUE); + // internal utility routine static UnicodeString& escape(UnicodeString& s); @@ -213,13 +290,23 @@ class NumberFormatTest: public CalendarTimeZoneTest { // 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); + + void verifyRounding( + DecimalFormat& format, + const double *values, + const char * const *expected, + const DecimalFormat::ERoundingMode *roundingModes, + const char * const *descriptions, + int32_t valueSize, + int32_t roundingModeSize); + }; #endif /* #if !UCONFIG_NO_FORMATTING */ - + #endif // _NUMBERFORMATTEST_