summaryrefslogtreecommitdiff
path: root/Build/source/libs/icu/icu-src/source/test/intltest/alphaindextst.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/icu/icu-src/source/test/intltest/alphaindextst.cpp')
-rw-r--r--Build/source/libs/icu/icu-src/source/test/intltest/alphaindextst.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/Build/source/libs/icu/icu-src/source/test/intltest/alphaindextst.cpp b/Build/source/libs/icu/icu-src/source/test/intltest/alphaindextst.cpp
index a3ebd1114a8..8a4edb27711 100644
--- a/Build/source/libs/icu/icu-src/source/test/intltest/alphaindextst.cpp
+++ b/Build/source/libs/icu/icu-src/source/test/intltest/alphaindextst.cpp
@@ -22,6 +22,7 @@
#include "unicode/localpointer.h"
#include "unicode/tblcoll.h"
#include "unicode/uniset.h"
+#include "unicode/uscript.h"
#if !UCONFIG_NO_COLLATION && !UCONFIG_NO_NORMALIZATION
@@ -66,6 +67,7 @@ void AlphabeticIndexTest::runIndexedTest( int32_t index, UBool exec, const char*
TESTCASE_AUTO(TestChineseZhuyin);
TESTCASE_AUTO(TestJapaneseKanji);
TESTCASE_AUTO(TestChineseUnihan);
+ TESTCASE_AUTO(testHasBuckets);
TESTCASE_AUTO_END;
}
@@ -724,4 +726,27 @@ void AlphabeticIndexTest::TestChineseUnihan() {
assertEquals("getBucketIndex(U+7527)", 101, bucketIndex);
}
+void AlphabeticIndexTest::testHasBuckets() {
+ checkHasBuckets(Locale("am"), USCRIPT_ETHIOPIC);
+ checkHasBuckets(Locale("haw"), USCRIPT_LATIN);
+ checkHasBuckets(Locale("hy"), USCRIPT_ARMENIAN);
+ checkHasBuckets(Locale("vai"), USCRIPT_VAI);
+}
+
+void AlphabeticIndexTest::checkHasBuckets(const Locale &locale, UScriptCode script) {
+ IcuTestErrorCode errorCode(*this, "checkHasBuckets");
+ AlphabeticIndex aindex(locale, errorCode);
+ LocalPointer<AlphabeticIndex::ImmutableIndex> index(aindex.buildImmutableIndex(errorCode), errorCode);
+ if (U_FAILURE(errorCode)) {
+ dataerrln("%s %d Error in index creation", __FILE__, __LINE__);
+ return;
+ }
+ UnicodeString loc = locale.getName();
+ assertTrue(loc + u" at least 3 buckets", index->getBucketCount() >= 3);
+ const AlphabeticIndex::Bucket *bucket = index->getBucket(1);
+ assertEquals(loc + u" real bucket", U_ALPHAINDEX_NORMAL, bucket->getLabelType());
+ assertEquals(loc + u" expected script", script,
+ uscript_getScript(bucket->getLabel().char32At(0), errorCode));
+}
+
#endif