use of android.icu.text.UnicodeFilter in project j2objc by google.
the class TransliteratorTest method checkRegistry.
private void checkRegistry(String id) {
Transliterator fie = Transliterator.getInstance(id);
final UnicodeSet fae = new UnicodeSet("[a-z5]");
fie.setFilter(fae);
Transliterator foe = Transliterator.getInstance(id);
UnicodeFilter fee = foe.getFilter();
if (fae.equals(fee)) {
errln("Changed what is in registry for " + id);
}
}
use of android.icu.text.UnicodeFilter in project j2objc by google.
the class TransliteratorTest method TestFiltering.
/**
* Do some basic tests of filtering.
*/
@Test
public void TestFiltering() {
Transliterator tempTrans = Transliterator.createFromRules("temp", "x > y; x{a} > b; ", Transliterator.FORWARD);
tempTrans.setFilter(new UnicodeSet("[a]"));
String tempResult = tempTrans.transform("xa");
assertEquals("context should not be filtered ", "xb", tempResult);
tempTrans = Transliterator.createFromRules("temp", "::[a]; x > y; x{a} > b; ", Transliterator.FORWARD);
tempResult = tempTrans.transform("xa");
assertEquals("context should not be filtered ", "xb", tempResult);
Transliterator hex = Transliterator.getInstance("Any-Hex");
hex.setFilter(new UnicodeFilter() {
public boolean contains(int c) {
return c != 'c';
}
public String toPattern(boolean escapeUnprintable) {
return "";
}
public boolean matchesIndexValue(int v) {
return false;
}
public void addMatchSetTo(UnicodeSet toUnionTo) {
}
});
String s = "abcde";
String out = hex.transliterate(s);
String exp = "\\u0061\\u0062c\\u0064\\u0065";
if (out.equals(exp)) {
logln("Ok: \"" + exp + "\"");
} else {
logln("FAIL: \"" + out + "\", wanted \"" + exp + "\"");
}
}
Aggregations