use of android.icu.text.UnicodeSetIterator in project j2objc by google.
the class UnicodeSetTest method TestIteration.
@Test
public void TestIteration() {
UnicodeSet us1 = new UnicodeSet("[abcM{xy}]");
assertEquals("", "M, a-c", CollectionUtilities.join(us1.ranges(), ", "));
// Sample code
for (@SuppressWarnings("unused") EntryRange range : us1.ranges()) {
// do something with code points between range.codepointEnd and range.codepointEnd;
}
for (@SuppressWarnings("unused") String s : us1.strings()) {
// do something with each string;
}
String[] tests = { "[M-Qzab{XY}{ZW}]", "[]", "[a]", "[a-c]", "[{XY}]" };
for (String test : tests) {
UnicodeSet us = new UnicodeSet(test);
UnicodeSetIterator it = new UnicodeSetIterator(us);
for (EntryRange range : us.ranges()) {
final String title = range.toString();
logln(title);
it.nextRange();
assertEquals(title, it.codepoint, range.codepoint);
assertEquals(title, it.codepointEnd, range.codepointEnd);
}
for (String s : us.strings()) {
it.nextRange();
assertEquals("strings", it.string, s);
}
assertFalse("", it.next());
}
}
Aggregations