ICU-13242 modifes collation test to work with an upper-case-first locale (da).
X-SVN-Rev: 40178
This commit is contained in:
parent
64cb86e425
commit
29454f8167
@ -19,7 +19,6 @@ import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.icu.dev.test.TestFmwk;
|
||||
@ -1198,17 +1197,15 @@ public class CollationMiscTest extends TestFmwk {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(junit): not running before
|
||||
@Ignore
|
||||
@Test
|
||||
public void DontTestJ831() { // Latvian does not use upper first
|
||||
public void TestUpperCaseFirst() {
|
||||
String[] data = {
|
||||
"I",
|
||||
"i",
|
||||
"Y",
|
||||
"y"
|
||||
};
|
||||
genericLocaleStarter(new Locale("lv", ""), data);
|
||||
genericLocaleStarter(new Locale("da", ""), data);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -2045,7 +2042,7 @@ public class CollationMiscTest extends TestFmwk {
|
||||
"\u0663\u0662",
|
||||
"\u0663\u0663"
|
||||
};
|
||||
|
||||
|
||||
//Additional tests to cover bug reported in #9476
|
||||
String lastDigitDifferent[]={"2004","2005",
|
||||
"110005", "110006",
|
||||
@ -2078,13 +2075,13 @@ public class CollationMiscTest extends TestFmwk {
|
||||
preZeroTestStrings[j],0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Testing that the behavior reported in #9476 is fixed
|
||||
//We expect comparisons between adjacent pairs will result in -1
|
||||
for (int i=0; i < lastDigitDifferent.length -1; i=i+2 ) {
|
||||
CollationTest.doTest(this, coll, lastDigitDifferent[i], lastDigitDifferent[i+1], -1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//cover setNumericCollationDefault, getNumericCollation
|
||||
assertTrue("The Numeric Collation setting is on", coll.getNumericCollation());
|
||||
@ -2705,7 +2702,7 @@ public class CollationMiscTest extends TestFmwk {
|
||||
};
|
||||
doTestCollation(m_rangeTestCases_, rules);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void TestSameStrengthListQuoted() {
|
||||
String[] rules = new String[] {
|
||||
@ -2815,22 +2812,22 @@ public class CollationMiscTest extends TestFmwk {
|
||||
};
|
||||
doTestCollation(testCases, rules);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void TestInvalidListsAndRanges() {
|
||||
String[] invalidRules = new String[] {
|
||||
// Range not in starred expression
|
||||
"&\u4e00<\ufffb-'\ud800\udc02'",
|
||||
|
||||
|
||||
// Range without start
|
||||
"&a<*-c",
|
||||
|
||||
|
||||
// Range without end
|
||||
"&a<*b-",
|
||||
|
||||
|
||||
// More than one hyphen
|
||||
"&a<*b-g-l",
|
||||
|
||||
|
||||
// Range in the wrong order
|
||||
"&a<*k-b",
|
||||
};
|
||||
@ -2842,7 +2839,7 @@ public class CollationMiscTest extends TestFmwk {
|
||||
"x",
|
||||
"y",
|
||||
-1);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
continue;
|
||||
}
|
||||
@ -2858,7 +2855,7 @@ public class CollationMiscTest extends TestFmwk {
|
||||
// These are working as expected.
|
||||
"&';'<'+'<','<'-'<'&'<''<'*'<' '",
|
||||
|
||||
// List. Desired rule is
|
||||
// List. Desired rule is
|
||||
// "&';'<*'+,-&''* '",
|
||||
// but it doesn't work. Instead, '' should be outside quotes as below.
|
||||
"&';'<*'+,-&''''* '",
|
||||
@ -2870,7 +2867,7 @@ public class CollationMiscTest extends TestFmwk {
|
||||
//"&';'<*'+'-'-&'\\u0027'* '",
|
||||
|
||||
// The following rules are not working.
|
||||
// "&';'<'+'<','<'-'<'&'<\\u0027<'*'<' '",
|
||||
// "&';'<'+'<','<'-'<'&'<\\u0027<'*'<' '",
|
||||
//"&'\u003b'<'\u002b'<'\u002c'<'\u002d'<'\u0026'<'\u0027'<\u002a'<'\u0020'",
|
||||
//"&'\u003b'<'\u002b'<'\u002c'<'\u002d'<'\u0026'<\\u0027<\u002a'<'\u0020'",
|
||||
};
|
||||
@ -3125,11 +3122,11 @@ public class CollationMiscTest extends TestFmwk {
|
||||
String rules = "&[before 1]\u03b1 < \u0e01";
|
||||
int[] reorderCodes = {UScript.GREEK};
|
||||
int result;
|
||||
|
||||
|
||||
Collator myCollation = new RuleBasedCollator(rules);
|
||||
myCollation.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
|
||||
myCollation.setStrength(Collator.TERTIARY);
|
||||
|
||||
|
||||
String base = "\u03b1"; /* base */
|
||||
String before = "\u0e01"; /* ko kai */
|
||||
|
||||
@ -3145,7 +3142,7 @@ public class CollationMiscTest extends TestFmwk {
|
||||
byte[] baseKeyBytes = baseKey.toByteArray();
|
||||
byte[] beforeKeyBytes = beforeKey.toByteArray();
|
||||
if (baseKeyBytes[0] != beforeKeyBytes[0]) {
|
||||
errln("Different lead byte for sort keys using before rule and before script reordering. base character lead byte = "
|
||||
errln("Different lead byte for sort keys using before rule and before script reordering. base character lead byte = "
|
||||
+ baseKeyBytes[0] + ", before character lead byte = " + beforeKeyBytes[0]);
|
||||
}
|
||||
|
||||
@ -3157,14 +3154,14 @@ public class CollationMiscTest extends TestFmwk {
|
||||
if (!(result > 0)) {
|
||||
errln("Collation result not correct after script reordering.");
|
||||
}
|
||||
|
||||
|
||||
/* check the lead byte of the collation keys after script reordering */
|
||||
baseKey = myCollation.getCollationKey(base);
|
||||
beforeKey = myCollation.getCollationKey(before);
|
||||
baseKeyBytes = baseKey.toByteArray();
|
||||
beforeKeyBytes = beforeKey.toByteArray();
|
||||
if (baseKeyBytes[0] != beforeKeyBytes[0]) {
|
||||
errln("Different lead byte for sort keys using before rule and before script reordering. base character lead byte = "
|
||||
errln("Different lead byte for sort keys using before rule and before script reordering. base character lead byte = "
|
||||
+ baseKeyBytes[0] + ", before character lead byte = " + beforeKeyBytes[0]);
|
||||
}
|
||||
}
|
||||
@ -3188,16 +3185,16 @@ public class CollationMiscTest extends TestFmwk {
|
||||
|
||||
myCollation.setReorderCodes(reorderCodes);
|
||||
reorderKey = myCollation.getCollationKey(testString).toByteArray();
|
||||
|
||||
|
||||
if (baseKey.length != reorderKey.length) {
|
||||
errln("Key lengths not the same during reordering.\n");
|
||||
}
|
||||
|
||||
|
||||
for (int i = 1; i < baseKey.length; i++) {
|
||||
if (baseKey[i] != reorderKey[i]) {
|
||||
errln("Collation key bytes not the same at position " + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* build collator tertiary */
|
||||
myCollation = new RuleBasedCollator("");
|
||||
@ -3206,16 +3203,16 @@ public class CollationMiscTest extends TestFmwk {
|
||||
|
||||
myCollation.setReorderCodes(reorderCodes);
|
||||
reorderKey = myCollation.getCollationKey(testString).toByteArray();
|
||||
|
||||
|
||||
if (baseKey.length != reorderKey.length) {
|
||||
errln("Key lengths not the same during reordering.\n");
|
||||
}
|
||||
|
||||
|
||||
for (int i = 1; i < baseKey.length; i++) {
|
||||
if (baseKey[i] != reorderKey[i]) {
|
||||
errln("Collation key bytes not the same at position " + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -3238,7 +3235,7 @@ public class CollationMiscTest extends TestFmwk {
|
||||
|
||||
/* set the reorderding */
|
||||
myCollation.setReorderCodes(reorderCodes);
|
||||
|
||||
|
||||
retrievedReorderCodes = myCollation.getReorderCodes();
|
||||
if (!Arrays.equals(reorderCodes, retrievedReorderCodes)) {
|
||||
errln("ERROR: retrieved reorder codes do not match set reorder codes.");
|
||||
@ -3246,9 +3243,9 @@ public class CollationMiscTest extends TestFmwk {
|
||||
if (!(myCollation.compare(greekString, punctuationString) < 0)) {
|
||||
errln("ERROR: collation result should have been less.");
|
||||
}
|
||||
|
||||
|
||||
/* clear the reordering */
|
||||
myCollation.setReorderCodes(null);
|
||||
myCollation.setReorderCodes(null);
|
||||
retrievedReorderCodes = myCollation.getReorderCodes();
|
||||
if (retrievedReorderCodes.length != 0) {
|
||||
errln("ERROR: retrieved reorder codes was not null.");
|
||||
@ -3257,12 +3254,12 @@ public class CollationMiscTest extends TestFmwk {
|
||||
if (!(myCollation.compare(greekString, punctuationString) > 0)) {
|
||||
errln("ERROR: collation result should have been greater.");
|
||||
}
|
||||
|
||||
|
||||
// do it again with an empty but non-null array
|
||||
|
||||
|
||||
/* set the reorderding */
|
||||
myCollation.setReorderCodes(reorderCodes);
|
||||
|
||||
|
||||
retrievedReorderCodes = myCollation.getReorderCodes();
|
||||
if (!Arrays.equals(reorderCodes, retrievedReorderCodes)) {
|
||||
errln("ERROR: retrieved reorder codes do not match set reorder codes.");
|
||||
@ -3270,9 +3267,9 @@ public class CollationMiscTest extends TestFmwk {
|
||||
if (!(myCollation.compare(greekString, punctuationString) < 0)) {
|
||||
errln("ERROR: collation result should have been less.");
|
||||
}
|
||||
|
||||
|
||||
/* clear the reordering */
|
||||
myCollation.setReorderCodes(new int[]{});
|
||||
myCollation.setReorderCodes(new int[]{});
|
||||
retrievedReorderCodes = myCollation.getReorderCodes();
|
||||
if (retrievedReorderCodes.length != 0) {
|
||||
errln("ERROR: retrieved reorder codes was not null.");
|
||||
@ -3281,9 +3278,9 @@ public class CollationMiscTest extends TestFmwk {
|
||||
if (!(myCollation.compare(greekString, punctuationString) > 0)) {
|
||||
errln("ERROR: collation result should have been greater.");
|
||||
}
|
||||
|
||||
|
||||
/* clear the reordering using [NONE] */
|
||||
myCollation.setReorderCodes(new int[]{ ReorderCodes.NONE });
|
||||
myCollation.setReorderCodes(new int[]{ ReorderCodes.NONE });
|
||||
retrievedReorderCodes = myCollation.getReorderCodes();
|
||||
if (retrievedReorderCodes.length != 0) {
|
||||
errln("ERROR: [NONE] retrieved reorder codes was not null.");
|
||||
@ -3298,9 +3295,9 @@ public class CollationMiscTest extends TestFmwk {
|
||||
gotException = true;
|
||||
}
|
||||
if (!gotException) {
|
||||
errln("ERROR: exception was not thrown for illegal reorder codes argument.");
|
||||
errln("ERROR: exception was not thrown for illegal reorder codes argument.");
|
||||
}
|
||||
|
||||
|
||||
/* set duplicate reorder codes */
|
||||
gotException = false;
|
||||
try {
|
||||
@ -3309,10 +3306,10 @@ public class CollationMiscTest extends TestFmwk {
|
||||
gotException = true;
|
||||
}
|
||||
if (!gotException) {
|
||||
errln("ERROR: reorder codes following a 'default' code should have thrown an exception but did not.");
|
||||
errln("ERROR: reorder codes following a 'default' code should have thrown an exception but did not.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Test reordering API.
|
||||
*/
|
||||
@ -3325,7 +3322,7 @@ public class CollationMiscTest extends TestFmwk {
|
||||
int[] reorderCodes = {UScript.GREEK, UScript.HAN, ReorderCodes.PUNCTUATION};
|
||||
int[] retrievedReorderCodes;
|
||||
|
||||
|
||||
|
||||
/* build collator tertiary */
|
||||
myCollation = new RuleBasedCollator(rules);
|
||||
myCollation.setStrength(Collator.TERTIARY);
|
||||
@ -3334,9 +3331,9 @@ public class CollationMiscTest extends TestFmwk {
|
||||
if (!Arrays.equals(rulesReorderCodes, retrievedReorderCodes)) {
|
||||
errln("ERROR: retrieved reorder codes do not match set reorder codes.");
|
||||
}
|
||||
|
||||
|
||||
/* clear the reordering */
|
||||
myCollation.setReorderCodes(null);
|
||||
myCollation.setReorderCodes(null);
|
||||
retrievedReorderCodes = myCollation.getReorderCodes();
|
||||
if (retrievedReorderCodes.length != 0) {
|
||||
errln("ERROR: retrieved reorder codes was not null.");
|
||||
@ -3344,14 +3341,14 @@ public class CollationMiscTest extends TestFmwk {
|
||||
|
||||
/* set the reorderding */
|
||||
myCollation.setReorderCodes(reorderCodes);
|
||||
|
||||
|
||||
retrievedReorderCodes = myCollation.getReorderCodes();
|
||||
if (!Arrays.equals(reorderCodes, retrievedReorderCodes)) {
|
||||
errln("ERROR: retrieved reorder codes do not match set reorder codes.");
|
||||
}
|
||||
|
||||
|
||||
/* reset the reordering */
|
||||
myCollation.setReorderCodes(ReorderCodes.DEFAULT);
|
||||
myCollation.setReorderCodes(ReorderCodes.DEFAULT);
|
||||
retrievedReorderCodes = myCollation.getReorderCodes();
|
||||
if (!Arrays.equals(rulesReorderCodes, retrievedReorderCodes)) {
|
||||
errln("ERROR: retrieved reorder codes do not match set reorder codes.");
|
||||
@ -3449,7 +3446,7 @@ public class CollationMiscTest extends TestFmwk {
|
||||
"expected 2, was = " + equivalentScripts.length);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void TestGreekFirstReorderCloning() {
|
||||
String[] testSourceCases = {
|
||||
@ -3495,8 +3492,8 @@ public class CollationMiscTest extends TestFmwk {
|
||||
myCollation.setStrength(Collator.TERTIARY);
|
||||
for (int i = 0; i < testSourceCases.length ; i++)
|
||||
{
|
||||
CollationTest.doTest(this, (RuleBasedCollator)myCollation,
|
||||
testSourceCases[i], testTargetCases[i],
|
||||
CollationTest.doTest(this, (RuleBasedCollator)myCollation,
|
||||
testSourceCases[i], testTargetCases[i],
|
||||
results[i]);
|
||||
}
|
||||
}
|
||||
@ -3512,7 +3509,7 @@ public class CollationMiscTest extends TestFmwk {
|
||||
{
|
||||
Collator myCollation = Collator.getInstance(ULocale.ENGLISH);
|
||||
myCollation.setReorderCodes(reorderTokens);
|
||||
|
||||
|
||||
for (OneTestCase testCase : testCases) {
|
||||
CollationTest.doTest(this, (RuleBasedCollator)myCollation,
|
||||
testCase.m_source_,
|
||||
@ -3531,7 +3528,7 @@ public class CollationMiscTest extends TestFmwk {
|
||||
int[] apiRules = {
|
||||
UScript.GREEK
|
||||
};
|
||||
|
||||
|
||||
OneTestCase[] privateUseCharacterStrings = {
|
||||
new OneTestCase("\u0391", "\u0391", 0),
|
||||
new OneTestCase("\u0041", "\u0391", 1),
|
||||
@ -3558,7 +3555,7 @@ public class CollationMiscTest extends TestFmwk {
|
||||
int[] apiRules = {
|
||||
UScript.UNKNOWN, UScript.GREEK
|
||||
};
|
||||
|
||||
|
||||
OneTestCase[] privateUseCharacterStrings = {
|
||||
new OneTestCase("\u0391", "\u0391", 0),
|
||||
new OneTestCase("\u0041", "\u0391", -1),
|
||||
@ -3566,7 +3563,7 @@ public class CollationMiscTest extends TestFmwk {
|
||||
new OneTestCase("\u0060", "\u0391", -1),
|
||||
new OneTestCase("\u0391", "\ue2dc", 1),
|
||||
};
|
||||
|
||||
|
||||
/* Test rules creation */
|
||||
doTestCollation(privateUseCharacterStrings, strRules);
|
||||
|
||||
@ -3594,7 +3591,7 @@ public class CollationMiscTest extends TestFmwk {
|
||||
new OneTestCase("\u0060", "\u0391", 1),
|
||||
new OneTestCase("\u0024", "\u0041", 1),
|
||||
};
|
||||
|
||||
|
||||
/* Test rules creation */
|
||||
doTestCollation(privateUseCharacterStrings, strRules);
|
||||
|
||||
@ -3621,14 +3618,14 @@ public class CollationMiscTest extends TestFmwk {
|
||||
new OneTestCase("\ufa27", "\u0041", -1),
|
||||
new OneTestCase("\uD869\uDF00", "\u0041", -1),
|
||||
};
|
||||
|
||||
|
||||
/* Test rules creation */
|
||||
doTestCollation(privateUseCharacterStrings, strRules);
|
||||
|
||||
/* Test collation reordering API */
|
||||
doTestOneReorderingAPITestCase(privateUseCharacterStrings, apiRules);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void TestHaniReorderWithOtherRules()
|
||||
{
|
||||
@ -3646,11 +3643,11 @@ public class CollationMiscTest extends TestFmwk {
|
||||
new OneTestCase("\uD869\uDF00", "\u0041", -1),
|
||||
new OneTestCase("b", "a", -1),
|
||||
};
|
||||
|
||||
|
||||
/* Test rules creation */
|
||||
doTestCollation(privateUseCharacterStrings, strRules);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void TestMultipleReorder()
|
||||
{
|
||||
@ -3661,7 +3658,7 @@ public class CollationMiscTest extends TestFmwk {
|
||||
int[] apiRules = {
|
||||
UScript.GREEK, UScript.UNKNOWN, ReorderCodes.DIGIT, UScript.LATIN, UScript.HAN
|
||||
};
|
||||
|
||||
|
||||
OneTestCase[] collationTestCases = {
|
||||
new OneTestCase("\u0391", "\u0041", -1),
|
||||
new OneTestCase("\u0031", "\u0041", -1),
|
||||
@ -3674,13 +3671,13 @@ public class CollationMiscTest extends TestFmwk {
|
||||
/* Test collation reordering API */
|
||||
doTestOneReorderingAPITestCase(collationTestCases, apiRules);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void TestFrozeness()
|
||||
{
|
||||
Collator myCollation = Collator.getInstance(ULocale.CANADA);
|
||||
boolean exceptionCaught = false;
|
||||
|
||||
|
||||
myCollation.freeze();
|
||||
assertTrue("Collator not frozen.", myCollation.isFrozen());
|
||||
|
||||
@ -3692,7 +3689,7 @@ public class CollationMiscTest extends TestFmwk {
|
||||
}
|
||||
assertTrue("Frozen collator allowed change.", exceptionCaught);
|
||||
exceptionCaught = false;
|
||||
|
||||
|
||||
try {
|
||||
myCollation.setReorderCodes(ReorderCodes.DEFAULT);
|
||||
} catch (UnsupportedOperationException e) {
|
||||
@ -3701,7 +3698,7 @@ public class CollationMiscTest extends TestFmwk {
|
||||
}
|
||||
assertTrue("Frozen collator allowed change.", exceptionCaught);
|
||||
exceptionCaught = false;
|
||||
|
||||
|
||||
try {
|
||||
myCollation.setVariableTop(12);
|
||||
} catch (UnsupportedOperationException e) {
|
||||
@ -3710,7 +3707,7 @@ public class CollationMiscTest extends TestFmwk {
|
||||
}
|
||||
assertTrue("Frozen collator allowed change.", exceptionCaught);
|
||||
exceptionCaught = false;
|
||||
|
||||
|
||||
Collator myClone = null;
|
||||
try {
|
||||
myClone = (Collator) myCollation.clone();
|
||||
@ -3719,9 +3716,9 @@ public class CollationMiscTest extends TestFmwk {
|
||||
errln("ERROR: unable to clone collator.");
|
||||
}
|
||||
assertTrue("Clone not frozen as expected.", myClone.isFrozen());
|
||||
|
||||
|
||||
myClone = myClone.cloneAsThawed();
|
||||
assertFalse("Clone not thawed as expected.", myClone.isFrozen());
|
||||
assertFalse("Clone not thawed as expected.", myClone.isFrozen());
|
||||
}
|
||||
|
||||
// Test case for Ticket#9409
|
||||
|
Loading…
Reference in New Issue
Block a user