public void TestMaxExpansion(/* char* par */) { int unassigned = 0xEFFFD; String rule = "&a < ab < c/aba < d < z < ch"; RuleBasedCollator coll = null; try { coll = new RuleBasedCollator(rule); } catch (Exception e) { Warnln("Fail to create RuleBasedCollator"); return; } char ch = (char)0; String str = ch + ""; CollationElementIterator iter = coll.GetCollationElementIterator(str); while (ch < 0xFFFF) { int count = 1; ch++; str = ch + ""; iter.SetText(str); int order = iter.Previous(); // thai management if (order == 0) { order = iter.Previous(); } while (iter.Previous() != CollationElementIterator.NullOrder) { count++; } if (iter.GetMaxExpansion(order) < count) { Errln("Failure at codepoint " + ch + ", maximum expansion count < " + count); } } // testing for exact max expansion ch = (char)0; while (ch < 0x61) { str = ch + ""; iter.SetText(str); int order = iter.Previous(); if (iter.GetMaxExpansion(order) != 1) { Errln("Failure at codepoint 0x" + (ch).ToHexString() + " maximum expansion count == 1"); } ch++; } ch = (char)0x63; str = ch + ""; iter.SetText(str); int temporder = iter.Previous(); if (iter.GetMaxExpansion(temporder) != 3) { Errln("Failure at codepoint 0x" + (ch).ToHexString() + " maximum expansion count == 3"); } ch = (char)0x64; str = ch + ""; iter.SetText(str); temporder = iter.Previous(); if (iter.GetMaxExpansion(temporder) != 1) { Errln("Failure at codepoint 0x" + (ch).ToHexString() + " maximum expansion count == 1"); } str = UChar.ConvertFromUtf32(unassigned); iter.SetText(str); temporder = iter.Previous(); if (iter.GetMaxExpansion(temporder) != 2) { Errln("Failure at codepoint 0x" + (ch).ToHexString() + " maximum expansion count == 2"); } // testing jamo ch = (char)0x1165; str = ch + ""; iter.SetText(str); temporder = iter.Previous(); if (iter.GetMaxExpansion(temporder) > 3) { Errln("Failure at codepoint 0x" + (ch).ToHexString() + " maximum expansion count < 3"); } // testing special jamo &a<\u1165 rule = "\u0026\u0071\u003c\u1165\u002f\u0071\u0071\u0071\u0071"; try { coll = new RuleBasedCollator(rule); } catch (Exception e) { Errln("Fail to create RuleBasedCollator"); return; } iter = coll.GetCollationElementIterator(str); temporder = iter.Previous(); if (iter.GetMaxExpansion(temporder) != 6) { Errln("Failure at codepoint 0x" + (ch).ToHexString() + " maximum expansion count == 6"); } }