use of android.icu.text.RuleBasedCollator in project j2objc by google.
the class CollationRegressionTest method Test4244884.
@Test
public void Test4244884() throws Exception {
RuleBasedCollator coll = (RuleBasedCollator) Collator.getInstance(Locale.US);
coll = new RuleBasedCollator(coll.getRules() + " & C < ch , cH , Ch , CH < cat < crunchy");
String[] testStrings = new String[] { "car", "cave", "clamp", "cramp", "czar", "church", "catalogue", "crunchy", "dog" };
for (int i = 1; i < testStrings.length; i++) {
if (coll.compare(testStrings[i - 1], testStrings[i]) >= 0) {
errln("error: \"" + testStrings[i - 1] + "\" is greater than or equal to \"" + testStrings[i] + "\".");
}
}
}
use of android.icu.text.RuleBasedCollator in project j2objc by google.
the class CollationRegressionTest method Test4663220.
// CollationElementIterator set doesn't work propertly with next/prev
@Test
public void Test4663220() {
RuleBasedCollator collator = (RuleBasedCollator) Collator.getInstance(Locale.US);
java.text.StringCharacterIterator stringIter = new java.text.StringCharacterIterator("fox");
CollationElementIterator iter = collator.getCollationElementIterator(stringIter);
int[] elements_next = new int[3];
logln("calling next:");
for (int i = 0; i < 3; ++i) {
logln("[" + i + "] " + (elements_next[i] = iter.next()));
}
int[] elements_fwd = new int[3];
logln("calling set/next:");
for (int i = 0; i < 3; ++i) {
iter.setOffset(i);
logln("[" + i + "] " + (elements_fwd[i] = iter.next()));
}
for (int i = 0; i < 3; ++i) {
if (elements_next[i] != elements_fwd[i]) {
errln("mismatch at position " + i + ": " + elements_next[i] + " != " + elements_fwd[i]);
}
}
}
use of android.icu.text.RuleBasedCollator in project j2objc by google.
the class CollationRegressionTest method Test4087243.
// @bug 4087243
//
// CollationKey takes ignorable strings into account when it shouldn't
//
@Test
public void Test4087243() /* char* par */
{
RuleBasedCollator c = (RuleBasedCollator) Collator.getInstance(Locale.US);
c.setStrength(Collator.TERTIARY);
String[] tests = { // 1 2 3 = 1 2 3 ctrl-A
"\u0031\u0032\u0033", // 1 2 3 = 1 2 3 ctrl-A
"\u003d", // 1 2 3 = 1 2 3 ctrl-A
"\u0031\u0032\u0033\u0001" };
compareArray(c, tests);
}
use of android.icu.text.RuleBasedCollator in project j2objc by google.
the class CollationRegressionTest method Test4062418.
// @bug 4062418
//
// Secondary/Tertiary comparison incorrect in French Secondary
//
@Test
public void Test4062418() /* char* par */
{
RuleBasedCollator c = null;
try {
c = (RuleBasedCollator) Collator.getInstance(Locale.CANADA_FRENCH);
} catch (Exception e) {
errln("Failed to create collator for Locale.CANADA_FRENCH");
return;
}
c.setStrength(Collator.SECONDARY);
String[] tests = { // Comparing accents from end, p\u00e9ch\u00e9 is greater
"p\u00eache", // Comparing accents from end, p\u00e9ch\u00e9 is greater
"<", // Comparing accents from end, p\u00e9ch\u00e9 is greater
"p\u00e9ch\u00e9" };
compareArray(c, tests);
}
use of android.icu.text.RuleBasedCollator in project j2objc by google.
the class CollationRegressionTest method Test4076676.
// @bug 4076676
//
// Bad canonicalization of same-class combining characters
//
@Test
public void Test4076676() /* char* par */
{
// These combining characters are all in the same class, so they should not
// be reordered, and they should compare as unequal.
final String s1 = "\u0041\u0301\u0302\u0300";
final String s2 = "\u0041\u0302\u0300\u0301";
RuleBasedCollator c = (RuleBasedCollator) Collator.getInstance(Locale.US);
c.setStrength(Collator.TERTIARY);
if (c.compare(s1, s2) == 0) {
errln("Same-class combining chars were reordered");
}
}
Aggregations