use of android.icu.text.Normalizer2 in project j2objc by google.
the class BasicTest method TestCustomComp.
@Test
public void TestCustomComp() {
String[][] pairs = { { "\\uD801\\uE000\\uDFFE", "" }, { "\\uD800\\uD801\\uE000\\uDFFE\\uDFFF", "\\uD7FF\\uFFFF" }, { "\\uD800\\uD801\\uDFFE\\uDFFF", "\\uD7FF\\U000107FE\\uFFFF" }, { "\\uE001\\U000110B9\\u0345\\u0308\\u0327", "\\uE002\\U000110B9\\u0327\\u0345" }, { "\\uE010\\U000F0011\\uE012", "\\uE011\\uE012" }, { "\\uE010\\U000F0011\\U000F0011\\uE012", "\\uE011\\U000F0010" }, { "\\uE111\\u1161\\uE112\\u1162", "\\uAE4C\\u1102\\u0062\\u1162" }, { "\\uFFF3\\uFFF7\\U00010036\\U00010077", "\\U00010037\\U00010037\\uFFF6\\U00010037" } };
Normalizer2 customNorm2;
customNorm2 = Normalizer2.getInstance(BasicTest.class.getResourceAsStream("/android/icu/dev/data/testdata/testnorm.nrm"), "testnorm", Normalizer2.Mode.COMPOSE);
for (int i = 0; i < pairs.length; ++i) {
String[] pair = pairs[i];
String input = Utility.unescape(pair[0]);
String expected = Utility.unescape(pair[1]);
String result = customNorm2.normalize(input);
if (!result.equals(expected)) {
errln("custom compose Normalizer2 did not normalize input " + i + " as expected");
}
}
}
use of android.icu.text.Normalizer2 in project j2objc by google.
the class BasicTest method TestNFC.
@Test
public void TestNFC() {
// Coverage tests.
Normalizer2 nfc = Normalizer2.getNFCInstance();
assertTrue("nfc.hasBoundaryAfter(space)", nfc.hasBoundaryAfter(' '));
assertFalse("nfc.hasBoundaryAfter(ä)", nfc.hasBoundaryAfter('ä'));
}
use of android.icu.text.Normalizer2 in project j2objc by google.
the class BasicTest method TestFilteredNormalizer2.
@Test
public void TestFilteredNormalizer2() {
Normalizer2 nfcNorm2 = Normalizer2.getNFCInstance();
UnicodeSet filter = new UnicodeSet("[^\u00a0-\u00ff\u0310-\u031f]");
FilteredNormalizer2 fn2 = new FilteredNormalizer2(nfcNorm2, filter);
int c;
for (c = 0; c <= 0x3ff; ++c) {
int expectedCC = filter.contains(c) ? nfcNorm2.getCombiningClass(c) : 0;
int cc = fn2.getCombiningClass(c);
assertEquals("FilteredNormalizer2(NFC, ^A0-FF,310-31F).getCombiningClass(U+" + hex(c) + ")==filtered NFC.getCC()", expectedCC, cc);
}
// More coverage.
StringBuilder sb = new StringBuilder();
assertEquals("filtered normalize()", "ää\u0304", fn2.normalize("a\u0308ä\u0304", (Appendable) sb).toString());
assertTrue("filtered hasBoundaryAfter()", fn2.hasBoundaryAfter('ä'));
assertTrue("filtered isInert()", fn2.isInert(0x0313));
}
use of android.icu.text.Normalizer2 in project j2objc by google.
the class BasicTest method TestCustomFCC.
@Test
public void TestCustomFCC() {
String[][] pairs = { { "\\uD801\\uE000\\uDFFE", "" }, { "\\uD800\\uD801\\uE000\\uDFFE\\uDFFF", "\\uD7FF\\uFFFF" }, { "\\uD800\\uD801\\uDFFE\\uDFFF", "\\uD7FF\\U000107FE\\uFFFF" }, // because of only-contiguous composition.
{ "\\uE001\\U000110B9\\u0345\\u0308\\u0327", "\\uE001\\U000110B9\\u0327\\u0308\\u0345" }, { "\\uE010\\U000F0011\\uE012", "\\uE011\\uE012" }, { "\\uE010\\U000F0011\\U000F0011\\uE012", "\\uE011\\U000F0010" }, { "\\uE111\\u1161\\uE112\\u1162", "\\uAE4C\\u1102\\u0062\\u1162" }, { "\\uFFF3\\uFFF7\\U00010036\\U00010077", "\\U00010037\\U00010037\\uFFF6\\U00010037" } };
Normalizer2 customNorm2;
customNorm2 = Normalizer2.getInstance(BasicTest.class.getResourceAsStream("/android/icu/dev/data/testdata/testnorm.nrm"), "testnorm", Normalizer2.Mode.COMPOSE_CONTIGUOUS);
for (int i = 0; i < pairs.length; ++i) {
String[] pair = pairs[i];
String input = Utility.unescape(pair[0]);
String expected = Utility.unescape(pair[1]);
String result = customNorm2.normalize(input);
if (!result.equals(expected)) {
errln("custom FCC Normalizer2 did not normalize input " + i + " as expected");
}
}
}
use of android.icu.text.Normalizer2 in project j2objc by google.
the class BasicTest method TestNFD.
@Test
public void TestNFD() {
// Coverage tests.
Normalizer2 nfd = Normalizer2.getNFDInstance();
assertTrue("nfd.hasBoundaryAfter(space)", nfd.hasBoundaryAfter(' '));
assertFalse("nfd.hasBoundaryAfter(ä)", nfd.hasBoundaryAfter('ä'));
}
Aggregations