"&\ud800\udc00 << B / w",
"&a\ud800\udc00m << B",
"&a << B / \ud800\udc00m",
};
RuleBasedCollator coll = null;
for (int i = 0; i < testrules.length; i ++) {
CollationElementIterator iter1 = null;
int j = 0;
// logln("Rule " + testrules[i] + " for testing\n");
String rule = testrules[i];
try {
coll = new RuleBasedCollator(rule);
} catch (Exception e) {
warnln("Collator creation failed " + testrules[i]);
return;
}
try {
iter1 = coll.getCollationElementIterator(testdata[i]);
} catch (Exception e) {
errln("Collation iterator creation failed\n");
return;
}
while (j < 2) {
CollationElementIterator iter2;
int ce;
try {
iter2 = coll.getCollationElementIterator(String.valueOf(testdata[i].charAt(j)));
}catch (Exception e) {
errln("Collation iterator creation failed\n");
return;
}
ce = iter2.next();
while (ce != CollationElementIterator.NULLORDER) {
if (iter1.next() != ce) {
errln("Collation elements in contraction split does not match\n");
return;
}
ce = iter2.next();
}
j ++;
}
if (iter1.next() != CollationElementIterator.NULLORDER) {
errln("Collation elements not exhausted\n");
return;
}
}
String rule = "& a < b < c < ch < d & c = ch / h";
try {
coll = new RuleBasedCollator(rule);
} catch (Exception e) {
errln("cannot create rulebased collator");
return;
}
if (coll.compare(testdata2[0], testdata2[1]) != -1) {
errln("Expected " + testdata2[0] + " < " + testdata2[1]);
return;
}
if (coll.compare(testdata2[1], testdata2[2]) != -1) {
errln("Expected " + testdata2[1] + " < " + testdata2[2]);
return;
}
for (int i = 0; i < testrules3.length; i += 2) {
RuleBasedCollator coll1, coll2;
CollationElementIterator iter1, iter2;
char ch = 0x0042;
int ce;
rule = testrules3[i];
try {
coll1 = new RuleBasedCollator(rule);
} catch (Exception e) {
errln("Fail: cannot create rulebased collator, rule:" + rule);
return;
}
rule = testrules3[i + 1];
try {
coll2 = new RuleBasedCollator(rule);
} catch (Exception e) {
errln("Collator creation failed " + testrules[i]);
return;
}
try {
iter1 = coll1.getCollationElementIterator(String.valueOf(ch));
iter2 = coll2.getCollationElementIterator(String.valueOf(ch));
} catch (Exception e) {
errln("Collation iterator creation failed\n");
return;
}