use of android.icu.text.Transliterator in project j2objc by google.
the class TransliteratorTest method CheckIncrementalAux.
public void CheckIncrementalAux(Transliterator t, String input) {
Replaceable test = new ReplaceableString(input);
Transliterator.Position pos = new Transliterator.Position(0, test.length(), 0, test.length());
t.transliterate(test, pos);
boolean gotError = false;
if (pos.start == 0 && pos.limit != 0 && !t.getID().equals("Hex-Any/Unicode")) {
errln("No Progress, " + t.getID() + ": " + UtilityExtensions.formatInput(test, pos));
gotError = true;
} else {
logln("PASS Progress, " + t.getID() + ": " + UtilityExtensions.formatInput(test, pos));
}
t.finishTransliteration(test, pos);
if (pos.start != pos.limit) {
errln("Incomplete, " + t.getID() + ": " + UtilityExtensions.formatInput(test, pos));
gotError = true;
}
if (!gotError) {
// errln("FAIL: Did not get expected error");
}
}
use of android.icu.text.Transliterator in project j2objc by google.
the class TransliteratorTest method TestKeyboard3.
/**
* Test keyboard transliteration with back-replacement.
*/
@Test
public void TestKeyboard3() {
// We want th>z but t>y. Furthermore, during keyboard
// transliteration we want t>y then yh>z if t, then h are
// typed.
String RULES = "t>|y;" + "yh>z;" + "";
String[] DATA = { // keyboard xliteration.
"a", "a", "b", "ab", // modified for rollback - "aby",
"t", // modified for rollback - "aby",
"abt", "c", "abyc", // modified for rollback - "abycy",
"t", // modified for rollback - "abycy",
"abyct", "h", "abycz", // null means finishKeyboardTransliteration
null, // null means finishKeyboardTransliteration
"abycz" };
Transliterator t = Transliterator.createFromRules("<ID>", RULES, Transliterator.FORWARD);
keyboardAux(t, DATA);
}
use of android.icu.text.Transliterator in project j2objc by google.
the class TransliteratorTest method TestSegments.
/**
* Test segments and segment references.
*/
@Test
public void TestSegments() {
// Array of 3n items
// Each item is <rules>, <input>, <expected output>
String[] DATA = { "([a-z]) '.' ([0-9]) > $2 '-' $1", "abc.123.xyz.456", "ab1-c23.xy4-z56" };
for (int i = 0; i < DATA.length; i += 3) {
logln("Pattern: " + Utility.escape(DATA[i]));
Transliterator t = Transliterator.createFromRules("<ID>", DATA[i], Transliterator.FORWARD);
expect(t, DATA[i + 1], DATA[i + 2]);
}
}
use of android.icu.text.Transliterator in project j2objc by google.
the class TransliteratorTest method TestCursorOffset.
/**
* Test cursor positioning outside of the key
*/
@Test
public void TestCursorOffset() {
// Array of 3n items
// Each item is <rules>, <input>, <expected output>
String[] DATA = { "pre {alpha} post > | @ ALPHA ;" + "eALPHA > beta ;" + "pre {beta} post > BETA @@ | ;" + "post > xyz", "prealphapost prebetapost", "prbetaxyz preBETApost" };
for (int i = 0; i < DATA.length; i += 3) {
logln("Pattern: " + Utility.escape(DATA[i]));
Transliterator t = Transliterator.createFromRules("<ID>", DATA[i], Transliterator.FORWARD);
expect(t, DATA[i + 1], DATA[i + 2]);
}
}
use of android.icu.text.Transliterator in project j2objc by google.
the class TransliteratorTest method TestMulticharStringSet.
@Test
public void TestMulticharStringSet() {
// Basic testing
String rule = " [{aa}] > x;" + " a > y;" + " [b{bc}] > z;" + "[{gd}] { e > q;" + " e } [{fg}] > r;";
Transliterator t = Transliterator.createFromRules("Test", rule, Transliterator.FORWARD);
if (t == null) {
errln("FAIL: createFromRules failed");
return;
}
expect(t, "a aa ab bc d gd de gde gdefg ddefg", "y x yz z d gd de gdq gdqfg ddrfg");
// Overlapped string test. Make sure that when multiple
// strings can match that the longest one is matched.
rule = " [a {ab} {abc}] > x;" + " b > y;" + " c > z;" + " q [t {st} {rst}] { e > p;";
t = Transliterator.createFromRules("Test", rule, Transliterator.FORWARD);
if (t == null) {
errln("FAIL: createFromRules failed");
return;
}
expect(t, "a ab abc qte qste qrste", "x x x qtp qstp qrstp");
}
Aggregations