* getCollationElementIterator(java.text.CharacterIterator)
*/
public void testGetCollationElementIteratorCharacterIterator() throws Exception {
{
Locale locale = new Locale("es", "", "TRADITIONAL");
RuleBasedCollator coll = (RuleBasedCollator) Collator
.getInstance(locale);
String text = "cha";
StringCharacterIterator source = new StringCharacterIterator(text);
CollationElementIterator iterator = coll
.getCollationElementIterator(source);
int[] e_offset = { 0, 2, 3 };
int offset = iterator.getOffset();
int i = 0;
assertEquals(e_offset[i++], offset);
while (offset != text.length()) {
iterator.next();
offset = iterator.getOffset();
// System.out.println(offset);
assertEquals(e_offset[i++], offset);
}
}
{
Locale locale = new Locale("de", "DE");
RuleBasedCollator coll = (RuleBasedCollator) Collator
.getInstance(locale);
String text = "\u00E6b";
StringCharacterIterator source = new StringCharacterIterator(text);
CollationElementIterator iterator = coll
.getCollationElementIterator(source);
int[] e_offset = { 0, 1, 1, 2 };
int offset = iterator.getOffset();
int i = 0;
assertEquals(e_offset[i++], offset);
while (offset != text.length()) {
iterator.next();
offset = iterator.getOffset();
assertEquals(e_offset[i++], offset);
}
}
//Regression for HARMONY-1352
try {
new RuleBasedCollator("< a< b< c< d").getCollationElementIterator((CharacterIterator)null);
fail("NullPointerException expected");
} catch (NullPointerException e) {
//expected
}
}