Search in sources :

Example 1 with StringCharacterIterator

use of android.icu.text.StringCharacterIterator in project j2objc by google.

the class TestDeprecatedNormalizerAPI method TestNormalizerAPI.

@Test
public void TestNormalizerAPI() {
    // instantiate a Normalizer from a CharacterIterator
    String s = Utility.unescape("a\u0308\uac00\\U0002f800");
    // make s a bit longer and more interesting
    java.text.CharacterIterator iter = new StringCharacterIterator(s + s);
    // test deprecated constructors
    Normalizer norm = new Normalizer(iter, Normalizer.NFC, 0);
    if (norm.next() != 0xe4) {
        errln("error in Normalizer(CharacterIterator).next()");
    }
    Normalizer norm2 = new Normalizer(s, Normalizer.NFC, 0);
    if (norm2.next() != 0xe4) {
        errln("error in Normalizer(CharacterIterator).next()");
    }
    // test clone(), ==, and hashCode()
    Normalizer clone = (Normalizer) norm.clone();
    if (clone.getBeginIndex() != norm.getBeginIndex()) {
        errln("error in Normalizer.getBeginIndex()");
    }
    if (clone.getEndIndex() != norm.getEndIndex()) {
        errln("error in Normalizer.getEndIndex()");
    }
    // test setOption() and getOption()
    clone.setOption(0xaa0000, true);
    clone.setOption(0x20000, false);
    if (clone.getOption(0x880000) == 0 || clone.getOption(0x20000) == 1) {
        errln("error in Normalizer::setOption() or Normalizer::getOption()");
    }
    // test deprecated normalize method
    Normalizer.normalize(s, Normalizer.NFC, 0);
    // test deprecated compose method
    Normalizer.compose(s, false, 0);
    // test deprecated decompose method
    Normalizer.decompose(s, false, 0);
}
Also used : StringCharacterIterator(android.icu.text.StringCharacterIterator) Normalizer(android.icu.text.Normalizer) Test(org.junit.Test)

Aggregations

Normalizer (android.icu.text.Normalizer)1 StringCharacterIterator (android.icu.text.StringCharacterIterator)1 Test (org.junit.Test)1