use of android.icu.text.Normalizer2 in project j2objc by google.
the class BasicTest method TestFCD.
@Test
public void TestFCD() {
// Coverage tests.
Normalizer2 fcd = Normalizer2.getInstance(null, "nfc", Normalizer2.Mode.FCD);
assertTrue("fcd.hasBoundaryAfter(space)", fcd.hasBoundaryAfter(' '));
assertFalse("fcd.hasBoundaryAfter(ä)", fcd.hasBoundaryAfter('ä'));
assertTrue("fcd.isInert(space)", fcd.isInert(' '));
assertFalse("fcd.isInert(ä)", fcd.isInert('ä'));
// This implementation method is unreachable via public API.
Norm2AllModes.FCDNormalizer2 impl = (Norm2AllModes.FCDNormalizer2) fcd;
assertEquals("fcd impl.getQuickCheck(space)", 1, impl.getQuickCheck(' '));
assertEquals("fcd impl.getQuickCheck(ä)", 0, impl.getQuickCheck('ä'));
}
use of android.icu.text.Normalizer2 in project j2objc by google.
the class BasicTest method TestGetEasyToUseInstance.
@Test
public void TestGetEasyToUseInstance() {
// Test input string:
// U+00A0 -> <noBreak> 0020
// U+00C7 0301 = 1E08 = 0043 0327 0301
String in = "\u00A0\u00C7\u0301";
Normalizer2 n2 = Normalizer2.getNFCInstance();
String out = n2.normalize(in);
assertEquals("getNFCInstance() did not return an NFC instance " + "(normalizes to " + prettify(out) + ')', "\u00A0\u1E08", out);
n2 = Normalizer2.getNFDInstance();
out = n2.normalize(in);
assertEquals("getNFDInstance() did not return an NFD instance " + "(normalizes to " + prettify(out) + ')', "\u00A0C\u0327\u0301", out);
n2 = Normalizer2.getNFKCInstance();
out = n2.normalize(in);
assertEquals("getNFKCInstance() did not return an NFKC instance " + "(normalizes to " + prettify(out) + ')', " \u1E08", out);
n2 = Normalizer2.getNFKDInstance();
out = n2.normalize(in);
assertEquals("getNFKDInstance() did not return an NFKD instance " + "(normalizes to " + prettify(out) + ')', " C\u0327\u0301", out);
n2 = Normalizer2.getNFKCCasefoldInstance();
out = n2.normalize(in);
assertEquals("getNFKCCasefoldInstance() did not return an NFKC_Casefold instance " + "(normalizes to " + prettify(out) + ')', " \u1E09", out);
}
use of android.icu.text.Normalizer2 in project j2objc by google.
the class BasicTest method TestGetDecomposition.
@Test
public void TestGetDecomposition() {
Normalizer2 n2 = Normalizer2.getInstance(null, "nfc", Normalizer2.Mode.COMPOSE_CONTIGUOUS);
String decomp = n2.getDecomposition(0x20);
assertEquals("fcc.getDecomposition(space) failed", null, decomp);
decomp = n2.getDecomposition(0xe4);
assertEquals("fcc.getDecomposition(a-umlaut) failed", "a\u0308", decomp);
decomp = n2.getDecomposition(0xac01);
assertEquals("fcc.getDecomposition(Hangul syllable U+AC01) failed", "\u1100\u1161\u11a8", decomp);
}
use of android.icu.text.Normalizer2 in project j2objc by google.
the class BasicTest method TestGetRawDecomposition.
@Test
public void TestGetRawDecomposition() {
Normalizer2 n2 = Normalizer2.getNFKCInstance();
/*
* Raw decompositions from NFKC data are the Unicode Decomposition_Mapping values,
* without recursive decomposition.
*/
String decomp = n2.getRawDecomposition(0x20);
assertEquals("nfkc.getRawDecomposition(space) failed", null, decomp);
decomp = n2.getRawDecomposition(0xe4);
assertEquals("nfkc.getRawDecomposition(a-umlaut) failed", "a\u0308", decomp);
/* U+1E08 LATIN CAPITAL LETTER C WITH CEDILLA AND ACUTE */
decomp = n2.getRawDecomposition(0x1e08);
assertEquals("nfkc.getRawDecomposition(c-cedilla-acute) failed", "\u00c7\u0301", decomp);
/* U+212B ANGSTROM SIGN */
decomp = n2.getRawDecomposition(0x212b);
assertEquals("nfkc.getRawDecomposition(angstrom sign) failed", "\u00c5", decomp);
decomp = n2.getRawDecomposition(0xac00);
assertEquals("nfkc.getRawDecomposition(Hangul syllable U+AC00) failed", "\u1100\u1161", decomp);
/* A Hangul LVT syllable has a raw decomposition of an LV syllable + T. */
decomp = n2.getRawDecomposition(0xac01);
assertEquals("nfkc.getRawDecomposition(Hangul syllable U+AC01) failed", "\uac00\u11a8", decomp);
}
use of android.icu.text.Normalizer2 in project j2objc by google.
the class BasicTest method TestNoopNormalizer2.
@Test
public void TestNoopNormalizer2() {
// Use the internal class directly for coverage of methods that are not publicly reachable.
Normalizer2 noop = Norm2AllModes.NOOP_NORMALIZER2;
assertEquals("noop.normalizeSecondAndAppend()", "ä\u0327", noop.normalizeSecondAndAppend(new StringBuilder("ä"), "\u0327").toString());
assertEquals("noop.getDecomposition()", null, noop.getDecomposition('ä'));
assertTrue("noop.hasBoundaryAfter()", noop.hasBoundaryAfter(0x0308));
assertTrue("noop.isInert()", noop.isInert(0x0308));
}
Aggregations