Search in sources :

Example 51 with UnicodeSet

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

the class StringTokenizerTest method TestContains_int_int.

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

Example 52 with UnicodeSet

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

the class StringTokenizerTest method TestRetain_int_int.

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

Example 53 with UnicodeSet

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

the class StringTokenizerTest method TestAdd_int.

/* Tests the method
      *     private final UnicodeSet add_unchecked(int c)
      * from public final UnicodeSet add(int c)
      */
@Test
public void TestAdd_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.add(invalid[i]);
            errln("UnicodeSet.add(int c) was suppose to give " + "an exception for an start invalid input of " + invalid[i]);
        } catch (Exception e) {
        }
    }
// Tests when "if (c == MAX_VALUE)" is true
// TODO: Check comment in UnicodeSet.java
}
Also used : UnicodeSet(android.icu.text.UnicodeSet) Test(org.junit.Test)

Example 54 with UnicodeSet

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

the class StringTokenizerTest method TestIndexOf.

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

Example 55 with UnicodeSet

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

the class StringTokenizerTest method TestCharAt.

/* Tests the method
     *      public int charAt(int index)
     */
@Test
public void TestCharAt() {
    UnicodeSet us = new UnicodeSet();
    // Test when "if (index >= 0)" is false
    int[] invalid = { -100, -10, -5, -2, -1 };
    for (int i = 0; i < invalid.length; i++) {
        if (us.charAt(invalid[i]) != -1) {
            errln("UnicodeSet.charAt(int index) was suppose to return -1 " + "for an invalid input of " + invalid[i]);
        }
    }
}
Also used : UnicodeSet(android.icu.text.UnicodeSet) Test(org.junit.Test)

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