1 // © 2016 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html 3 /******************************************************************** 4 * COPYRIGHT: 5 * Copyright (c) 1997-2013, International Business Machines Corporation and 6 * others. All Rights Reserved. 7 ********************************************************************/ 8 9 #ifndef _PluralRulesTest 10 #define _PluralRulesTest 11 12 #include "unicode/utypes.h" 13 14 #if !UCONFIG_NO_FORMATTING 15 16 #include "intltest.h" 17 #include "number_decimalquantity.h" 18 #include "unicode/localpointer.h" 19 #include "unicode/plurrule.h" 20 21 /** 22 * Test basic functionality of various API functions 23 **/ 24 class PluralRulesTest : public IntlTest { 25 void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par = NULL ) override; 26 27 private: 28 /** 29 * Performs tests on many API functions, see detailed comments in source code 30 **/ 31 void testAPI(); 32 void testGetUniqueKeywordValue(); 33 void testGetSamples(); 34 void testGetDecimalQuantitySamples(); 35 void testGetOrAddSamplesFromString(); 36 void testGetOrAddSamplesFromStringCompactNotation(); 37 void testSamplesWithExponent(); 38 void testSamplesWithCompactNotation(); 39 void testWithin(); 40 void testGetAllKeywordValues(); 41 void testCompactDecimalPluralKeyword(); 42 void testDoubleValue(); 43 void testLongValue(); 44 void testScientificPluralKeyword(); 45 void testOrdinal(); 46 void testSelect(); 47 void testSelectRange(); 48 void testAvailableLocales(); 49 void testParseErrors(); 50 void testFixedDecimal(); 51 void testSelectTrailingZeros(); 52 void testLocaleExtension(); 53 54 void assertRuleValue(const UnicodeString& rule, double expected); 55 void assertRuleKeyValue(const UnicodeString& rule, const UnicodeString& key, 56 double expected); 57 void checkNewSamples(UnicodeString description, 58 const LocalPointer<PluralRules> &test, 59 UnicodeString keyword, 60 UnicodeString samplesString, 61 ::icu::number::impl::DecimalQuantity firstInRange); 62 UnicodeString getPluralKeyword(const LocalPointer<PluralRules> &rules, 63 Locale locale, double number, const char16_t* skeleton); 64 void checkSelect(const LocalPointer<PluralRules> &rules, UErrorCode &status, 65 int32_t line, const char *keyword, ...); 66 void compareLocaleResults(const char* loc1, const char* loc2, const char* loc3); 67 }; 68 69 #endif /* #if !UCONFIG_NO_FORMATTING */ 70 71 #endif 72