ICU-9009 For Alphabetic Index, add hard coded fall back in case there is no data available for defining the Labels.
X-SVN-Rev: 31424
This commit is contained in:
parent
9d6a55f33d
commit
9dbf80393c
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2009-2011, International Business Machines Corporation and *
|
||||
* Copyright (C) 2009-2012, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -218,6 +218,13 @@ void AlphabeticIndex::buildIndex(UErrorCode &status) {
|
||||
}
|
||||
}
|
||||
|
||||
// If we have no labels, hard-code a fallback default set of [A-Z]
|
||||
// This case can occur with locales that don't have exemplar character data, including root.
|
||||
// A no-labels situation will cause other problems; it needs to be avoided.
|
||||
if (labelSet.isEmpty()) {
|
||||
labelSet.add((UChar32)0x41, (UChar32)0x5A);
|
||||
}
|
||||
|
||||
// Move the set of Labels from the set into a vector, and sort
|
||||
// according to the collator.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/********************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 2011, International Business Machines Corporation and
|
||||
* Copyright (c) 2012, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
********************************************************************/
|
||||
//
|
||||
@ -43,6 +43,10 @@ void AlphabeticIndexTest::runIndexedTest( int32_t index, UBool exec, const char*
|
||||
if (exec) HackPinyinTest();
|
||||
break;
|
||||
|
||||
case 3: name = "TestBug9009";
|
||||
if (exec) TestBug9009();
|
||||
break;
|
||||
|
||||
default: name = "";
|
||||
break; //needed to end loop
|
||||
}
|
||||
@ -416,4 +420,16 @@ void AlphabeticIndexTest::HackPinyinTest() {
|
||||
TEST_ASSERT(bucketCount > 25);
|
||||
TEST_ASSERT(filledBucketCount > 15);
|
||||
}
|
||||
|
||||
|
||||
void AlphabeticIndexTest::TestBug9009() {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
Locale loc("root");
|
||||
AlphabeticIndex aindex(loc, status);
|
||||
TEST_CHECK_STATUS;
|
||||
aindex.nextBucket(status); // Crash here before bug was fixed.
|
||||
TEST_CHECK_STATUS;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,6 +1,6 @@
|
||||
/********************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 2011, International Business Machines Corporation and
|
||||
* Copyright (c) 2012, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
********************************************************************/
|
||||
//
|
||||
@ -23,6 +23,7 @@ public:
|
||||
virtual void APITest();
|
||||
virtual void ManyLocalesTest();
|
||||
virtual void HackPinyinTest();
|
||||
virtual void TestBug9009();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user