X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/0f5d89e82340278ed3d7d50029f37cab2c41a57e..HEAD:/icuSources/test/intltest/numbertest.h diff --git a/icuSources/test/intltest/numbertest.h b/icuSources/test/intltest/numbertest.h index 8984fdc3..7f5bcdf4 100644 --- a/icuSources/test/intltest/numbertest.h +++ b/icuSources/test/intltest/numbertest.h @@ -6,11 +6,15 @@ #if !UCONFIG_NO_FORMATTING #pragma once -#include "number_stringbuilder.h" +#include "formatted_string_builder.h" #include "intltest.h" +#include "itformat.h" #include "number_affixutils.h" -#include "numparse_stringsegment.h" +#include "string_segment.h" +#include "numrange_impl.h" #include "unicode/locid.h" +#include "unicode/numberformatter.h" +#include "unicode/numberrangeformatter.h" using namespace icu::number; using namespace icu::number::impl; @@ -40,7 +44,7 @@ class AffixUtilsTest : public IntlTest { UErrorCode &status); }; -class NumberFormatterApiTest : public IntlTest { +class NumberFormatterApiTest : public IntlTestWithFieldPosition { public: NumberFormatterApiTest(); NumberFormatterApiTest(UErrorCode &status); @@ -52,6 +56,7 @@ class NumberFormatterApiTest : public IntlTest { void unitCompoundMeasure(); void unitCurrency(); void unitPercent(); + void percentParity(); void roundingFraction(); void roundingFigures(); void roundingFractionFigures(); @@ -63,16 +68,21 @@ class NumberFormatterApiTest : public IntlTest { // TODO: Add this method if currency symbols override support is added. //void symbolsOverride(); void sign(); + void signCoverage(); void decimal(); void scale(); void locale(); + void skeletonUserGuideExamples(); void formatTypes(); - void fieldPosition(); + void fieldPositionLogic(); + void fieldPositionCoverage(); void toFormat(); void errors(); void validRanges(); void copyMove(); void localPointerCAPI(); + void toObject(); + void toDecimalNumber(); void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par = 0); @@ -83,6 +93,7 @@ class NumberFormatterApiTest : public IntlTest { CurrencyUnit CAD; CurrencyUnit ESP; CurrencyUnit PTE; + CurrencyUnit RON; MeasureUnit METER; MeasureUnit DAY; @@ -108,11 +119,18 @@ class NumberFormatterApiTest : public IntlTest { void assertFormatDescendingBig(const char16_t* message, const char16_t* skeleton, const UnlocalizedNumberFormatter& f, Locale locale, ...); - void assertFormatSingle(const char16_t* message, const char16_t* skeleton, - const UnlocalizedNumberFormatter& f, Locale locale, double input, - const UnicodeString& expected); + FormattedNumber + assertFormatSingle(const char16_t* message, const char16_t* skeleton, + const UnlocalizedNumberFormatter& f, Locale locale, double input, + const UnicodeString& expected); void assertUndefinedSkeleton(const UnlocalizedNumberFormatter& f); + + void assertNumberFieldPositions( + const char16_t* message, + const FormattedNumber& formattedNumber, + const UFieldPosition* expectedFieldPositions, + int32_t length); }; class DecimalQuantityTest : public IntlTest { @@ -126,6 +144,7 @@ class DecimalQuantityTest : public IntlTest { void testHardDoubleConversion(); void testToDouble(); void testMaxDigits(); + void testNickelRounding(); void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par = 0); @@ -157,7 +176,7 @@ class ModifiersTest : public IntlTest { UnicodeString expectedChars, UnicodeString expectedFields, UErrorCode &status); - void assertModifierEquals(const Modifier &mod, NumberStringBuilder &sb, int32_t expectedPrefixLength, + void assertModifierEquals(const Modifier &mod, FormattedStringBuilder &sb, int32_t expectedPrefixLength, bool expectedStrong, UnicodeString expectedChars, UnicodeString expectedFields, UErrorCode &status); }; @@ -187,33 +206,6 @@ class PatternStringTest : public IntlTest { private: }; -class NumberStringBuilderTest : public IntlTest { - public: - void testInsertAppendUnicodeString(); - void testSplice(); - void testInsertAppendCodePoint(); - void testCopy(); - void testFields(); - void testUnlimitedCapacity(); - void testCodePoints(); - - void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par = 0); - - private: - void assertEqualsImpl(const UnicodeString &a, const NumberStringBuilder &b); -}; - -class StringSegmentTest : public IntlTest { - public: - void testOffset(); - void testLength(); - void testCharAt(); - void testGetCodePoint(); - void testCommonPrefixLength(); - - void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par = 0); -}; - class NumberParserTest : public IntlTest { public: void testBasic(); @@ -223,6 +215,8 @@ class NumberParserTest : public IntlTest { void testAffixPatternMatcher(); void testGroupingDisabled(); void testCaseFolding(); + void test20360_BidiOverflow(); + void testInfiniteRecursion(); void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par = 0); }; @@ -244,6 +238,63 @@ class NumberSkeletonTest : public IntlTest { void expectedErrorSkeleton(const char16_t** cases, int32_t casesLen); }; +class NumberRangeFormatterTest : public IntlTestWithFieldPosition { + public: + NumberRangeFormatterTest(); + NumberRangeFormatterTest(UErrorCode &status); + + void testSanity(); + void testBasic(); + void testCollapse(); + void testIdentity(); + void testDifferentFormatters(); + void testPlurals(); + void testFieldPositions(); + void testCopyMove(); + void toObject(); + + void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par = 0); + + private: + CurrencyUnit USD; + CurrencyUnit GBP; + CurrencyUnit PTE; + + MeasureUnit METER; + MeasureUnit KILOMETER; + MeasureUnit FAHRENHEIT; + MeasureUnit KELVIN; + + void assertFormatRange( + const char16_t* message, + const UnlocalizedNumberRangeFormatter& f, + Locale locale, + const char16_t* expected_10_50, + const char16_t* expected_49_51, + const char16_t* expected_50_50, + const char16_t* expected_00_30, + const char16_t* expected_00_00, + const char16_t* expected_30_3K, + const char16_t* expected_30K_50K, + const char16_t* expected_49K_51K, + const char16_t* expected_50K_50K, + const char16_t* expected_50K_50M); + + FormattedNumberRange assertFormattedRangeEquals( + const char16_t* message, + const LocalizedNumberRangeFormatter& l, + double first, + double second, + const char16_t* expected); +}; + +class NumberPermutationTest : public IntlTest { + public: + void testPermutations(); + + void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par = 0); +}; + // NOTE: This macro is identical to the one in itformat.cpp #define TESTCLASS(id, TestClass) \ @@ -271,11 +322,11 @@ class NumberTest : public IntlTest { TESTCLASS(3, ModifiersTest); TESTCLASS(4, PatternModifierTest); TESTCLASS(5, PatternStringTest); - TESTCLASS(6, NumberStringBuilderTest); - TESTCLASS(7, DoubleConversionTest); - TESTCLASS(8, StringSegmentTest); - TESTCLASS(9, NumberParserTest); - TESTCLASS(10, NumberSkeletonTest); + TESTCLASS(6, DoubleConversionTest); + TESTCLASS(7, NumberParserTest); + TESTCLASS(8, NumberSkeletonTest); + TESTCLASS(9, NumberRangeFormatterTest); + TESTCLASS(10, NumberPermutationTest); default: name = ""; break; // needed to end loop } }