use of android.icu.text.AlphabeticIndex.ImmutableIndex in project j2objc by google.
the class AlphabeticIndexTest method TestSchSt.
/**
* Test labels with multiple primary weights.
*/
@Test
public void TestSchSt() {
AlphabeticIndex index = new AlphabeticIndex(ULocale.GERMAN);
index.addLabels(new UnicodeSet("[Æ{Sch*}{St*}]"));
// ... A Æ B-R S Sch St T-Z ...
ImmutableIndex immIndex = index.buildImmutableIndex();
assertEquals("getBucketCount()", 31, index.getBucketCount());
assertEquals("immutable getBucketCount()", 31, immIndex.getBucketCount());
String[][] testCases = new String[][] { // name, bucket index, bucket label
{ "Adelbert", "1", "A" }, { "Afrika", "1", "A" }, { "Æsculap", "2", "Æ" }, { "Aesthet", "2", "Æ" }, { "Berlin", "3", "B" }, { "Rilke", "19", "R" }, { "Sacher", "20", "S" }, { "Seiler", "20", "S" }, { "Sultan", "20", "S" }, { "Schiller", "21", "Sch" }, { "Steiff", "22", "St" }, { "Thomas", "23", "T" } };
List<String> labels = index.getBucketLabels();
for (String[] testCase : testCases) {
String name = testCase[0];
int bucketIndex = Integer.valueOf(testCase[1]);
String label = testCase[2];
String msg = "getBucketIndex(" + name + ")";
assertEquals(msg, bucketIndex, index.getBucketIndex(name));
msg = "immutable " + msg;
assertEquals(msg, bucketIndex, immIndex.getBucketIndex(name));
msg = "bucket label (" + name + ")";
assertEquals(msg, label, labels.get(index.getBucketIndex(name)));
msg = "immutable " + msg;
assertEquals(msg, label, immIndex.getBucket(bucketIndex).getLabel());
}
}
use of android.icu.text.AlphabeticIndex.ImmutableIndex in project j2objc by google.
the class AlphabeticIndexTest method TestSetGetSpecialLabels.
@Test
public void TestSetGetSpecialLabels() {
AlphabeticIndex index = new AlphabeticIndex(Locale.GERMAN).addLabels(new Locale("ru"));
index.setUnderflowLabel("__");
index.setInflowLabel("--");
index.setOverflowLabel("^^");
assertEquals("underflow label", "__", index.getUnderflowLabel());
assertEquals("inflow label", "--", index.getInflowLabel());
assertEquals("overflow label", "^^", index.getOverflowLabel());
ImmutableIndex ii = index.buildImmutableIndex();
assertEquals("0 -> underflow", "__", ii.getBucket(ii.getBucketIndex("0")).getLabel());
assertEquals("Ω -> inflow", "--", ii.getBucket(ii.getBucketIndex("Ω")).getLabel());
assertEquals("字 -> overflow", "^^", ii.getBucket(ii.getBucketIndex("字")).getLabel());
}
use of android.icu.text.AlphabeticIndex.ImmutableIndex in project j2objc by google.
the class AlphabeticIndexTest method TestChineseZhuyin.
/**
* Test with the Bopomofo-phonetic tailoring.
*/
@Test
public void TestChineseZhuyin() {
AlphabeticIndex index = new AlphabeticIndex(ULocale.forLanguageTag("zh-u-co-zhuyin"));
ImmutableIndex immIndex = index.buildImmutableIndex();
// ... ㄅ ㄆ ㄇ ㄈ ㄉ -- ㄩ ...
assertEquals("getBucketCount()", 38, immIndex.getBucketCount());
assertEquals("label 1", "ㄅ", immIndex.getBucket(1).getLabel());
assertEquals("label 2", "ㄆ", immIndex.getBucket(2).getLabel());
assertEquals("label 3", "ㄇ", immIndex.getBucket(3).getLabel());
assertEquals("label 4", "ㄈ", immIndex.getBucket(4).getLabel());
assertEquals("label 5", "ㄉ", immIndex.getBucket(5).getLabel());
}
Aggregations