use of android.icu.text.CollationKey in project j2objc by google.
the class LotusCollationKoreanTest method doTest.
// main test routine, tests rules specific to "Korean" locale
private void doTest(char[] source, char[] target, int result) {
String s = new String(source);
String t = new String(target);
int compareResult = myCollation.compare(s, t);
CollationKey sortKey1, sortKey2;
sortKey1 = myCollation.getCollationKey(s);
sortKey2 = myCollation.getCollationKey(t);
int keyResult = sortKey1.compareTo(sortKey2);
reportCResult(s, t, sortKey1, sortKey2, compareResult, keyResult, compareResult, result);
}
use of android.icu.text.CollationKey in project j2objc by google.
the class CollationRegressionTest method printKey.
private static StringBuilder printKey(Collator col, String str1) {
StringBuilder sb = new StringBuilder();
CollationKey sortk1 = col.getCollationKey(str1);
byte[] bytes = sortk1.toByteArray();
for (int i = 0; i < str1.length(); i++) {
sb.append("\\u" + Integer.toHexString(str1.charAt(i)));
}
System.out.print(": ");
for (int i = 0; i < bytes.length; i++) {
sb.append(" 0x" + Integer.toHexString(((int) bytes[i]) & 0xff));
}
sb.append("\n");
return sb;
}
use of android.icu.text.CollationKey in project j2objc by google.
the class CollationRegressionTest method Test4124632.
// @bug 4124632
//
// Collator::getCollationKey was hanging on certain character sequences
//
@Test
public void Test4124632() /* char* par */
{
Collator coll = null;
try {
coll = Collator.getInstance(Locale.JAPAN);
} catch (Exception e) {
errln("Failed to create collator for Locale::JAPAN");
return;
}
String test = "\u0041\u0308\u0062\u0063";
CollationKey key;
try {
key = coll.getCollationKey(test);
logln(key.getSourceString());
} catch (Exception e) {
errln("CollationKey creation failed.");
}
}
use of android.icu.text.CollationKey in project j2objc by google.
the class CollationRegressionTest method caseFirstCompressionSub.
/*
* Compare two strings - "aaa...A" and "aaa...a" with
* Collation#compare and CollationKey#compareTo, called from
* TestCaseFirstCompression.
*/
private void caseFirstCompressionSub(RuleBasedCollator col, String opt) {
final int maxLength = 50;
StringBuilder buf1 = new StringBuilder();
StringBuilder buf2 = new StringBuilder();
String str1, str2;
for (int n = 1; n <= maxLength; n++) {
buf1.setLength(0);
buf2.setLength(0);
for (int i = 0; i < n - 1; i++) {
buf1.append('a');
buf2.append('a');
}
buf1.append('A');
buf2.append('a');
str1 = buf1.toString();
str2 = buf2.toString();
CollationKey key1 = col.getCollationKey(str1);
CollationKey key2 = col.getCollationKey(str2);
int cmpKey = key1.compareTo(key2);
int cmpCol = col.compare(str1, str2);
if ((cmpKey < 0 && cmpCol >= 0) || (cmpKey > 0 && cmpCol <= 0) || (cmpKey == 0 && cmpCol != 0)) {
errln("Inconsistent comparison(" + opt + "): str1=" + str1 + ", str2=" + str2 + ", cmpKey=" + cmpKey + " , cmpCol=" + cmpCol);
}
}
}
use of android.icu.text.CollationKey in project j2objc by google.
the class G7CollationTest method doTest.
// main test routine, tests comparisons for a set of strings against sets of expected results
private void doTest(Collator myCollation, String source, String target, int result) {
int compareResult = myCollation.compare(source, target);
CollationKey sortKey1, sortKey2;
sortKey1 = myCollation.getCollationKey(source);
sortKey2 = myCollation.getCollationKey(target);
int keyResult = sortKey1.compareTo(sortKey2);
reportCResult(source, target, sortKey1, sortKey2, compareResult, keyResult, compareResult, result);
}
Aggregations