Search in sources :

Example 26 with CollationElementIterator

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

the class CollationThaiTest method TestInvalidThai.

@Test
public void TestInvalidThai() {
    String[] tests = { "\u0E44\u0E01\u0E44\u0E01", "\u0E44\u0E01\u0E01\u0E44", "\u0E01\u0E44\u0E01\u0E44", "\u0E01\u0E01\u0E44\u0E44", "\u0E44\u0E44\u0E01\u0E01", "\u0E01\u0E44\u0E44\u0E01" };
    RuleBasedCollator collator;
    StrCmp comparator;
    try {
        collator = getThaiCollator();
        comparator = new StrCmp();
    } catch (Exception e) {
        warnln("could not construct Thai collator");
        return;
    }
    Arrays.sort(tests, comparator);
    for (int i = 0; i < tests.length; i++) {
        for (int j = i + 1; j < tests.length; j++) {
            if (collator.compare(tests[i], tests[j]) > 0) {
                // inconsistency ordering found!
                errln("Inconsistent ordering between strings " + i + " and " + j);
            }
        }
        CollationElementIterator iterator = collator.getCollationElementIterator(tests[i]);
        CollationTest.backAndForth(this, iterator);
    }
}
Also used : RuleBasedCollator(android.icu.text.RuleBasedCollator) CollationElementIterator(android.icu.text.CollationElementIterator) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

CollationElementIterator (android.icu.text.CollationElementIterator)26 RuleBasedCollator (android.icu.text.RuleBasedCollator)25 Test (org.junit.Test)25 ULocale (android.icu.util.ULocale)4 Collator (android.icu.text.Collator)3 Locale (java.util.Locale)3 CollationKey (android.icu.text.CollationKey)2 RawCollationKey (android.icu.text.RawCollationKey)2 UCharacterIterator (android.icu.text.UCharacterIterator)2 CharacterIterator (java.text.CharacterIterator)2 StringCharacterIterator (java.text.StringCharacterIterator)2 IOException (java.io.IOException)1 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 MissingResourceException (java.util.MissingResourceException)1