Search in sources :

Example 56 with UnicodeSet

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

the class StringTokenizerTest method TestRemove.

/* Tests the method
       *     public UnicodeSet remove(int start, int end)
       */
@Test
public void TestRemove() {
    UnicodeSet us = new UnicodeSet();
    int[] invalid = { UnicodeSet.MIN_VALUE - 1, UnicodeSet.MIN_VALUE - 2, UnicodeSet.MAX_VALUE + 1, UnicodeSet.MAX_VALUE + 2 };
    // Tests when "if (start < MIN_VALUE || start > MAX_VALUE)" is true
    for (int i = 0; i < invalid.length; i++) {
        try {
            us.remove(invalid[i], UnicodeSet.MAX_VALUE);
            errln("UnicodeSet.remove(int start, int end) was suppose to give " + "an exception for an start invalid input of " + invalid[i]);
        } catch (Exception e) {
        }
    }
    // Tests when "if (end < MIN_VALUE || end > MAX_VALUE)" is true
    for (int i = 0; i < invalid.length; i++) {
        try {
            us.remove(UnicodeSet.MIN_VALUE, invalid[i]);
            errln("UnicodeSet.remove(int start, int end) was suppose to give " + "an exception for an end invalid input of " + invalid[i]);
        } catch (Exception e) {
        }
    }
    // Tests when "if (start <= end)" is false
    try {
        us.remove(UnicodeSet.MIN_VALUE + 1, UnicodeSet.MIN_VALUE);
    } catch (Exception e) {
        errln("UnicodeSet.remove(int start, int end) was not suppose to give " + "an exception.");
    }
    try {
        us.remove(UnicodeSet.MAX_VALUE, UnicodeSet.MAX_VALUE - 1);
    } catch (Exception e) {
        errln("UnicodeSet.remove(int start, int end) was not suppose to give " + "an exception.");
    }
}
Also used : UnicodeSet(android.icu.text.UnicodeSet) Test(org.junit.Test)

Example 57 with UnicodeSet

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

the class StringTokenizerTest method TestContains_int.

/* Tests the method
         *      public boolean contains(int c)
         */
@Test
public void TestContains_int() {
    UnicodeSet us = new UnicodeSet();
    int[] invalid = { UnicodeSet.MIN_VALUE - 1, UnicodeSet.MIN_VALUE - 2, UnicodeSet.MAX_VALUE + 1, UnicodeSet.MAX_VALUE + 2 };
    // Tests when "if (c < MIN_VALUE || c > MAX_VALUE)" is true
    for (int i = 0; i < invalid.length; i++) {
        try {
            us.contains(invalid[i]);
            errln("UnicodeSet.contains(int c) was suppose to give " + "an exception for an start invalid input of " + invalid[i]);
        } catch (Exception e) {
        }
    }
}
Also used : UnicodeSet(android.icu.text.UnicodeSet) Test(org.junit.Test)

Example 58 with UnicodeSet

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

the class UtilityTest method TestUnicodeSet.

@Test
public void TestUnicodeSet() {
    String[] array = new String[] { "a", "b", "c", "{de}" };
    List list = Arrays.asList(array);
    Set aset = new HashSet(list);
    logln(" *** The source set's size is: " + aset.size());
    // The size reads 4
    UnicodeSet set = new UnicodeSet();
    set.clear();
    set.addAll(aset);
    logln(" *** After addAll, the UnicodeSet size is: " + set.size());
// The size should also read 4, but 0 is seen instead
}
Also used : HashSet(java.util.HashSet) UnicodeSet(android.icu.text.UnicodeSet) Set(java.util.Set) List(java.util.List) CaseInsensitiveString(android.icu.util.CaseInsensitiveString) UnicodeSet(android.icu.text.UnicodeSet) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 59 with UnicodeSet

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

the class UnicodeMap method composeWith.

public UnicodeMap<T> composeWith(UnicodeMap<T> other, Composer<T> composer) {
    for (T value : other.getAvailableValues()) {
        UnicodeSet set = other.keySet(value);
        composeWith(set, value, composer);
    }
    return this;
}
Also used : UnicodeSet(android.icu.text.UnicodeSet)

Example 60 with UnicodeSet

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

the class UnicodeMap method toString.

public String toString(Comparator<T> collected) {
    StringBuffer result = new StringBuffer();
    if (collected == null) {
        for (int i = 0; i < length - 1; ++i) {
            T value = values[i];
            if (value == null)
                continue;
            int start = transitions[i];
            int end = transitions[i + 1] - 1;
            result.append(Utility.hex(start));
            if (start != end)
                result.append("-").append(Utility.hex(end));
            result.append("=").append(value.toString()).append("\n");
        }
        if (stringMap != null) {
            for (String s : stringMap.keySet()) {
                result.append(Utility.hex(s)).append("=").append(stringMap.get(s).toString()).append("\n");
            }
        }
    } else {
        Set<T> set = values(new TreeSet<T>(collected));
        for (Iterator<T> it = set.iterator(); it.hasNext(); ) {
            T value = it.next();
            UnicodeSet s = keySet(value);
            result.append(value).append("=").append(s.toString()).append("\n");
        }
    }
    return result.toString();
}
Also used : UnicodeSet(android.icu.text.UnicodeSet)

Aggregations

UnicodeSet (android.icu.text.UnicodeSet)158 Test (org.junit.Test)112 UnicodeSetIterator (android.icu.text.UnicodeSetIterator)25 Transliterator (android.icu.text.Transliterator)19 ReplaceableString (android.icu.text.ReplaceableString)14 ULocale (android.icu.util.ULocale)13 CaseInsensitiveString (android.icu.util.CaseInsensitiveString)9 Normalizer2 (android.icu.text.Normalizer2)7 RuleBasedCollator (android.icu.text.RuleBasedCollator)7 ArrayList (java.util.ArrayList)5 HashSet (java.util.HashSet)5 FilteredNormalizer2 (android.icu.text.FilteredNormalizer2)4 SpoofChecker (android.icu.text.SpoofChecker)4 TreeSet (java.util.TreeSet)4 UnicodeMap (android.icu.dev.util.UnicodeMap)3 AlphabeticIndex (android.icu.text.AlphabeticIndex)3 CollationKey (android.icu.text.CollationKey)3 RawCollationKey (android.icu.text.RawCollationKey)3 CheckResult (android.icu.text.SpoofChecker.CheckResult)3 SpanCondition (android.icu.text.UnicodeSet.SpanCondition)3