public void TestComposeDecompose()
{
Tester t[] = new Tester[0x30000];
t[0] = new Tester();
logln("Testing UCA extensively\n");
RuleBasedCollator coll;
try {
coll = (RuleBasedCollator)Collator.getInstance(Locale.ENGLISH);
}
catch (Exception e) {
warnln("Error opening collator\n");
return;
}
int noCases = 0;
for (int u = 0; u < 0x30000; u ++) {
String comp = UTF16.valueOf(u);
int len = comp.length();
t[noCases].NFC = Normalizer.normalize(u, Normalizer.NFC);
t[noCases].NFD = Normalizer.normalize(u, Normalizer.NFD);
if (t[noCases].NFC.length() != t[noCases].NFD.length()
|| (t[noCases].NFC.compareTo(t[noCases].NFD) != 0)
|| (len != t[noCases].NFD.length())
|| (comp.compareTo(t[noCases].NFD) != 0)) {
t[noCases].u = u;
if (len != t[noCases].NFD.length()
|| (comp.compareTo(t[noCases].NFD) != 0)) {
t[noCases].NFC = comp;
}
noCases ++;
t[noCases] = new Tester();
}
}
for (int u = 0; u < noCases; u ++) {
if (!coll.equals(t[u].NFC, t[u].NFD)) {
errln("Failure: codePoint \\u" + Integer.toHexString(t[u].u)
+ " fails TestComposeDecompose in the UCA");
CollationTest.doTest(this, coll, t[u].NFC, t[u].NFD, 0);
}
}
logln("Testing locales, number of cases = " + noCases);
Locale loc[] = Collator.getAvailableLocales();
for (int i = 0; i < loc.length; i ++) {
if (hasCollationElements(loc[i])) {
logln("Testing locale " + loc[i].getDisplayName());
coll = (RuleBasedCollator)Collator.getInstance(loc[i]);
coll.setStrength(Collator.IDENTICAL);
for (int u = 0; u < noCases; u ++) {
if (!coll.equals(t[u].NFC, t[u].NFD)) {
errln("Failure: codePoint \\u"
+ Integer.toHexString(t[u].u)
+ " fails TestComposeDecompose for locale "
+ loc[i].getDisplayName());
// this tests for the iterators too