ICU-8499 change PluralRules::NO_UNIQUE_VALUE into #define UPLRULES_NO_UNIQUE_VALUE

X-SVN-Rev: 29911
This commit is contained in:
Markus Scherer 2011-04-27 20:04:06 +00:00
parent dfaf3a12d6
commit e25457f07a
3 changed files with 18 additions and 20 deletions

View File

@ -50,8 +50,6 @@ static const UChar PK_WITHIN[]={LOW_W,LOW_I,LOW_T,LOW_H,LOW_I,LOW_N,0};
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(PluralRules)
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(PluralKeywordEnumeration)
const double PluralRules::NO_UNIQUE_VALUE = -0.00123456777;
PluralRules::PluralRules(UErrorCode& status)
: UObject(),
mRules(NULL),
@ -210,7 +208,7 @@ PluralRules::getUniqueKeywordValue(const UnicodeString& keyword) {
double val;
UErrorCode status = U_ZERO_ERROR;
int32_t count = getSamplesInternal(keyword, &val, 1, FALSE, status);
return count == 1 ? val : NO_UNIQUE_VALUE;
return count == 1 ? val : UPLRULES_NO_UNIQUE_VALUE;
}
int32_t

View File

@ -27,6 +27,13 @@
#include "unicode/format.h"
/**
* Value returned by PluralRules::getUniqueKeywordValue() when there is no
* unique value to return.
* draft ICU 4.8
*/
#define UPLRULES_NO_UNIQUE_VALUE ((double)-0.00123456777)
U_NAMESPACE_BEGIN
class Hashtable;
@ -221,20 +228,13 @@ public:
*/
StringEnumeration* getKeywords(UErrorCode& status) const;
/**
* Value returned by getUniqueKeywordValue when there is no
* unique value to return.
* draft ICU 4.8
*/
static const double NO_UNIQUE_VALUE;
/**
* Returns a unique value for this keyword if it exists, else the constant
* NO_UNIQUE_VALUE.
* UPLRULES_NO_UNIQUE_VALUE.
*
* @param keyword The keyword.
* @return The unique value that generates the keyword, or
* NO_UNIQUE_VALUE if the keyword is undefined or there is no
* UPLRULES_NO_UNIQUE_VALUE if the keyword is undefined or there is no
* unique value that generates this keyword.
* @draft ICU 4.8
*/

View File

@ -358,16 +358,16 @@ void PluralRulesTest::testGetUniqueKeywordValue() {
assertRuleValue("n is 1", 1);
assertRuleValue("n in 2..2", 2);
assertRuleValue("n within 2..2", 2);
assertRuleValue("n in 3..4", PluralRules::NO_UNIQUE_VALUE);
assertRuleValue("n within 3..4", PluralRules::NO_UNIQUE_VALUE);
assertRuleValue("n in 3..4", UPLRULES_NO_UNIQUE_VALUE);
assertRuleValue("n within 3..4", UPLRULES_NO_UNIQUE_VALUE);
assertRuleValue("n is 2 or n is 2", 2);
assertRuleValue("n is 2 and n is 2", 2);
assertRuleValue("n is 2 or n is 3", PluralRules::NO_UNIQUE_VALUE);
assertRuleValue("n is 2 and n is 3", PluralRules::NO_UNIQUE_VALUE);
assertRuleValue("n is 2 or n in 2..3", PluralRules::NO_UNIQUE_VALUE);
assertRuleValue("n is 2 or n is 3", UPLRULES_NO_UNIQUE_VALUE);
assertRuleValue("n is 2 and n is 3", UPLRULES_NO_UNIQUE_VALUE);
assertRuleValue("n is 2 or n in 2..3", UPLRULES_NO_UNIQUE_VALUE);
assertRuleValue("n is 2 and n in 2..3", 2);
assertRuleKeyValue("a: n is 1", "not_defined", PluralRules::NO_UNIQUE_VALUE); // key not defined
assertRuleKeyValue("a: n is 1", "other", PluralRules::NO_UNIQUE_VALUE); // key matches default rule
assertRuleKeyValue("a: n is 1", "not_defined", UPLRULES_NO_UNIQUE_VALUE); // key not defined
assertRuleKeyValue("a: n is 1", "other", UPLRULES_NO_UNIQUE_VALUE); // key matches default rule
}
void PluralRulesTest::testGetSamples() {
@ -402,7 +402,7 @@ void PluralRulesTest::testGetSamples() {
count = 4;
}
for (int32_t j = 0; j < count; ++j) {
if (values[j] == PluralRules::NO_UNIQUE_VALUE) {
if (values[j] == UPLRULES_NO_UNIQUE_VALUE) {
errln("got 'no unique value' among values");
} else {
UnicodeString resultKeyword = rules->select(values[j]);