mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 15:42:14 +00:00
Removed jni files
X-SVN-Rev: 4027
This commit is contained in:
parent
bfbfc53bd9
commit
5930c0b8c9
17 changed files with 0 additions and 4169 deletions
|
@ -1,342 +0,0 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2000, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
* $Source:
|
||||
* /usr/cvs/icu4j/icu4j/src/com/ibm/icu/test/text/CollationElementIteratorTest.java,v $
|
||||
* $Date: 2001/03/09 23:41:46 $
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu4jni.test.text;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.text.ParseException;
|
||||
import com.ibm.text.UCharacter;
|
||||
import com.ibm.icu4jni.test.TestFmwk;
|
||||
import com.ibm.icu4jni.text.Collator;
|
||||
import com.ibm.icu4jni.text.RuleBasedCollator;
|
||||
import com.ibm.icu4jni.text.CollationKey;
|
||||
import com.ibm.icu4jni.text.CollationElementIterator;
|
||||
|
||||
/**
|
||||
* Testing class for Finnish collator
|
||||
* Mostly following the test cases for ICU
|
||||
* @author Syn Wee Quek
|
||||
* @since jan 23 2001
|
||||
*/
|
||||
public final class CollationElementIteratorTest extends TestFmwk
|
||||
{
|
||||
|
||||
// constructor ===================================================
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public CollationElementIteratorTest()
|
||||
{
|
||||
m_collator_ = (RuleBasedCollator)Collator.getInstance(Locale.US);
|
||||
}
|
||||
|
||||
// public methods ================================================
|
||||
|
||||
/**
|
||||
* Test for CollationElementIterator previous and next for the whole set of
|
||||
* unicode characters.
|
||||
*/
|
||||
public void TestUnicodeChar()
|
||||
{
|
||||
for (char codepoint = 1; codepoint < 0xFFFE;)
|
||||
{
|
||||
StringBuffer test = new StringBuffer(0xFF);
|
||||
while (codepoint % 0xFF != 0)
|
||||
{
|
||||
if (UCharacter.isDefined(codepoint))
|
||||
test.append(codepoint);
|
||||
codepoint ++;
|
||||
}
|
||||
|
||||
if (UCharacter.isDefined(codepoint))
|
||||
test.append(codepoint);
|
||||
|
||||
if (codepoint != 0xFFFF)
|
||||
codepoint ++;
|
||||
|
||||
CollationElementIterator iter =
|
||||
m_collator_.getCollationElementIterator(test.toString());
|
||||
|
||||
// A basic test to see if it's working at all
|
||||
previousNext(iter);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing previous method
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestPrevious()
|
||||
{
|
||||
CollationElementIterator iterator =
|
||||
m_collator_.getCollationElementIterator(TEST_CASE_1_);
|
||||
|
||||
// A basic test to see if it's working at all
|
||||
previousNext(iterator);
|
||||
|
||||
try
|
||||
{
|
||||
// Test with a contracting character sequence
|
||||
RuleBasedCollator collator = new RuleBasedCollator(
|
||||
"&a,A < b,B < c,C, d,D < z,Z < ch,cH,Ch,CH");
|
||||
|
||||
iterator = collator.getCollationElementIterator("abchdcba");
|
||||
previousNext(iterator);
|
||||
|
||||
// Test with an expanding character sequence
|
||||
collator = new RuleBasedCollator("&a < b < c/abd < d");
|
||||
|
||||
iterator = collator.getCollationElementIterator("abcd");
|
||||
previousNext(iterator);
|
||||
|
||||
// Now try both
|
||||
collator = new RuleBasedCollator("&a < b < c/aba < d < z < ch");
|
||||
|
||||
String source = "abcdbchdc";
|
||||
iterator = collator.getCollationElementIterator(source);
|
||||
previousNext(iterator);
|
||||
|
||||
source= "\u0e41\u0e02\u0e27abc";
|
||||
|
||||
collator = (RuleBasedCollator)Collator.getInstance(new Locale("th",
|
||||
"TH"));
|
||||
|
||||
iterator = collator.getCollationElementIterator(source);
|
||||
previousNext(iterator);
|
||||
|
||||
collator = (RuleBasedCollator)Collator.getInstance();
|
||||
|
||||
iterator = collator.getCollationElementIterator(source);
|
||||
previousNext(iterator);
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
errln("Failed : Rule parse error " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getOffset() and setOffset()
|
||||
* @exception thrown when error occurs
|
||||
*/
|
||||
public void TestOffset()
|
||||
{
|
||||
CollationElementIterator iter =
|
||||
m_collator_.getCollationElementIterator(TEST_CASE_1_);
|
||||
|
||||
// Run all the way through the iterator, then get the offset
|
||||
int orders[] = getOrders(iter);
|
||||
int offset = iter.getOffset();
|
||||
|
||||
if (offset != TEST_CASE_1_.length())
|
||||
errln("Failed : Collation element iterator offset is not " +
|
||||
"equals to " + TEST_CASE_1_.length());
|
||||
|
||||
// Now set the offset back to the beginning and see if it works
|
||||
CollationElementIterator iter2 =
|
||||
m_collator_.getCollationElementIterator(TEST_CASE_1_);
|
||||
|
||||
iter.setOffset(0);
|
||||
|
||||
for (int i = 0; i < offset; i ++)
|
||||
if (iter.next() != iter2.next())
|
||||
{
|
||||
errln("Failed : Offset reset should revert collation element"
|
||||
+ " to the previous state");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Text setting test
|
||||
* @exception thrown when error occurs
|
||||
*/
|
||||
public void TestSetText()
|
||||
{
|
||||
CollationElementIterator iter1 =
|
||||
m_collator_.getCollationElementIterator(TEST_CASE_1_);
|
||||
CollationElementIterator iter2 =
|
||||
m_collator_.getCollationElementIterator(TEST_CASE_2_);
|
||||
|
||||
// Run through the second iterator just to exercise it
|
||||
int c = iter2.next();
|
||||
for (int i = 0;
|
||||
++ i < 10 && c != CollationElementIterator.NULLORDER;)
|
||||
c = iter2.next();
|
||||
|
||||
// Now set it to point to the same string as the first iterator
|
||||
iter2.setText(TEST_CASE_1_);
|
||||
|
||||
c = 1;
|
||||
for (int i = 0; c != CollationElementIterator.NULLORDER; i ++)
|
||||
{
|
||||
c = iter1.next();
|
||||
if (c != iter2.next())
|
||||
{
|
||||
errln("Failed : Collation element iterator should be equal "
|
||||
+ "if the text string is the same");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
iter1.reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getMaxExpansion() @bug 4108762
|
||||
* @exception thrown when error occurs
|
||||
*/
|
||||
public void TestMaxExpansion()
|
||||
{
|
||||
String rule = "&a < ab < c/aba < d < z < ch";
|
||||
try
|
||||
{
|
||||
RuleBasedCollator coll = new RuleBasedCollator(rule);
|
||||
CollationElementIterator iter = coll.getCollationElementIterator("a");
|
||||
char ch = 1;
|
||||
|
||||
while (ch < 0xFFFF) {
|
||||
int count = 1;
|
||||
int order = 0;
|
||||
ch ++;
|
||||
iter.setText(String.valueOf(ch));
|
||||
order = iter.previous();
|
||||
|
||||
/* thai management */
|
||||
if (order == 0)
|
||||
order = iter.previous();
|
||||
|
||||
while (iter.previous() != CollationElementIterator.NULLORDER) {
|
||||
count ++;
|
||||
}
|
||||
|
||||
if (iter.getMaxExpansion(order) < count) {
|
||||
errln("Failed : Maximum expansion count for 0x" +
|
||||
Integer.toHexString(order) + " < counted size " +
|
||||
Integer.toHexString(count));
|
||||
}
|
||||
}
|
||||
} catch (ParseException e)
|
||||
{
|
||||
errln("Failed : creation of RuleBasedCollator for rules " +
|
||||
rule);
|
||||
}
|
||||
}
|
||||
|
||||
// private variables =============================================
|
||||
|
||||
/**
|
||||
* RuleBasedCollator for testing
|
||||
*/
|
||||
private RuleBasedCollator m_collator_;
|
||||
|
||||
/**
|
||||
* Source strings for testing
|
||||
*/
|
||||
private final String TEST_CASE_1_ =
|
||||
"What subset of all possible test cases?";
|
||||
private final String TEST_CASE_2_ =
|
||||
"has the highest probability of detecting";
|
||||
|
||||
/*
|
||||
* Maximum size used in arrays
|
||||
*/
|
||||
private final int MAX_SIZE_ = 100;
|
||||
|
||||
// private methods --------------------------------------------------
|
||||
|
||||
/**
|
||||
* Testing if next and prev works.
|
||||
* @param iter collation element iterator to be tested
|
||||
*/
|
||||
private void previousNext(CollationElementIterator iter)
|
||||
{
|
||||
// Run through the iterator forwards and stick it into an array
|
||||
int orders[] = getOrders(iter);
|
||||
|
||||
// Now go through it backwards and make sure we get the same values
|
||||
iter.reset();
|
||||
int index = orders.length;
|
||||
int order = iter.previous();
|
||||
while (order != CollationElementIterator.NULLORDER)
|
||||
{
|
||||
if (order != orders[--index]) {
|
||||
if (order == 0) {
|
||||
index ++;
|
||||
}
|
||||
else {
|
||||
while (index > 0 && orders[-- index] == 0)
|
||||
{
|
||||
}
|
||||
if (order != orders[index])
|
||||
{
|
||||
errln("Fail : CollationElementIterator previous element "
|
||||
+ "expected to be " +
|
||||
Integer.toHexString(orders[index]) + " not " +
|
||||
Integer.toHexString(order));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
order = iter.previous();
|
||||
}
|
||||
|
||||
while (index != 0 && orders[index - 1] == 0) {
|
||||
index --;
|
||||
}
|
||||
|
||||
if (index != 0)
|
||||
errln("Fail : CollationElementIterator has more previous " +
|
||||
"elements than next");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an integer array containing all of the collation orders.
|
||||
* returned by calls to next on the specified iterator
|
||||
* @param iter collation element iterator
|
||||
* @return list of all collation order in collation element iterator
|
||||
*/
|
||||
private int[] getOrders(CollationElementIterator iter)
|
||||
{
|
||||
int size = 0;
|
||||
int maxsize = MAX_SIZE_;
|
||||
int result[] = new int[MAX_SIZE_];
|
||||
|
||||
int order = iter.next();
|
||||
while (order != CollationElementIterator.NULLORDER)
|
||||
{
|
||||
if (size == maxsize)
|
||||
{
|
||||
maxsize = maxsize << 1;
|
||||
int temp[] = new int[maxsize];
|
||||
System.arraycopy(result, 0, temp, 0, size);
|
||||
result = temp;
|
||||
}
|
||||
|
||||
result[size ++] = order;
|
||||
order = iter.next();
|
||||
}
|
||||
|
||||
if (maxsize > size)
|
||||
{
|
||||
int temp[] = new int[size];
|
||||
System.arraycopy(result, 0, temp, 0, size);
|
||||
result = temp;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,422 +0,0 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2000, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
* $Source:
|
||||
* /usr/cvs/icu4j/icu4j/src/com/ibm/icu/test/text/CollatorAPITest.java,v $
|
||||
* $Date: 2001/03/09 23:41:46 $
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu4jni.test.text;
|
||||
|
||||
import java.util.Locale;
|
||||
import com.ibm.icu4jni.text.Collator;
|
||||
import com.ibm.icu4jni.text.RuleBasedCollator;
|
||||
import com.ibm.icu4jni.text.CollationKey;
|
||||
import com.ibm.icu4jni.text.CollationAttribute;
|
||||
import com.ibm.icu4jni.text.CollationElementIterator;
|
||||
import com.ibm.icu4jni.text.NormalizationMode;
|
||||
|
||||
/**
|
||||
* Collator API testing class
|
||||
* Mostly following the test cases for ICU
|
||||
* @author Syn Wee Quek
|
||||
* @since jan 29 2001
|
||||
*/
|
||||
public final class CollatorAPITest
|
||||
{
|
||||
|
||||
// constructor ===================================================
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public CollatorAPITest(CollatorTest testprogram) throws Exception
|
||||
{
|
||||
m_test_ = testprogram;
|
||||
// m_collator_ = Collator.getInstance();
|
||||
}
|
||||
|
||||
// public methods ================================================
|
||||
|
||||
/**
|
||||
* Testing collator class properties.
|
||||
* Constructor, compare, strength retrieval/set, decomposition
|
||||
* retrievale/set
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestProperties() throws Exception
|
||||
{
|
||||
m_test_.logln("TestProperties --");
|
||||
byte minversion[] = {0x01, 0x00, 0x00, 0x00};
|
||||
byte maxversion[] = {0x01, 0x09, 0x09, 0x09};
|
||||
byte version[];
|
||||
Collator defaultcollator = Collator.getInstance();
|
||||
|
||||
if (defaultcollator.compare("ab", "abc") != Collator.RESULT_LESS)
|
||||
m_test_.errln("Failed : ab < abc comparison");
|
||||
if (defaultcollator.compare("ab", "AB") != Collator.RESULT_LESS)
|
||||
m_test_.errln("Failed : ab < AB");
|
||||
if (defaultcollator.compare("black-bird", "blackbird") !=
|
||||
Collator.RESULT_GREATER)
|
||||
m_test_.errln("Failed : black-bird > blackbird comparison");
|
||||
if (defaultcollator.compare("black bird", "black-bird") !=
|
||||
Collator.RESULT_LESS)
|
||||
m_test_.errln("Failed : black bird > black-bird comparison");
|
||||
if (defaultcollator.compare("Hello", "hello") !=
|
||||
Collator.RESULT_GREATER)
|
||||
m_test_.errln("Failed : Hello > hello comparison");
|
||||
|
||||
if (defaultcollator.getStrength() != CollationAttribute.VALUE_TERTIARY)
|
||||
m_test_.errln("Failed : Default collation have tertiary strength");
|
||||
|
||||
defaultcollator.setStrength(CollationAttribute.VALUE_SECONDARY);
|
||||
if (defaultcollator.getStrength() != CollationAttribute.VALUE_SECONDARY)
|
||||
m_test_.errln("Failed : Collation strength set to secondary");
|
||||
|
||||
defaultcollator.setDecomposition(NormalizationMode.NO_NORMALIZATION);
|
||||
if (defaultcollator.getDecomposition() !=
|
||||
NormalizationMode.NO_NORMALIZATION)
|
||||
m_test_.errln("Failed : Collation strength set to no normalization");
|
||||
|
||||
if (((RuleBasedCollator)defaultcollator).getRules().length() == 0)
|
||||
m_test_.errln("Failed : RuleBasedCollator getRules() result");
|
||||
|
||||
Collator collator = Collator.getInstance(Locale.FRENCH);
|
||||
|
||||
collator.setStrength(CollationAttribute.VALUE_PRIMARY);
|
||||
if (collator.getStrength() != CollationAttribute.VALUE_PRIMARY)
|
||||
m_test_.errln("Failed : Collation strength set to primary");
|
||||
|
||||
collator.setStrength(CollationAttribute.VALUE_TERTIARY);
|
||||
if (defaultcollator.getStrength() != CollationAttribute.VALUE_TERTIARY)
|
||||
m_test_.errln("Failed : Collation strength set to tertiary");
|
||||
|
||||
// testing rubbish collator
|
||||
// should return the default
|
||||
Locale abcd = new Locale("ab", "CD");
|
||||
collator = Collator.getInstance(abcd);
|
||||
defaultcollator = Collator.getInstance();
|
||||
|
||||
if (!collator.equals(defaultcollator))
|
||||
m_test_.errln("Failed : Undefined locale should return the default " +
|
||||
"collator");
|
||||
|
||||
Collator frenchcollator = Collator.getInstance(Locale.FRANCE);
|
||||
if (!frenchcollator.equals(collator))
|
||||
m_test_.errln("Failed : Undefined locale should return the default " +
|
||||
"collator");
|
||||
|
||||
Collator clonefrench = (Collator)frenchcollator.clone();
|
||||
if (!frenchcollator.equals(clonefrench))
|
||||
m_test_.errln("Failed : Cloning of a French collator");
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing hash code method
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestHashCode() throws Exception
|
||||
{
|
||||
m_test_.logln("TestHashCode --");
|
||||
|
||||
Locale dk = new Locale("da", "DK");
|
||||
Collator collator = Collator.getInstance(dk);
|
||||
|
||||
Collator defaultcollator = Collator.getInstance();
|
||||
|
||||
if (defaultcollator.hashCode() == collator.hashCode())
|
||||
m_test_.errln("Failed : Default collator's hash code not equal to " +
|
||||
"Danish collator's hash code");
|
||||
if (defaultcollator.hashCode() != defaultcollator.hashCode())
|
||||
m_test_.errln("Failed : Hash code of two default collators are equal");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test collation key
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestCollationKey() throws Exception
|
||||
{
|
||||
m_test_.logln("TestCollationKey --");
|
||||
|
||||
String test1 = "Abcda",
|
||||
test2 = "abcda";
|
||||
|
||||
Collator defaultcollator = Collator.getInstance();
|
||||
CollationKey sortk1 = defaultcollator.getCollationKey(test1),
|
||||
sortk2 = defaultcollator.getCollationKey(test2);
|
||||
if (sortk1.compareTo(sortk2) != Collator.RESULT_GREATER)
|
||||
m_test_.errln("Failed : Abcda >>> abcda");
|
||||
|
||||
if (sortk1.equals(sortk2))
|
||||
m_test_.errln("Failed : The sort keys of different strings should be " +
|
||||
"different");
|
||||
if (sortk1.hashCode() == sortk2.hashCode())
|
||||
m_test_.errln("Failed : sort key hashCode() for different strings " +
|
||||
"should be different");
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing the functionality of the collation element iterator
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestElementIterator() throws Exception
|
||||
{
|
||||
m_test_.logln("TestElementIterator --");
|
||||
|
||||
String test1 = "XFILE What subset of all possible test cases has the " +
|
||||
"highest probability of detecting the most errors?";
|
||||
String test2 = "Xf ile What subset of all possible test cases has the " +
|
||||
"lowest probability of detecting the least errors?";
|
||||
Collator defaultcollator = Collator.getInstance();
|
||||
|
||||
CollationElementIterator iterator1 =
|
||||
((RuleBasedCollator)defaultcollator).getCollationElementIterator(
|
||||
test1);
|
||||
|
||||
// copy ctor
|
||||
CollationElementIterator iterator2 =
|
||||
((RuleBasedCollator)defaultcollator).getCollationElementIterator(
|
||||
test2);
|
||||
if (iterator1.equals(iterator2))
|
||||
m_test_.errln("Failed : Two iterators with different strings should " +
|
||||
"be different");
|
||||
|
||||
int order1 = iterator1.next();
|
||||
int order2 = iterator2.next();
|
||||
|
||||
if (CollationElementIterator.primaryOrder(order1) !=
|
||||
CollationElementIterator.primaryOrder(order2))
|
||||
m_test_.errln("Failed : The primary orders should be the same");
|
||||
if (CollationElementIterator.secondaryOrder(order1) !=
|
||||
CollationElementIterator.secondaryOrder(order2))
|
||||
m_test_.errln("Failed : The secondary orders should be the same");
|
||||
if (CollationElementIterator.tertiaryOrder(order1) ==
|
||||
CollationElementIterator.tertiaryOrder(order2))
|
||||
m_test_.errln("Failed : The tertiary orders should be the same");
|
||||
|
||||
order1 = iterator1.next();
|
||||
order2 = iterator2.next();
|
||||
|
||||
if (CollationElementIterator.primaryOrder(order1) !=
|
||||
CollationElementIterator.primaryOrder(order2))
|
||||
m_test_.errln("Failed : The primary orders should be identical");
|
||||
if (CollationElementIterator.tertiaryOrder(order1) ==
|
||||
CollationElementIterator.tertiaryOrder(order2))
|
||||
m_test_.errln("Failed : The tertiary orders should be different");
|
||||
|
||||
order1 = iterator1.next();
|
||||
order2 = iterator2.next();
|
||||
if (CollationElementIterator.secondaryOrder(order1) ==
|
||||
CollationElementIterator.secondaryOrder(order2))
|
||||
m_test_.errln("Failed : The secondary orders should be different");
|
||||
if (order1 == CollationElementIterator.NULLORDER)
|
||||
m_test_.errln("Failed : Unexpected end of iterator reached");
|
||||
|
||||
iterator1.reset();
|
||||
iterator2.reset();
|
||||
order1 = iterator1.next();
|
||||
order2 = iterator2.next();
|
||||
|
||||
if (CollationElementIterator.primaryOrder(order1) !=
|
||||
CollationElementIterator.primaryOrder(order2))
|
||||
m_test_.errln("Failed : The primary orders should be the same");
|
||||
if (CollationElementIterator.secondaryOrder(order1) !=
|
||||
CollationElementIterator.secondaryOrder(order2))
|
||||
m_test_.errln("Failed : The secondary orders should be the same");
|
||||
if (CollationElementIterator.tertiaryOrder(order1) ==
|
||||
CollationElementIterator.tertiaryOrder(order2))
|
||||
m_test_.errln("Failed : The tertiary orders should be the same");
|
||||
|
||||
order1 = iterator1.next();
|
||||
order2 = iterator2.next();
|
||||
|
||||
if (CollationElementIterator.primaryOrder(order1) !=
|
||||
CollationElementIterator.primaryOrder(order2))
|
||||
m_test_.errln("Failed : The primary orders should be identical");
|
||||
if (CollationElementIterator.tertiaryOrder(order1) ==
|
||||
CollationElementIterator.tertiaryOrder(order2))
|
||||
m_test_.errln("Failed : The tertiary orders should be different");
|
||||
|
||||
order1 = iterator1.next();
|
||||
order2 = iterator2.next();
|
||||
if (CollationElementIterator.secondaryOrder(order1) ==
|
||||
CollationElementIterator.secondaryOrder(order2))
|
||||
m_test_.errln("Failed : The secondary orders should be different");
|
||||
if (order1 == CollationElementIterator.NULLORDER)
|
||||
m_test_.errln("Failed : Unexpected end of iterator reached");
|
||||
|
||||
//test error values
|
||||
iterator1.setText("hello there");
|
||||
if (iterator1.previous() != CollationElementIterator.NULLORDER)
|
||||
m_test_.errln("Failed : Retrieval of previous value in a new iterator "
|
||||
+ "has to return a NULLORDER");
|
||||
|
||||
String rule = "< a, A < b, B < c, C < d, D, e, E";
|
||||
try
|
||||
{
|
||||
Collator collator = new RuleBasedCollator(rule);
|
||||
m_test_.errln("Failed : RuleBasedCollator can't have " + rule +
|
||||
" as its rule");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
try
|
||||
{
|
||||
Collator collator = new RuleBasedCollator(rule,
|
||||
CollationAttribute.VALUE_PRIMARY);
|
||||
m_test_.errln("Failed : RuleBasedCollator can't have " + rule +
|
||||
" as its rule");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
try
|
||||
{
|
||||
Collator collator = new RuleBasedCollator(rule,
|
||||
NormalizationMode.NO_NORMALIZATION);
|
||||
m_test_.errln("Failed : RuleBasedCollator can't have " + rule +
|
||||
" as its rule");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
try
|
||||
{
|
||||
Collator collator = new RuleBasedCollator(rule,
|
||||
CollationAttribute.VALUE_SECONDARY);
|
||||
m_test_.errln("Failed : RuleBasedCollator can't have " + rule +
|
||||
" as its rule");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test RuleBasedCollator constructor, clone, copy, and getRules
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestOperators() throws Exception
|
||||
{
|
||||
m_test_.logln("TestOperators --");
|
||||
|
||||
String ruleset1 = "< a, A < b, B < c, C; ch, cH, Ch, CH < d, D, e, E";
|
||||
String ruleset2 = "< a, A < b, B < c, C < d, D, e, E";
|
||||
RuleBasedCollator col1 = new RuleBasedCollator(ruleset1);
|
||||
|
||||
RuleBasedCollator col2 = new RuleBasedCollator(ruleset2);
|
||||
|
||||
if (col1.equals(col2))
|
||||
m_test_.errln("Failed : Two different rule collations should return " +
|
||||
"different comparisons");
|
||||
|
||||
Collator col3 = Collator.getInstance();
|
||||
|
||||
Collator col4 = (Collator)col1.clone();
|
||||
Collator col5 = (Collator)col3.clone();
|
||||
|
||||
if (!col1.equals(col4))
|
||||
m_test_.errln("Failed : Cloned collation objects should be equal");
|
||||
if (col3.equals(col4))
|
||||
m_test_.errln("Failed : Two different rule collations should compare " +
|
||||
"different");
|
||||
if (col3.equals(col5))
|
||||
m_test_.errln("Failed : Cloned collation objects should be equal");
|
||||
if (col4.equals(col5))
|
||||
m_test_.errln("Failed : Clones of 2 different collations should " +
|
||||
"compare different");
|
||||
|
||||
String defrules = ((RuleBasedCollator)col3).getRules();
|
||||
RuleBasedCollator col6 = new RuleBasedCollator(defrules);
|
||||
if (!((RuleBasedCollator)col3).getRules().equals(col6.getRules()))
|
||||
m_test_.errln("Failed : Rules from one collator should create a same " +
|
||||
"collator");
|
||||
|
||||
RuleBasedCollator col7 = new RuleBasedCollator(ruleset2,
|
||||
CollationAttribute.VALUE_TERTIARY);
|
||||
RuleBasedCollator col8 = new RuleBasedCollator(ruleset2,
|
||||
NormalizationMode.NO_NORMALIZATION);
|
||||
RuleBasedCollator col9 = new RuleBasedCollator(ruleset2,
|
||||
CollationAttribute.VALUE_PRIMARY, NormalizationMode.DECOMP_COMPAT);
|
||||
|
||||
if (col7.equals(col9))
|
||||
m_test_.errln("Failed : Two different rule collations should compare " +
|
||||
"different");
|
||||
if (col8.equals(col9))
|
||||
m_test_.errln("Failed : Two different rule collations should compare " +
|
||||
"equal");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test clone and copy
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestDuplicate() throws Exception
|
||||
{
|
||||
m_test_.logln("TestDuplicate --");
|
||||
|
||||
Collator defaultcollator = Collator.getInstance();
|
||||
Collator col2 = (Collator)defaultcollator.clone();
|
||||
if (!defaultcollator.equals(col2))
|
||||
m_test_.errln("Failed : Cloned object should be equal to the orginal");
|
||||
String ruleset = "< a, A < b, B < c, C < d, D, e, E";
|
||||
RuleBasedCollator col3 = new RuleBasedCollator(ruleset);
|
||||
if (defaultcollator.equals(col3))
|
||||
m_test_.errln("Failed : Cloned object not equal to collator created " +
|
||||
"by rules");
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing compare methods
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestCompare() throws Exception
|
||||
{
|
||||
m_test_.logln("TestCompare --");
|
||||
|
||||
String test1 = "Abcda",
|
||||
test2 = "abcda";
|
||||
|
||||
Collator defaultcollator = Collator.getInstance();
|
||||
|
||||
if (defaultcollator.compare(test1, test2) != Collator.RESULT_GREATER)
|
||||
m_test_.errln("Failed : Result should be Abcda >>> abcda");
|
||||
|
||||
defaultcollator.setStrength(CollationAttribute.VALUE_SECONDARY);
|
||||
|
||||
if (defaultcollator.compare(test1, test2) != Collator.RESULT_EQUAL)
|
||||
m_test_.errln("Failed : Result should be Abcda == abcda");
|
||||
|
||||
defaultcollator.setStrength(CollationAttribute.VALUE_PRIMARY);
|
||||
|
||||
if (!defaultcollator.equals(test1, test2))
|
||||
m_test_.errln("Failed : Result should be Abcda == abcda");
|
||||
}
|
||||
|
||||
// private variables =============================================
|
||||
|
||||
/**
|
||||
* Main Collation test program
|
||||
*/
|
||||
private CollatorTest m_test_;
|
||||
|
||||
/**
|
||||
* Test collator
|
||||
*/
|
||||
// private Collator m_collator_;
|
||||
|
||||
/**
|
||||
* Source string for testing
|
||||
*/
|
||||
private static final String SOURCE_TEST_CASE_ =
|
||||
"-abcdefghijklmnopqrstuvwxyz#&^$@";
|
||||
}
|
||||
|
|
@ -1,194 +0,0 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2000, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
* $Source:
|
||||
* /usr/cvs/icu4j/icu4j/src/com/ibm/icu/test/text/CollatorJNIPerformanceTest.java,v $
|
||||
* $Date: 2001/03/09 23:41:46 $
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu4jni.test.text;
|
||||
|
||||
import java.util.Locale;
|
||||
import com.ibm.icu4jni.text.Collator;
|
||||
import com.ibm.icu4jni.text.RuleBasedCollator;
|
||||
import com.ibm.icu4jni.text.CollationKey;
|
||||
|
||||
/**
|
||||
* Performance testing class for Collator
|
||||
* @author Syn Wee Quek
|
||||
* @since jan 23 2001
|
||||
*/
|
||||
public final class CollatorPerformanceTest
|
||||
{
|
||||
|
||||
// constructor ===================================================
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public CollatorPerformanceTest()
|
||||
{
|
||||
}
|
||||
|
||||
// public methods ================================================
|
||||
|
||||
/**
|
||||
* Sortkey retrieval performance testing
|
||||
* @param locale for processing
|
||||
* @param str test string
|
||||
* @return time taken for loop
|
||||
*/
|
||||
public long testSortKey(Locale locale, String str) throws Exception
|
||||
{
|
||||
System.gc();
|
||||
RuleBasedCollator collator =
|
||||
(RuleBasedCollator)Collator.getInstance(locale);
|
||||
|
||||
// initial startup cost
|
||||
collator.getCollationKey(str);
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
for (int i = 0; i < LOOP_COUNT_; i ++)
|
||||
collator.getCollationKey(str);
|
||||
|
||||
long end = System.currentTimeMillis();
|
||||
|
||||
long loopstart = System.currentTimeMillis();
|
||||
for (int i = 0; i < LOOP_COUNT_; i ++)
|
||||
{
|
||||
}
|
||||
|
||||
long loopend = System.currentTimeMillis();
|
||||
|
||||
collator = null;
|
||||
str = null;
|
||||
return (end - start) - (loopend - loopstart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sortkey retrieval performance testing
|
||||
* @param locale for processing
|
||||
* @param str test string
|
||||
* @return time taken for loop
|
||||
*/
|
||||
public long testJDKSortKey(Locale locale, String str) throws Exception
|
||||
{
|
||||
System.gc();
|
||||
java.text.Collator collator = java.text.Collator.getInstance(locale);
|
||||
|
||||
collator.getCollationKey(str);
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
for (int i = 0; i < LOOP_COUNT_ - 1; i ++)
|
||||
collator.getCollationKey(str);
|
||||
long end = System.currentTimeMillis();
|
||||
|
||||
long loopstart = System.currentTimeMillis();
|
||||
for (int i = 0; i < LOOP_COUNT_; i ++)
|
||||
{
|
||||
}
|
||||
|
||||
long loopend = System.currentTimeMillis();
|
||||
|
||||
collator = null;
|
||||
str = null;
|
||||
return (end - start) - (loopend - loopstart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Main method for running test
|
||||
* @param arg argument
|
||||
*/
|
||||
public static void main(String[] arg)
|
||||
{
|
||||
Locale locale[] = {Locale.US, Locale.CHINA, Locale.FRANCE, Locale.GERMANY,
|
||||
Locale.JAPAN, Locale.ITALY};
|
||||
String str = LONG_STRING_;
|
||||
|
||||
if (arg.length > 0)
|
||||
{
|
||||
if (arg[0].equals("short"))
|
||||
str = SHORT_STRING_;
|
||||
else
|
||||
if (!arg[0].equals("long"))
|
||||
str = arg[0];
|
||||
}
|
||||
|
||||
System.out.println(str);
|
||||
|
||||
long time = 0;
|
||||
CollatorPerformanceTest test = new CollatorPerformanceTest();
|
||||
|
||||
try
|
||||
{
|
||||
System.out.println("");
|
||||
System.out.println("US CHINA FRANCE GERMANY JAPAN ITALY");
|
||||
// doing a first round to remove any possibility of startup cost
|
||||
for (int i = 0; i < CONSISTENCY_COUNT_; i ++)
|
||||
{
|
||||
for (int j = 0; j < locale.length; j ++)
|
||||
{
|
||||
time = test.testSortKey(locale[j], str);
|
||||
System.out.print(time + " ");
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
System.out.println("JAVA");
|
||||
System.out.println("US CHINA FRANCE GERMANY JAPAN ITALY");
|
||||
// doing a first round to remove any possibility of startup cost
|
||||
for (int i = 0; i < CONSISTENCY_COUNT_; i ++)
|
||||
{
|
||||
for (int j = 0; j < locale.length; j ++)
|
||||
{
|
||||
time = test.testJDKSortKey(locale[j], str);
|
||||
System.out.print(time + " ");
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// private variables =============================================
|
||||
|
||||
/**
|
||||
* RuleBasedCollator for performance testing
|
||||
*/
|
||||
private Collator m_collator_;
|
||||
|
||||
/**
|
||||
* Number times for looping
|
||||
*/
|
||||
private static final int LOOP_COUNT_ = 200000;
|
||||
|
||||
/**
|
||||
* Number of times for running the loops to determine consistency
|
||||
*/
|
||||
private static final int CONSISTENCY_COUNT_ = 10;
|
||||
|
||||
/**
|
||||
* Long test string
|
||||
*/
|
||||
private static final String LONG_STRING_ =
|
||||
"\u0055\u006e\u0069\u0074\u0065\u0064\u0020\u0053\u0074\u0061\u0074\u0065" +
|
||||
"\u0073\u4e2d\u534e\u4eba\u6c11\u5171\u548c\u56fd\u0046\u0072\u0061\u006e" +
|
||||
"\u0063\u0065\u0044\u0065\u0075\u0074\u0073\u0063\u0068\u006c\u0061\u006e" +
|
||||
"\u0064\u65e5\u672c\u0049\u0074\u0061\u006c\u0069\u0061";
|
||||
|
||||
/**
|
||||
* Short test string
|
||||
*/
|
||||
private static final String SHORT_STRING_ =
|
||||
"\u0055\u4e2d\u534e\u4eba\u0046\u0044\u65e5\u372c\u0049\u0074";
|
||||
}
|
||||
|
|
@ -1,654 +0,0 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2000, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
* $Source:
|
||||
* /usr/cvs/icu4j/icu4j/src/com/ibm/icu/test/text/CollatorRegressionTest.java,v $
|
||||
* $Date: 2001/03/09 23:41:46 $
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu4jni.test.text;
|
||||
|
||||
import com.ibm.icu4jni.text.Collator;
|
||||
import com.ibm.icu4jni.text.RuleBasedCollator;
|
||||
import com.ibm.icu4jni.text.CollationKey;
|
||||
import com.ibm.icu4jni.text.CollationElementIterator;
|
||||
import com.ibm.icu4jni.text.NormalizationMode;
|
||||
import com.ibm.icu4jni.text.CollationAttribute;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Collator regression testing class
|
||||
* Mostly following the test cases for ICU
|
||||
* @author Syn Wee Quek
|
||||
* @since jan 29 2001
|
||||
*/
|
||||
public final class CollatorRegressionTest
|
||||
{
|
||||
|
||||
// constructor ===================================================
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public CollatorRegressionTest(CollatorTest testprogram) throws Exception
|
||||
{
|
||||
m_test_ = testprogram;
|
||||
m_collator_ = Collator.getInstance();
|
||||
}
|
||||
|
||||
// public methods ================================================
|
||||
|
||||
/**
|
||||
* Testing bug 4048446
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4048446() throws Exception
|
||||
{
|
||||
CollationElementIterator i1 =
|
||||
((RuleBasedCollator)m_collator_).getCollationElementIterator(
|
||||
TEST_STRING_1_);
|
||||
CollationElementIterator i2 =
|
||||
((RuleBasedCollator)m_collator_).getCollationElementIterator(
|
||||
TEST_STRING_1_);
|
||||
if (i1 == null || i2 == null)
|
||||
{
|
||||
m_test_.errln("Failed : Creation of the collation element iterator");
|
||||
return;
|
||||
}
|
||||
|
||||
while (i1.next() != CollationElementIterator.NULLORDER)
|
||||
{
|
||||
}
|
||||
|
||||
i1.reset();
|
||||
|
||||
int c1 = 1,
|
||||
c2;
|
||||
while (c1 != CollationElementIterator.NULLORDER);
|
||||
{
|
||||
c1 = i1.next();
|
||||
c2 = i2.next();
|
||||
|
||||
if (c1 != c2)
|
||||
{
|
||||
m_test_.errln("Failed : Resetting collation element iterator " +
|
||||
"should revert it back to the orginal state");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing bug 4051866
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4051866() throws Exception
|
||||
{
|
||||
String rules= "< o & oe ,o\u3080& oe ,\u1530 ,O& OE ,O\u3080& OE ," +
|
||||
"\u1520< p ,P";
|
||||
|
||||
// Build a collator containing expanding characters
|
||||
RuleBasedCollator c1 = new RuleBasedCollator(rules);
|
||||
|
||||
// Build another using the rules from the first
|
||||
RuleBasedCollator c2 = new RuleBasedCollator(c1.getRules());
|
||||
|
||||
if (!(c1.getRules().equals(c2.getRules())))
|
||||
m_test_.errln("Failed : Rules from equivalent collators should be " +
|
||||
"the same");
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing bug 4053636
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4053636() throws Exception
|
||||
{
|
||||
if (m_collator_.equals("black_bird", "black"))
|
||||
m_test_.errln("Failed : black-bird != black");
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing bug 4054238
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4054238() throws Exception
|
||||
{
|
||||
RuleBasedCollator c = (RuleBasedCollator)m_collator_.clone();
|
||||
|
||||
c.setDecomposition(NormalizationMode.DECOMP_CAN);
|
||||
CollationElementIterator i1 = c.getCollationElementIterator(
|
||||
TEST_STRING_3_);
|
||||
c.setDecomposition(NormalizationMode.NO_NORMALIZATION);
|
||||
CollationElementIterator i2 = c.getCollationElementIterator(
|
||||
TEST_STRING_3_);
|
||||
|
||||
// At this point, BOTH iterators should use NO_DECOMPOSITION, since the
|
||||
// collator itself is in that mode
|
||||
int c1 = 1,
|
||||
c2;
|
||||
while (c1 != CollationElementIterator.NULLORDER);
|
||||
{
|
||||
c1 = i1.next();
|
||||
c2 = i2.next();
|
||||
|
||||
if (c1 != c2)
|
||||
{
|
||||
m_test_.errln("Failed : Comparison of equivalent collation element " +
|
||||
"iterator should be equal");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing bug 4054734
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4054734() throws Exception
|
||||
{
|
||||
final String decomp[] = {"\u0001", "\u003c", "\u0002", "\u0001", "\u003d",
|
||||
"\u0001", "\u0041", "\u0001", "\u003e", "\u007e",
|
||||
"\u0002", "\u00c0", "\u003d", "\u0041\u0300"};
|
||||
|
||||
final String nodecomp[] = {"\u00C0", "\u003e", "\u0041\u0300"};
|
||||
|
||||
RuleBasedCollator c = (RuleBasedCollator)m_collator_.clone();
|
||||
|
||||
c.setStrength(CollationAttribute.VALUE_IDENTICAL);
|
||||
|
||||
c.setDecomposition(NormalizationMode.DECOMP_CAN);
|
||||
compareStrings(c, decomp, decomp.length);
|
||||
c.setDecomposition(NormalizationMode.NO_NORMALIZATION);
|
||||
compareStrings(c, nodecomp, nodecomp.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing bug 4054734
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4054736() throws Exception
|
||||
{
|
||||
RuleBasedCollator c = (RuleBasedCollator)m_collator_.clone();
|
||||
|
||||
c.setDecomposition(NormalizationMode.DECOMP_COMPAT);
|
||||
|
||||
final String tests[] = {"\uFB4F", "\u003d", "\u05D0\u05DC"};
|
||||
// Alef-Lamed vs. Alef, Lamed
|
||||
|
||||
compareStrings(c, tests, tests.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing bug 4058613
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4058613() throws Exception
|
||||
{
|
||||
Locale oldDefault = Locale.getDefault();
|
||||
Locale.setDefault(Locale.KOREAN);
|
||||
|
||||
Collator c = Collator.getInstance();
|
||||
|
||||
// Since the fix to this bug was to turn off decomposition for Korean
|
||||
// collators, ensure that's what we got
|
||||
if (c.getDecomposition() != NormalizationMode.NO_NORMALIZATION)
|
||||
m_test_.errln("Failed : Decomposition is not set to NO_DECOMPOSITION " +
|
||||
"for Korean collator");
|
||||
|
||||
Locale.setDefault(oldDefault);
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing bug 4059820
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4059820() throws Exception
|
||||
{
|
||||
String rules = "< a < b , c/a < d < z";
|
||||
|
||||
RuleBasedCollator c = new RuleBasedCollator(rules);
|
||||
|
||||
if (c.getRules().indexOf("c/a") == -1)
|
||||
m_test_.errln("Failed : Rules should contain 'c/a'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing bug 4060154
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4060154() throws Exception
|
||||
{
|
||||
String rules = "< g, G < h, H < i, I < j, J & H < \u0131, \u0130, i, I";
|
||||
RuleBasedCollator c = new RuleBasedCollator(rules);
|
||||
|
||||
c.setDecomposition(NormalizationMode.DECOMP_CAN);
|
||||
|
||||
String tertiary[] = {"\u0041", "\u003c", "\u0042", "\u0048", "\u003c",
|
||||
"\u0131", "\u0048", "\u003c", "\u0049", "\u0131",
|
||||
"\u003c", "\u0130", "\u0130", "\u003c", "\u0069",
|
||||
"\u0130", "\u003e", "\u0048"};
|
||||
|
||||
c.setStrength(CollationAttribute.VALUE_TERTIARY);
|
||||
compareStrings(c, tertiary, tertiary.length);
|
||||
|
||||
String secondary[] = {"\u0048", "\u003c", "\u0049", "\u0131", "\u003d",
|
||||
"\u0130"};
|
||||
|
||||
c.setStrength(CollationAttribute.VALUE_PRIMARY);
|
||||
compareStrings(c, secondary, secondary.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing bug 4062418
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4062418() throws Exception
|
||||
{
|
||||
RuleBasedCollator c = (RuleBasedCollator)Collator.getInstance(
|
||||
Locale.FRANCE);
|
||||
|
||||
c.setStrength(CollationAttribute.VALUE_SECONDARY);
|
||||
|
||||
String tests[] = {"\u0070\u00EA\u0063\u0068\u0065", "\u003c",
|
||||
"\u0070\u00E9\u0063\u0068\u00E9"};
|
||||
|
||||
compareStrings(c, tests, tests.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing bug 4065540
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4065540() throws Exception
|
||||
{
|
||||
if (m_collator_.equals("abcd e", "abcd f"))
|
||||
m_test_.errln("Failed : 'abcd e' != 'abcd f'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing bug 4066189
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4066189() throws Exception
|
||||
{
|
||||
String chars1 = "\u1EB1";
|
||||
String chars2 = "\u0061\u0306\u0300";
|
||||
String test1 = chars1;
|
||||
String test2 = chars2;
|
||||
|
||||
RuleBasedCollator c1 = (RuleBasedCollator)m_collator_.clone();
|
||||
c1.setDecomposition(NormalizationMode.DECOMP_COMPAT);
|
||||
CollationElementIterator i1 = c1.getCollationElementIterator(test1);
|
||||
|
||||
RuleBasedCollator c2 = (RuleBasedCollator)m_collator_.clone();
|
||||
c2.setDecomposition(NormalizationMode.NO_NORMALIZATION);
|
||||
CollationElementIterator i2 = c2.getCollationElementIterator(test2);
|
||||
|
||||
int ce1 = 1,
|
||||
ce2;
|
||||
while (ce1 != CollationElementIterator.NULLORDER);
|
||||
{
|
||||
ce1 = i1.next();
|
||||
ce2 = i2.next();
|
||||
|
||||
if (ce1 != ce2)
|
||||
{
|
||||
m_test_.errln("Failed : \u1EB1 == \u0061\u0306\u0300");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing bug 4066696
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4066696() throws Exception
|
||||
{
|
||||
RuleBasedCollator c = (RuleBasedCollator)Collator.getInstance(
|
||||
Locale.FRANCE);
|
||||
|
||||
c.setStrength(CollationAttribute.VALUE_SECONDARY);
|
||||
|
||||
String tests[] = {"\u00E0", "\u003e", "\u01FA"};
|
||||
|
||||
compareStrings(c, tests, tests.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing bug 4076676
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4076676() throws Exception
|
||||
{
|
||||
// These combining characters are all in the same class, so they should not
|
||||
// be reordered, and they should compare as unequal.
|
||||
String s1 = "\u0041\u0301\u0302\u0300";
|
||||
String s2 = "\u0041\u0302\u0300\u0301";
|
||||
|
||||
RuleBasedCollator c = (RuleBasedCollator)m_collator_.clone();
|
||||
c.setStrength(CollationAttribute.VALUE_TERTIARY);
|
||||
|
||||
if (c.equals(s1, s2))
|
||||
m_test_.errln("Failed : Reordered combining chars of the same class " +
|
||||
"are not equal");
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing bug 4078588
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4078588() throws Exception
|
||||
{
|
||||
RuleBasedCollator rbc = new RuleBasedCollator("< a < bb");
|
||||
|
||||
int result = rbc.compare("a", "bb");
|
||||
|
||||
if (result != Collator.RESULT_LESS)
|
||||
m_test_.errln("Failed : a < bb");
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing bug 4081866
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4081866() throws Exception
|
||||
{
|
||||
// These combining characters are all in different classes,
|
||||
// so they should be reordered and the strings should compare as equal.
|
||||
String s1 = "\u0041\u0300\u0316\u0327\u0315";
|
||||
String s2 = "\u0041\u0327\u0316\u0315\u0300";
|
||||
|
||||
RuleBasedCollator c = (RuleBasedCollator)m_collator_.clone();
|
||||
c.setStrength(CollationAttribute.VALUE_TERTIARY);
|
||||
|
||||
// Now that the default collators are set to NO_DECOMPOSITION
|
||||
// (as a result of fixing bug 4114077), we must set it explicitly
|
||||
// when we're testing reordering behavior.
|
||||
c.setDecomposition(NormalizationMode.DECOMP_CAN);
|
||||
|
||||
if (!c.equals(s1, s2))
|
||||
m_test_.errln("Failed : \u0041\u0300\u0316\u0327\u0315 = " +
|
||||
"\u0041\u0327\u0316\u0315\u0300");
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing bug 4087241
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4087241() throws Exception
|
||||
{
|
||||
Locale da_DK = new Locale("da", "DK");
|
||||
RuleBasedCollator c = (RuleBasedCollator)Collator.getInstance(da_DK);
|
||||
|
||||
c.setStrength(CollationAttribute.VALUE_SECONDARY);
|
||||
|
||||
String tests[] = {"\u007a", "\u003c", "\u00E6", // z < ae
|
||||
// a-unlaut < a-ring
|
||||
"\u0061\u0308", "\u003c", "\u0061\u030A",
|
||||
"\u0059", "\u003c", "\u0075\u0308"}; // Y < u-umlaut
|
||||
|
||||
compareStrings(c, tests, tests.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing bug 4087243
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4087243() throws Exception
|
||||
{
|
||||
RuleBasedCollator c = (RuleBasedCollator)m_collator_.clone();
|
||||
c.setStrength(CollationAttribute.VALUE_TERTIARY);
|
||||
|
||||
String tests[] = {"\u0031\u0032\u0033", "\u003d",
|
||||
"\u0031\u0032\u0033\u0001"}; // 1 2 3 = 1 2 3 ctrl-A
|
||||
|
||||
compareStrings(c, tests, tests.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing bug 4092260
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4092260() throws Exception
|
||||
{
|
||||
Locale el = new Locale("el", "");
|
||||
Collator c = Collator.getInstance(el);
|
||||
|
||||
String tests[] = {"\u00B5", "\u003d", "\u03BC"};
|
||||
|
||||
compareStrings(c, tests, tests.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing bug 4095316
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4095316() throws Exception
|
||||
{
|
||||
Locale el = new Locale("el", "GR");
|
||||
Collator c = Collator.getInstance(el);
|
||||
c.setStrength(CollationAttribute.VALUE_TERTIARY);
|
||||
|
||||
String tests[] = {"\u03D4", "\u003d", "\u03AB"};
|
||||
|
||||
compareStrings(c, tests, tests.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing bug 4101940
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4101940() throws Exception
|
||||
{
|
||||
RuleBasedCollator c = new RuleBasedCollator("< a < b");
|
||||
|
||||
CollationElementIterator i = c.getCollationElementIterator("");
|
||||
i.reset();
|
||||
|
||||
if (i.next() != CollationElementIterator.NULLORDER)
|
||||
m_test_.errln("Failed : next did not return NULLORDER");
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing bug 4103436
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4103436() throws Exception
|
||||
{
|
||||
RuleBasedCollator c = (RuleBasedCollator)m_collator_.clone();
|
||||
c.setStrength(CollationAttribute.VALUE_TERTIARY);
|
||||
|
||||
String tests[] = { "\u0066\u0069\u006c\u0065", "\u003c",
|
||||
"\u0066\u0069\u006c\u0065\u0020\u0061\u0063\u0063\u0065\u0073\u0073",
|
||||
"\u0066\u0069\u006c\u0065", "\u003c",
|
||||
"\u0066\u0069\u006c\u0065\u0061\u0063\u0063\u0065\u0073\u0073"};
|
||||
|
||||
compareStrings(c, tests, tests.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing bug 4114076
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4114076() throws Exception
|
||||
{
|
||||
RuleBasedCollator c = (RuleBasedCollator)m_collator_.clone();
|
||||
c.setStrength(CollationAttribute.VALUE_TERTIARY);
|
||||
|
||||
String tests[] = { "\ud4db", "\u003d", "\u1111\u1171\u11b6"};
|
||||
|
||||
c.setDecomposition(NormalizationMode.DECOMP_CAN);
|
||||
compareStrings(c, tests, tests.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing bug 4124632
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4124632() throws Exception
|
||||
{
|
||||
Collator c = Collator.getInstance(Locale.JAPAN);
|
||||
String test = "\u0041\u0308\u0062\u0063";
|
||||
CollationKey key = c.getCollationKey(test);
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing bug 4132736
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4132736() throws Exception
|
||||
{
|
||||
Collator c = Collator.getInstance(Locale.FRANCE);
|
||||
String tests[] = {"\u0065\u0300\u0065\u0301", "\u003c",
|
||||
"\u0065\u0301\u0065\u0300", "\u0065\u0300\u0301",
|
||||
"\u003c", "\u0065\u0301\u0300"};
|
||||
compareStrings(c, tests, tests.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing bug 4133509
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4133509() throws Exception
|
||||
{
|
||||
Collator c = Collator.getInstance(Locale.FRANCE);
|
||||
String tests[] = {
|
||||
"\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e", "\u003c",
|
||||
"\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0049\u006e\u0049\u006e\u0069\u0074\u0069\u0061\u006c\u0069\u007a\u0065\u0072\u0045\u0072\u0072\u006f\u0072",
|
||||
"\u0047\u0072\u0061\u0070\u0068\u0069\u0063\u0073", "\u003c",
|
||||
"\u0047\u0072\u0061\u0070\u0068\u0069\u0063\u0073\u0045\u006e\u0076\u0069\u0072\u006f\u006e\u006d\u0065\u006e\u0074",
|
||||
"\u0053\u0074\u0072\u0069\u006e\u0067", "\u003c",
|
||||
"\u0053\u0074\u0072\u0069\u006e\u0067\u0042\u0075\u0066\u0066\u0065\u0072"
|
||||
};
|
||||
compareStrings(m_collator_, tests, tests.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing bug 4114077
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4114077() throws Exception
|
||||
{
|
||||
// Ensure that we get the same results with decomposition off
|
||||
// as we do with it on....
|
||||
|
||||
RuleBasedCollator c = (RuleBasedCollator)m_collator_.clone();
|
||||
c.setStrength(CollationAttribute.VALUE_TERTIARY);
|
||||
|
||||
String test1[] =
|
||||
{
|
||||
"\u00C0", "\u003d", "\u0041\u0300", // Should be equivalent
|
||||
"\u0070\u00ea\u0063\u0068\u0065", "\u003e",
|
||||
"\u0070\u00e9\u0063\u0068\u00e9",
|
||||
"\u0204", "\u003d", "\u0045\u030F",
|
||||
// a-ring-acute -> a-ring, acute
|
||||
"\u01fa", "\u003d", "\u0041\u030a\u0301",
|
||||
// -> a, ring, acute
|
||||
// No reordering --> unequal
|
||||
"\u0041\u0300\u0316", "\u003c", "\u0041\u0316\u0300"
|
||||
};
|
||||
|
||||
c.setDecomposition(NormalizationMode.NO_NORMALIZATION);
|
||||
compareStrings(c, test1, test1.length);
|
||||
|
||||
String test2[] = {"\u0041\u0300\u0316", "\u003d", "\u0041\u0316\u0300"};
|
||||
// Reordering --> equal
|
||||
|
||||
c.setDecomposition(NormalizationMode.DECOMP_CAN);
|
||||
compareStrings(c, test2, test2.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing bug 4139572
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void Test4139572() throws Exception
|
||||
{
|
||||
// Rather than just creating a Swedish collator, we might as well
|
||||
// try to instantiate one for every locale available on the system
|
||||
// in order to prevent this sort of bug from cropping up in the future
|
||||
// Code pasted straight from the bug report
|
||||
// (and then translated to C++ ;-)
|
||||
Locale l = new Locale("es", "es");
|
||||
Collator col = Collator.getInstance(l);
|
||||
|
||||
CollationKey key = col.getCollationKey("Nombre De Objeto");
|
||||
}
|
||||
|
||||
// private variables =============================================
|
||||
|
||||
/**
|
||||
* Main Collation test program
|
||||
*/
|
||||
private CollatorTest m_test_;
|
||||
|
||||
/**
|
||||
* Test collator
|
||||
*/
|
||||
private Collator m_collator_;
|
||||
|
||||
/**
|
||||
* Source strings for testing
|
||||
*/
|
||||
private final String TEST_STRING_1_ = "XFILE What subset of all possible " +
|
||||
"test cases has the highest probability of detecting the most errors?";
|
||||
private final String TEST_STRING_2_ = "Xf ile What subset of all " +
|
||||
"possible test cases has the lowest probability of detecting the least " +
|
||||
"errors?";
|
||||
private final char CHAR_ARRAY_[] = {0x0061, 0x00FC, 0x0062, 0x0065, 0x0063,
|
||||
0x006b, 0x0020, 0x0047, 0x0072, 0x00F6,
|
||||
0x00DF, 0x0065, 0x0020, 0x004c, 0x00FC,
|
||||
0x0062, 0x0063, 0x006b
|
||||
};
|
||||
private final String TEST_STRING_3_ = new String(CHAR_ARRAY_);
|
||||
|
||||
// private methods ------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Comparing strings
|
||||
*/
|
||||
private void compareStrings(Collator c, String tests[], int testcount)
|
||||
{
|
||||
int expectedResult = Collator.RESULT_EQUAL;
|
||||
|
||||
for (int i = 0; i < testcount; i += 3)
|
||||
{
|
||||
String source = tests[i];
|
||||
String comparison = tests[i + 1];
|
||||
String target = tests[i + 2];
|
||||
|
||||
if (comparison.equals("<"))
|
||||
expectedResult = Collator.RESULT_LESS;
|
||||
else
|
||||
if (comparison.equals(">"))
|
||||
expectedResult = Collator.RESULT_GREATER;
|
||||
else
|
||||
if (comparison.equals("="))
|
||||
expectedResult = Collator.RESULT_EQUAL;
|
||||
else
|
||||
m_test_.errln("Failed : Bogus comparison string \"" + comparison
|
||||
+ "\"");
|
||||
|
||||
CollationKey sourceKey, targetKey;
|
||||
|
||||
sourceKey = c.getCollationKey(source);
|
||||
targetKey = c.getCollationKey(target);
|
||||
|
||||
if (sourceKey.compareTo(targetKey) != expectedResult)
|
||||
{
|
||||
m_test_.errln("Failed : String comparison of " + source + " and " +
|
||||
target + " should be " + expectedResult);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,119 +0,0 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2000, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
* $Source:
|
||||
* /usr/cvs/icu4j/icu4j/src/com/ibm/icu/test/text/CurrencyCollatorTest.java,v $
|
||||
* $Date: 2001/03/09 23:41:46 $
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu4jni.test.text;
|
||||
|
||||
import com.ibm.icu4jni.text.Collator;
|
||||
import com.ibm.icu4jni.text.CollationKey;
|
||||
import com.ibm.icu4jni.text.CollationAttribute;
|
||||
|
||||
/**
|
||||
* Testing class for currency collator
|
||||
* Mostly following the test cases for ICU
|
||||
* @author Syn Wee Quek
|
||||
* @since jan 23 2001
|
||||
*/
|
||||
public final class CurrencyCollatorTest
|
||||
{
|
||||
|
||||
// constructor ===================================================
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public CurrencyCollatorTest(CollatorTest testprogram) throws Exception
|
||||
{
|
||||
m_test_ = testprogram;
|
||||
m_collator_ = Collator.getInstance();
|
||||
}
|
||||
|
||||
// public methods ================================================
|
||||
|
||||
/**
|
||||
* Test with primary collation strength
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestCurrency() throws Exception
|
||||
{
|
||||
int expectedresult;
|
||||
int size = m_currency_.length;
|
||||
|
||||
String source;
|
||||
String target;
|
||||
|
||||
// Compare each currency symbol against all the currency symbols,
|
||||
// including itself
|
||||
for (int i = 0; i < size; i ++)
|
||||
{
|
||||
source = m_currency_[i];
|
||||
for (int j = 0; j < size; j ++)
|
||||
{
|
||||
target = m_currency_[j];
|
||||
if (i < j)
|
||||
expectedresult = Collator.RESULT_LESS;
|
||||
else
|
||||
if ( i == j)
|
||||
expectedresult = Collator.RESULT_EQUAL;
|
||||
else
|
||||
expectedresult = Collator.RESULT_GREATER;
|
||||
|
||||
CollationKey skey = m_collator_.getCollationKey(source),
|
||||
tkey = m_collator_.getCollationKey(target);
|
||||
|
||||
if (skey.compareTo(tkey) != expectedresult)
|
||||
{
|
||||
m_test_.errln("Fail : Collation keys for " + source + " and " +
|
||||
target + " expected to be " + expectedresult);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// private variables =============================================
|
||||
|
||||
/**
|
||||
* RuleBasedCollator for testing
|
||||
*/
|
||||
private Collator m_collator_;
|
||||
|
||||
/**
|
||||
* Main Collation test program
|
||||
*/
|
||||
private CollatorTest m_test_;
|
||||
|
||||
/**
|
||||
* Test data in ascending collation order
|
||||
*/
|
||||
private final String m_currency_[] = {"\u00a4", // generic currency
|
||||
"\u0e3f", // baht
|
||||
"\u00a2", // cent
|
||||
"\u20a1", // colon
|
||||
"\u20a2", // cruzeiro
|
||||
"\u0024", // dollar
|
||||
"\u20ab", // dong
|
||||
"\u20ac", // euro
|
||||
"\u20a3", // franc
|
||||
"\u20a4", // lira
|
||||
"\u20a5", // mill
|
||||
"\u20a6", // naira
|
||||
"\u20a7", // peseta
|
||||
"\u00a3", // pound
|
||||
"\u20a8", // rupee
|
||||
"\u20aa", // shekel
|
||||
"\u20a9", // won
|
||||
"\u00a5" // yen
|
||||
};
|
||||
}
|
||||
|
|
@ -1,258 +0,0 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2000, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
* $Source:
|
||||
* /usr/cvs/icu4j/icu4j/src/com/ibm/icu/test/text/DanishCollatorTest.java,v $
|
||||
* $Date: 2001/03/09 23:41:46 $
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu4jni.test.text;
|
||||
|
||||
import java.util.Locale;
|
||||
import com.ibm.icu4jni.text.Collator;
|
||||
import com.ibm.icu4jni.text.CollationAttribute;
|
||||
|
||||
/**
|
||||
* Testing class for danish collator
|
||||
* Mostly following the test cases for ICU
|
||||
* @author Syn Wee Quek
|
||||
* @since jan 23 2001
|
||||
*/
|
||||
public final class DanishCollatorTest
|
||||
{
|
||||
|
||||
// constructor ===================================================
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public DanishCollatorTest(CollatorTest testprogram) throws Exception
|
||||
{
|
||||
m_test_ = testprogram;
|
||||
m_collator_ = Collator.getInstance(new Locale("da", "DK"));
|
||||
}
|
||||
|
||||
// public methods ================================================
|
||||
|
||||
/**
|
||||
* Test with primary collation strength
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestPrimary() throws Exception
|
||||
{
|
||||
m_collator_.setStrength(CollationAttribute.VALUE_PRIMARY);
|
||||
for (int i = 5; i < 8; i ++)
|
||||
m_test_.doTest(m_collator_, SOURCE_TEST_CASE_[i], TARGET_TEST_CASE_[i],
|
||||
EXPECTED_TEST_RESULT_[i]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test with tertiary collation strength
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestTertiary() throws Exception
|
||||
{
|
||||
m_collator_.setStrength(CollationAttribute.VALUE_TERTIARY);
|
||||
for (int i = 0; i < 5 ; i ++)
|
||||
m_test_.doTest(m_collator_, SOURCE_TEST_CASE_[i], TARGET_TEST_CASE_[i],
|
||||
EXPECTED_TEST_RESULT_[i]);
|
||||
|
||||
for (int i = 0; i < 53; i ++)
|
||||
for (int j = i + 1; j < 54; j ++)
|
||||
m_test_.doTest(m_collator_, BUGS_TEST_CASE_[i], BUGS_TEST_CASE_[i],
|
||||
Collator.RESULT_LESS);
|
||||
|
||||
for (int i = 0; i < 52; i ++)
|
||||
for (int j = i + 1; j < 53; j ++)
|
||||
m_test_.doTest(m_collator_, NT_TEST_CASE_[i],
|
||||
NT_TEST_CASE_[j], Collator.RESULT_LESS);
|
||||
}
|
||||
|
||||
// private variables =============================================
|
||||
|
||||
/**
|
||||
* RuleBasedCollator for testing
|
||||
*/
|
||||
private Collator m_collator_;
|
||||
|
||||
/**
|
||||
* Main Collation test program
|
||||
*/
|
||||
private CollatorTest m_test_;
|
||||
|
||||
/**
|
||||
* Source strings for testing
|
||||
*/
|
||||
private static final String SOURCE_TEST_CASE_[] =
|
||||
{
|
||||
"\u004c\u0075\u0063",
|
||||
"\u006c\u0075\u0063\u006b",
|
||||
"\u004c\u00FC\u0062\u0065\u0063\u006b",
|
||||
"\u004c\u00E4\u0076\u0069",
|
||||
"\u004c\u00F6\u0077\u0077",
|
||||
"\u004c\u0076\u0069",
|
||||
"\u004c\u00E4\u0076\u0069",
|
||||
"\u004c\u0000FC\u0062\u0065\u0063\u006b"
|
||||
};
|
||||
|
||||
/**
|
||||
* Target strings for testing
|
||||
*/
|
||||
private final String TARGET_TEST_CASE_[] =
|
||||
{
|
||||
"\u006c\u0075\u0063\u006b",
|
||||
"\u004c\u00FC\u0062\u0065\u0063\u006b",
|
||||
"\u006c\u0079\u0062\u0065\u0063\u006b",
|
||||
"\u004c\u00F6\u0077\u0065",
|
||||
"\u006d\u0061\u0073\u0074",
|
||||
"\u004c\u0077\u0069",
|
||||
"\u004c\u00F6\u0077\u0069",
|
||||
"\u004c\u0079\u0062\u0065\u0063\u006b"
|
||||
};
|
||||
|
||||
/**
|
||||
* Comparison result corresponding to above source and target cases
|
||||
*/
|
||||
private final int EXPECTED_TEST_RESULT_[] =
|
||||
{
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_EQUAL
|
||||
};
|
||||
|
||||
/**
|
||||
* Bug testing data set.
|
||||
* Internet data list.
|
||||
*/
|
||||
private final String BUGS_TEST_CASE_[] =
|
||||
{
|
||||
"\u0041\u002f\u0053",
|
||||
"\u0041\u004e\u0044\u0052\u0045",
|
||||
"\u0041\u004e\u0044\u0052\u00C9",
|
||||
"\u0041\u004e\u0044\u0052\u0045\u0041\u0053",
|
||||
"\u0041\u0053",
|
||||
"\u0043\u0041",
|
||||
"\u00C7\u0041",
|
||||
"\u0043\u0042",
|
||||
"\u00C7\u0043",
|
||||
"\u0044\u002e\u0053\u002e\u0042\u002e",
|
||||
"\u0044\u0041",
|
||||
"\u0044\u0042",
|
||||
"\u0044\u0053\u0042",
|
||||
"\u0044\u0053\u0043",
|
||||
"\u0045\u004b\u0053\u0054\u0052\u0041\u005f\u0041\u0052\u0042\u0045\u004a\u0044\u0045",
|
||||
"\u0045\u004b\u0053\u0054\u0052\u0041\u0042\u0055\u0044",
|
||||
"\u0048\u00D8\u0053\u0054", // could the \u00D8 be \u2205?
|
||||
"\u0048\u0041\u0041\u0047",
|
||||
"\u0048\u00C5\u004e\u0044\u0042\u004f\u0047",
|
||||
"\u0048\u0041\u0041\u004e\u0044\u0056\u0000C6\u0052\u004b\u0053\u0042\u0041\u004e\u004b\u0045\u004e",
|
||||
"\u006b\u0061\u0072\u006c",
|
||||
"\u004b\u0061\u0072\u006c",
|
||||
"\u004e\u0049\u0045\u004c\u0053\u0045\u004e",
|
||||
"\u004e\u0049\u0045\u004c\u0053\u0020\u004a\u00D8\u0052\u0047\u0045\u004e",
|
||||
"\u004e\u0049\u0045\u004c\u0053\u002d\u004a\u00D8\u0052\u0047\u0045\u004e",
|
||||
"\u0052\u00C9\u0045\u002c\u0020\u0041",
|
||||
"\u0052\u0045\u0045\u002c\u0020\u0042",
|
||||
"\u0052\u00C9\u0045\u002c\u0020\u004c",
|
||||
"\u0052\u0045\u0045\u002c\u0020\u0056",
|
||||
"\u0053\u0043\u0048\u0059\u0054\u0054\u002c\u0020\u0042",
|
||||
"\u0053\u0043\u0048\u0059\u0054\u0054\u002c\u0020\u0048",
|
||||
"\u0053\u0043\u0048\u00DC\u0054\u0054\u002c\u0020\u0048",
|
||||
"\u0053\u0043\u0048\u0059\u0054\u0054\u002c\u0020\u004c",
|
||||
"\u0053\u0043\u0048\u00DC\u0054\u0054\u002c\u0020\u004d",
|
||||
"\u0053\u0053",
|
||||
"\u00DF",
|
||||
"\u0053\u0053\u0041",
|
||||
"\u0053\u0054\u004f\u0052\u0045\u004b\u00C6\u0052",
|
||||
"\u0053\u0054\u004f\u0052\u0045\u0020\u0056\u0049\u004c\u0044\u004d\u004f\u0053\u0045",
|
||||
"\u0053\u0054\u004f\u0052\u004d\u004c\u0059",
|
||||
"\u0053\u0054\u004f\u0052\u004d\u0020\u0050\u0045\u0054\u0045\u0052\u0053\u0045\u004e",
|
||||
"\u0054\u0048\u004f\u0052\u0056\u0041\u004c\u0044",
|
||||
"\u0054\u0048\u004f\u0052\u0056\u0041\u0052\u0044\u0055\u0052",
|
||||
"\u00FE\u004f\u0052\u0056\u0041\u0052\u0110\u0055\u0052",
|
||||
"\u0054\u0048\u0059\u0047\u0045\u0053\u0045\u004e",
|
||||
"\u0056\u0045\u0053\u0054\u0045\u0052\u0047\u00C5\u0052\u0044\u002c\u0020\u0041",
|
||||
"\u0056\u0045\u0053\u0054\u0045\u0052\u0047\u0041\u0041\u0052\u0044\u002c\u0020\u0041",
|
||||
"\u0056\u0045\u0053\u0054\u0045\u0052\u0047\u00C5\u0052\u0044\u002c\u0020\u0042",
|
||||
"\u00C6\u0042\u004c\u0045",
|
||||
"\u00C4\u0042\u004c\u0045",
|
||||
"\u00D8\u0042\u0045\u0052\u0047",
|
||||
"\u00D6\u0042\u0045\u0052\u0047",
|
||||
"\u0110\u0041",
|
||||
"\u0110\u0043"
|
||||
};
|
||||
|
||||
/**
|
||||
* Data set for testing.
|
||||
* NT data list
|
||||
*/
|
||||
private final String NT_TEST_CASE_[] =
|
||||
{
|
||||
"\u0061\u006e\u0064\u0065\u0072\u0065",
|
||||
"\u0063\u0068\u0061\u0071\u0075\u0065",
|
||||
"\u0063\u0068\u0065\u006d\u0069\u006e",
|
||||
"\u0063\u006f\u0074\u0065",
|
||||
"\u0063\u006f\u0074\u00e9",
|
||||
"\u0063\u00f4\u0074\u0065",
|
||||
"\u0063\u00f4\u0074\u00e9",
|
||||
"\u010d\u0075\u010d\u0113\u0074",
|
||||
"\u0043\u007a\u0065\u0063\u0068",
|
||||
"\u0068\u0069\u0161\u0061",
|
||||
"\u0069\u0072\u0064\u0069\u0073\u0063\u0068",
|
||||
"\u006c\u0069\u0065",
|
||||
"\u006c\u0069\u0072\u0065",
|
||||
"\u006c\u006c\u0061\u006d\u0061",
|
||||
"\u006c\u00f5\u0075\u0067",
|
||||
"\u006c\u00f2\u007a\u0061",
|
||||
"\u006c\u0075\u010d",
|
||||
"\u006c\u0075\u0063\u006b",
|
||||
"\u004c\u00fc\u0062\u0065\u0063\u006b",
|
||||
"\u006c\u0079\u0065",
|
||||
"\u006c\u00e4\u0076\u0069",
|
||||
"\u004c\u00f6\u0077\u0065\u006e",
|
||||
"\u006d\u00e0\u0161\u0074\u0061",
|
||||
"\u006d\u00ee\u0072",
|
||||
"\u006d\u0079\u006e\u0064\u0069\u0067",
|
||||
"\u004d\u00e4\u006e\u006e\u0065\u0072",
|
||||
"\u006d\u00f6\u0063\u0068\u0074\u0065\u006e",
|
||||
"\u0070\u0069\u00f1\u0061",
|
||||
"\u0070\u0069\u006e\u0074",
|
||||
"\u0070\u0079\u006c\u006f\u006e",
|
||||
"\u0161\u00e0\u0072\u0061\u006e",
|
||||
"\u0073\u0061\u0076\u006f\u0069\u0072",
|
||||
"\u0160\u0065\u0072\u0062\u016b\u0072\u0061",
|
||||
"\u0053\u0069\u0065\u0074\u006c\u0061",
|
||||
"\u015b\u006c\u0075\u0062",
|
||||
"\u0073\u0075\u0062\u0074\u006c\u0065",
|
||||
"\u0073\u0079\u006d\u0062\u006f\u006c",
|
||||
"\u0073\u00e4\u006d\u0074\u006c\u0069\u0063\u0068",
|
||||
"\u0077\u0061\u0066\u0066\u006c\u0065",
|
||||
"\u0076\u0065\u0072\u006b\u0065\u0068\u0072\u0074",
|
||||
"\u0077\u006f\u006f\u0064",
|
||||
"\u0076\u006f\u0078",
|
||||
"\u0076\u00e4\u0067\u0061",
|
||||
"\u0079\u0065\u006e",
|
||||
"\u0079\u0075\u0061\u006e",
|
||||
"\u0079\u0075\u0063\u0063\u0061",
|
||||
"\u017e\u0061\u006c",
|
||||
"\u017e\u0065\u006e\u0061",
|
||||
"\u017d\u0065\u006e\u0113\u0076\u0061",
|
||||
"\u007a\u006f\u006f",
|
||||
"\u005a\u0076\u0069\u0065\u0064\u0072\u0069\u006a\u0061",
|
||||
"\u005a\u00fc\u0072\u0069\u0063\u0068",
|
||||
"\u007a\u0079\u0073\u006b",
|
||||
"\u00e4\u006e\u0064\u0065\u0072\u0065"
|
||||
};
|
||||
}
|
||||
|
|
@ -1,258 +0,0 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2000, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
* $Source:
|
||||
* /usr/cvs/icu4j/icu4j/src/com/ibm/icu/test/text/DummyCollatorTest.java,v $
|
||||
* $Date: 2001/03/09 23:41:46 $
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu4jni.test.text;
|
||||
|
||||
import java.util.Locale;
|
||||
import com.ibm.icu4jni.text.Collator;
|
||||
import com.ibm.icu4jni.text.CollationAttribute;
|
||||
|
||||
/**
|
||||
* Testing class for Dummy collator
|
||||
* Mostly following the test cases for ICU
|
||||
* @author Syn Wee Quek
|
||||
* @since jan 23 2001
|
||||
*/
|
||||
public final class DummyCollatorTest
|
||||
{
|
||||
|
||||
// constructor ===================================================
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public DummyCollatorTest(CollatorTest testprogram) throws Exception
|
||||
{
|
||||
m_test_ = testprogram;
|
||||
m_collator_ = Collator.getInstance(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
// public methods ================================================
|
||||
|
||||
/**
|
||||
* Test with primary collation strength
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestPrimary() throws Exception
|
||||
{
|
||||
m_collator_.setStrength(CollationAttribute.VALUE_PRIMARY);
|
||||
for (int i = 17; i < 26 ; i ++)
|
||||
m_test_.doTest(m_collator_, SOURCE_TEST_CASE_[i],
|
||||
TARGET_TEST_CASE_[i], EXPECTED_TEST_RESULT_[i]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test with secondary collation strength
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestSecondary() throws Exception
|
||||
{
|
||||
m_collator_.setStrength(CollationAttribute.VALUE_SECONDARY);
|
||||
for (int i = 26; i < 34 ; i ++)
|
||||
m_test_.doTest(m_collator_, SOURCE_TEST_CASE_[i], TARGET_TEST_CASE_[i],
|
||||
EXPECTED_TEST_RESULT_[i]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test with tertiary collation strength
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestTertiary() throws Exception
|
||||
{
|
||||
m_collator_.setStrength(CollationAttribute.VALUE_TERTIARY);
|
||||
for (int i = 0; i < 17 ; i ++)
|
||||
m_test_.doTest(m_collator_, SOURCE_TEST_CASE_[i], TARGET_TEST_CASE_[i],
|
||||
EXPECTED_TEST_RESULT_[i]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Miscellaneous test
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestMiscellaneous() throws Exception
|
||||
{
|
||||
m_collator_.setStrength(CollationAttribute.VALUE_TERTIARY);
|
||||
int size = MISCELLANEOUS_TEST_CASE_.length - 1;
|
||||
for (int i = 0; i < size; i ++)
|
||||
for (int j = i + 1; j < MISCELLANEOUS_TEST_CASE_.length; j ++)
|
||||
m_test_.doTest(m_collator_, MISCELLANEOUS_TEST_CASE_[i],
|
||||
MISCELLANEOUS_TEST_CASE_[j],
|
||||
Collator.RESULT_LESS);
|
||||
}
|
||||
|
||||
// private variables =============================================
|
||||
|
||||
/**
|
||||
* RuleBasedCollator for testing
|
||||
*/
|
||||
private Collator m_collator_;
|
||||
|
||||
/**
|
||||
* Main Collation test program
|
||||
*/
|
||||
private CollatorTest m_test_;
|
||||
|
||||
/**
|
||||
* Source test cases
|
||||
*/
|
||||
private final String SOURCE_TEST_CASE_[] =
|
||||
{
|
||||
"\u0061\u0062\u0027\u0063",
|
||||
"\u0063\u006f\u002d\u006f\u0070",
|
||||
"\u0061\u0062",
|
||||
"\u0061\u006d\u0070\u0065\u0072\u0073\u0061\u0064",
|
||||
"\u0061\u006c\u006c",
|
||||
"\u0066\u006f\u0075\u0072",
|
||||
"\u0066\u0069\u0076\u0065",
|
||||
"\u0031",
|
||||
"\u0031",
|
||||
"\u0031",
|
||||
"\u0032",
|
||||
"\u0032",
|
||||
"\u0048\u0065\u006c\u006c\u006f",
|
||||
"\u0061\u003c\u0062",
|
||||
"\u0061\u003c\u0062",
|
||||
"\u0061\u0063\u0063",
|
||||
"\u0061\u0063\u0048\u0063", // simple test
|
||||
"\u0070\u00EA\u0063\u0068\u0065",
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0061\u00E6\u0063",
|
||||
"\u0061\u0063\u0048\u0063", // primary test
|
||||
"\u0062\u006c\u0061\u0063\u006b",
|
||||
"\u0066\u006f\u0075\u0072",
|
||||
"\u0066\u0069\u0076\u0065",
|
||||
"\u0031",
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0061\u0062\u0063\u0048",
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0061\u0063\u0048\u0063",
|
||||
"\u0061\u0063\u0065\u0030",
|
||||
"\u0031\u0030",
|
||||
"\u0070\u00EA\u0030"
|
||||
};
|
||||
|
||||
/**
|
||||
* Target test cases
|
||||
*/
|
||||
private final String TARGET_TEST_CASE_[] =
|
||||
{
|
||||
"\u0061\u0062\u0063\u0027",
|
||||
"\u0043\u004f\u004f\u0050",
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0026",
|
||||
"\u0026",
|
||||
"\u0034",
|
||||
"\u0035",
|
||||
"\u006f\u006e\u0065",
|
||||
"\u006e\u006e\u0065",
|
||||
"\u0070\u006e\u0065",
|
||||
"\u0074\u0077\u006f",
|
||||
"\u0075\u0077\u006f",
|
||||
"\u0068\u0065\u006c\u006c\u004f",
|
||||
"\u0061\u003c\u003d\u0062",
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0061\u0043\u0048\u0063",
|
||||
"\u0061\u0043\u0048\u0063", // simple test
|
||||
"\u0070\u00E9\u0063\u0068\u00E9",
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0061\u0042\u0043",
|
||||
"\u0061\u0062\u0063\u0068",
|
||||
"\u0061\u0062\u0064",
|
||||
"\u00E4\u0062\u0063",
|
||||
"\u0061\u00C6\u0063",
|
||||
"\u0061\u0043\u0048\u0063", // primary test
|
||||
"\u0062\u006c\u0061\u0063\u006b\u002d\u0062\u0069\u0072\u0064",
|
||||
"\u0034",
|
||||
"\u0035",
|
||||
"\u006f\u006e\u0065",
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0061\u0042\u0063",
|
||||
"\u0061\u0062\u0063\u0068",
|
||||
"\u0061\u0062\u0064",
|
||||
"\u0061\u0043\u0048\u0063",
|
||||
"\u0061\u0063\u0065\u0030",
|
||||
"\u0031\u0030",
|
||||
"\u0070\u00EB\u0030"
|
||||
};
|
||||
|
||||
/**
|
||||
* Source test cases
|
||||
*/
|
||||
private final String MISCELLANEOUS_TEST_CASE_[] =
|
||||
{
|
||||
"\u0061",
|
||||
"\u0041",
|
||||
"\u00e4",
|
||||
"\u00c4",
|
||||
"\u0061\u0065",
|
||||
"\u0061\u0045",
|
||||
"\u0041\u0065",
|
||||
"\u0041\u0045",
|
||||
"\u00e6",
|
||||
"\u00c6",
|
||||
"\u0062",
|
||||
"\u0063",
|
||||
"\u007a"
|
||||
};
|
||||
|
||||
/**
|
||||
* Test result expected
|
||||
*/
|
||||
private final static int EXPECTED_TEST_RESULT_[] =
|
||||
{
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_LESS
|
||||
};
|
||||
}
|
||||
|
|
@ -1,363 +0,0 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2000, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
* $Source:
|
||||
* /usr/cvs/icu4j/icu4j/src/com/ibm/icu/test/text/EnglishCollatorTest.java,v $
|
||||
* $Date: 2001/03/09 23:41:46 $
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu4jni.test.text;
|
||||
|
||||
import java.util.Locale;
|
||||
import com.ibm.icu4jni.text.Collator;
|
||||
import com.ibm.icu4jni.text.CollationAttribute;
|
||||
|
||||
/**
|
||||
* Testing class for english collator
|
||||
* Mostly following the test cases for ICU
|
||||
* @author Syn Wee Quek
|
||||
* @since jan 23 2001
|
||||
*/
|
||||
public final class EnglishCollatorTest
|
||||
{
|
||||
|
||||
// constructor ===================================================
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public EnglishCollatorTest(CollatorTest testprogram) throws Exception
|
||||
{
|
||||
m_test_ = testprogram;
|
||||
m_collator_ = Collator.getInstance(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
// public methods ================================================
|
||||
|
||||
/**
|
||||
* Test with primary collation strength
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestPrimary() throws Exception
|
||||
{
|
||||
m_collator_.setStrength(CollationAttribute.VALUE_PRIMARY);
|
||||
for (int i = 38; i < 43 ; i ++)
|
||||
m_test_.doTest(m_collator_, SOURCE_TEST_CASE_[i],
|
||||
TARGET_TEST_CASE_[i], EXPECTED_TEST_RESULT_[i]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test with secondary collation strength
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestSecondary() throws Exception
|
||||
{
|
||||
m_collator_.setStrength(CollationAttribute.VALUE_SECONDARY);
|
||||
for (int i = 43; i < 49 ; i ++)
|
||||
m_test_.doTest(m_collator_, SOURCE_TEST_CASE_[i], TARGET_TEST_CASE_[i],
|
||||
EXPECTED_TEST_RESULT_[i]);
|
||||
|
||||
//test acute and grave ordering (compare to french collation)
|
||||
int expected;
|
||||
int size = ACUTE_TEST_CASE_.length / (ACUTE_TEST_CASE_[0].length());
|
||||
for (int i = 0; i < size; i ++)
|
||||
for (int j = 0; j < size; j ++)
|
||||
{
|
||||
if (i < j)
|
||||
expected = Collator.RESULT_LESS;
|
||||
else
|
||||
if (i == j)
|
||||
expected = Collator.RESULT_EQUAL;
|
||||
else // (i > j)
|
||||
expected = Collator.RESULT_GREATER;
|
||||
m_test_.doTest(m_collator_, ACUTE_TEST_CASE_[i], ACUTE_TEST_CASE_[j],
|
||||
expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test with tertiary collation strength
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestTertiary() throws Exception
|
||||
{
|
||||
m_collator_.setStrength(CollationAttribute.VALUE_TERTIARY);
|
||||
for (int i = 0; i < 38 ; i ++)
|
||||
m_test_.doTest(m_collator_, SOURCE_TEST_CASE_[i], TARGET_TEST_CASE_[i],
|
||||
EXPECTED_TEST_RESULT_[i]);
|
||||
|
||||
for (int i = 0; i < 10; i ++)
|
||||
for (int j = i + 1; j < 10; j ++)
|
||||
m_test_.doTest(m_collator_, BUGS_TEST_CASE_[i], BUGS_TEST_CASE_[j],
|
||||
Collator.RESULT_LESS);
|
||||
|
||||
//test more interesting cases
|
||||
int expected;
|
||||
int size = MISCELLANEOUS_TEST_CASE_.length;
|
||||
for (int i = 0; i < size; i ++)
|
||||
for (int j = 0; j < size; j ++)
|
||||
{
|
||||
if (i < j)
|
||||
expected = Collator.RESULT_LESS;
|
||||
else
|
||||
if (i == j)
|
||||
expected = Collator.RESULT_EQUAL;
|
||||
else // (i > j)
|
||||
expected = Collator.RESULT_GREATER;
|
||||
m_test_.doTest(m_collator_, MISCELLANEOUS_TEST_CASE_[i],
|
||||
MISCELLANEOUS_TEST_CASE_[j], expected);
|
||||
}
|
||||
}
|
||||
|
||||
// private variables =============================================
|
||||
|
||||
/**
|
||||
* RuleBasedCollator for testing
|
||||
*/
|
||||
private Collator m_collator_;
|
||||
|
||||
/**
|
||||
* Main Collation test program
|
||||
*/
|
||||
private CollatorTest m_test_;
|
||||
|
||||
/**
|
||||
* Source strings for testing
|
||||
*/
|
||||
private static final String SOURCE_TEST_CASE_[] =
|
||||
{
|
||||
"\u0061\00u62",
|
||||
"\u0062\u006c\u0061\u0063\u006b\u002d\u0062\u0069\u0072\u0064",
|
||||
"\u0062\u006c\u0061\u0063\u006b\u0020\u0062\u0069\u0072\u0064",
|
||||
"\u0062\u006c\u0061\u0063\u006b\u002d\u0062\u0069\u0072\u0064",
|
||||
"\u0048\u0065\u006c\u006c\u006f",
|
||||
"\u0041\u0042\u0043",
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0062\u006c\u0061\u0063\u006b\u0062\u0069\u0072\u0064",
|
||||
"\u0062\u006c\u0061\u0063\u006b\u002d\u0062\u0069\u0072\u0064",
|
||||
"\u0062\u006c\u0061\u0063\u006b\u002d\u0062\u0069\u0072\u0064",
|
||||
// 10
|
||||
"\u0070\u00EA\u0063\u0068\u0065",
|
||||
"\u0070\u00E9\u0063\u0068\u00E9",
|
||||
"\u00C4\u0042\u0308\u0043\u0308",
|
||||
"\u0061\u0308\u0062\u0063",
|
||||
"\u0070\u00E9\u0063\u0068\u0065\u0072",
|
||||
"\u0072\u006f\u006c\u0065\u0073",
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0041",
|
||||
"\u0041",
|
||||
"\u0061\u0062",
|
||||
// 20
|
||||
"\u0074\u0063\u006f\u006d\u0070\u0061\u0072\u0065\u0070\u006c\u0061\u0069\u006e",
|
||||
"\u0061\u0062",
|
||||
"\u0061\u0023\u0062",
|
||||
"\u0061\u0023\u0062",
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0041\u0062\u0063\u0064\u0061",
|
||||
"\u0061\u0062\u0063\u0064\u0061",
|
||||
"\u0061\u0062\u0063\u0064\u0061",
|
||||
"\u00E6\u0062\u0063\u0064\u0061",
|
||||
"\u00E4\u0062\u0063\u0064\u0061", // 30
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0061\u0063\u0048\u0063",
|
||||
"\u0061\u0308\u0062\u0063",
|
||||
"\u0074\u0068\u0069\u0302\u0073",
|
||||
"\u0070\u00EA\u0063\u0068\u0065",
|
||||
"\u0061\u0062\u0063", // 40
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0061\u00E6\u0063",
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0061\u00E6\u0063",
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0070\u00E9\u0063\u0068\u00E9" // 49
|
||||
};
|
||||
|
||||
/**
|
||||
* Target strings for testing
|
||||
*/
|
||||
private final String TARGET_TEST_CASE_[] =
|
||||
{
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0062\u006c\u0061\u0063\u006b\u0062\u0069\u0072\u0064",
|
||||
"\u0062\u006c\u0061\u0063\u006b\u002d\u0062\u0069\u0072\u0064",
|
||||
"\u0062\u006c\u0061\u0063\u006b",
|
||||
"\u0068\u0065\u006c\u006c\u006f",
|
||||
"\u0041\u0042\u0043",
|
||||
"\u0041\u0042\u0043",
|
||||
"\u0062\u006c\u0061\u0063\u006b\u0062\u0069\u0072\u0064\u0073",
|
||||
"\u0062\u006c\u0061\u0063\u006b\u0062\u0069\u0072\u0064\u0073",
|
||||
"\u0062\u006c\u0061\u0063\u006b\u0062\u0069\u0072\u0064", // 10
|
||||
"\u0070\u00E9\u0063\u0068\u00E9",
|
||||
"\u0070\u00E9\u0063\u0068\u0065\u0072",
|
||||
"\u00C4\u0042\u0308\u0043\u0308",
|
||||
"\u0041\u0308\u0062\u0063",
|
||||
"\u0070\u00E9\u0063\u0068\u0065",
|
||||
"\u0072\u006f\u0302\u006c\u0065",
|
||||
"\u0041\u00E1\u0063\u0064",
|
||||
"\u0041\u00E1\u0063\u0064",
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0061\u0062\u0063", // 20
|
||||
"\u0054\u0043\u006f\u006d\u0070\u0061\u0072\u0065\u0050\u006c\u0061\u0069\u006e",
|
||||
"\u0061\u0042\u0063",
|
||||
"\u0061\u0023\u0042",
|
||||
"\u0061\u0026\u0062",
|
||||
"\u0061\u0023\u0063",
|
||||
"\u0061\u0062\u0063\u0064\u0061",
|
||||
"\u00C4\u0062\u0063\u0064\u0061",
|
||||
"\u00E4\u0062\u0063\u0064\u0061",
|
||||
"\u00C4\u0062\u0063\u0064\u0061",
|
||||
"\u00C4\u0062\u0063\u0064\u0061", // 30
|
||||
"\u0061\u0062\u0023\u0063",
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0061\u0062\u003d\u0063",
|
||||
"\u0061\u0062\u0064",
|
||||
"\u00E4\u0062\u0063",
|
||||
"\u0061\u0043\u0048\u0063",
|
||||
"\u00E4\u0062\u0063",
|
||||
"\u0074\u0068\u00EE\u0073",
|
||||
"\u0070\u00E9\u0063\u0068\u00E9",
|
||||
"\u0061\u0042\u0043", // 40
|
||||
"\u0061\u0062\u0064",
|
||||
"\u00E4\u0062\u0063",
|
||||
"\u0061\u00C6\u0063",
|
||||
"\u0061\u0042\u0064",
|
||||
"\u00E4\u0062\u0063",
|
||||
"\u0061\u0000C6\u0063",
|
||||
"\u0061\u0042\u0064",
|
||||
"\u00E4\u0062\u0063",
|
||||
"\u0070\u00EA\u0063\u0068\u0065" // 49
|
||||
};
|
||||
|
||||
/**
|
||||
* Comparison result corresponding to above source and target cases
|
||||
*/
|
||||
private final int EXPECTED_TEST_RESULT_[] =
|
||||
{
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_GREATER, // 10
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS, // 20
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_GREATER,
|
||||
// Test Tertiary > 26
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_LESS, // 30
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS,
|
||||
// test identical > 36
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_EQUAL,
|
||||
// test primary > 38
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_EQUAL, // 40
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_EQUAL,
|
||||
// test secondary > 43
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS // 49
|
||||
};
|
||||
|
||||
/**
|
||||
* Bug testing data set
|
||||
*/
|
||||
private final String BUGS_TEST_CASE_[] =
|
||||
{
|
||||
"\u0061", "\u0041", "\u0065", "\u0045", "\u00e9",
|
||||
"\u00e8", "\u00ea", "\u00eb", "\u0065\u0061", "\u0078"
|
||||
};
|
||||
|
||||
/**
|
||||
* \u000300 is grave\u000301 is acute.
|
||||
* the order of elements in this array must be different than the order in
|
||||
* CollationFrenchTest.
|
||||
* Data set for testing accents.
|
||||
*/
|
||||
private final String ACUTE_TEST_CASE_[] =
|
||||
{
|
||||
"\u0065\u0065",
|
||||
"\u0065\u0065\u0301",
|
||||
"\u0065\u0065\u0301\u0300",
|
||||
"\u0065\u0065\u0300",
|
||||
"\u0065\u0065\u0300\u0301",
|
||||
"\u0065\u0301\u0065",
|
||||
"\u0065\u0301\u0065\u0301",
|
||||
"\u0065\u0301\u0065\u0301\u0300",
|
||||
"\u0065\u0301\u0065\u0300",
|
||||
"\u0065\u0301\u0065\u0300\u0301",
|
||||
"\u0065\u0301\u0300\u0065",
|
||||
"\u0065\u0301\u0300\u0065\u0301",
|
||||
"\u0065\u0301\u0300\u0065\u0301\u0300",
|
||||
"\u0065\u0301\u0300\u0065\u0300",
|
||||
"\u0065\u0301\u0300\u0065\u0300\u0301",
|
||||
"\u0065\u0300\u0065",
|
||||
"\u0065\u0300\u0065\u0301",
|
||||
"\u0065\u0300\u0065\u0301\u0300",
|
||||
"\u0065\u0300\u0065\u0300",
|
||||
"\u0065\u0300\u0065\u0300\u0301",
|
||||
"\u0065\u0300\u0301\u0065",
|
||||
"\u0065\u0300\u0301\u0065\u0301",
|
||||
"\u0065\u0300\u0301\u0065\u0301\u0300",
|
||||
"\u0065\u0300\u0301\u0065\u0300",
|
||||
"\u0065\u0300\u0301\u0065\u0300\u0301"
|
||||
};
|
||||
|
||||
/**
|
||||
* Miscellaneous tests
|
||||
*/
|
||||
private final static String MISCELLANEOUS_TEST_CASE_[] =
|
||||
{
|
||||
"\u0061\u0065",
|
||||
"\u00E6",
|
||||
"\u00C6",
|
||||
"\u0061\u0066",
|
||||
"\u006f\u0065",
|
||||
"\u0153",
|
||||
"\u0152",
|
||||
"\u006f\u0066",
|
||||
};
|
||||
}
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2000, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
* $Source:
|
||||
* /usr/cvs/icu4j/icu4j/src/com/ibm/icu/test/text/FinnishCollatorTest.java,v $
|
||||
* $Date: 2001/03/09 23:41:46 $
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu4jni.test.text;
|
||||
|
||||
import java.util.Locale;
|
||||
import com.ibm.icu4jni.text.Collator;
|
||||
import com.ibm.icu4jni.text.CollationAttribute;
|
||||
|
||||
/**
|
||||
* Testing class for Finnish collator
|
||||
* Mostly following the test cases for ICU
|
||||
* @author Syn Wee Quek
|
||||
* @since jan 23 2001
|
||||
*/
|
||||
public final class FinnishCollatorTest
|
||||
{
|
||||
|
||||
// constructor ===================================================
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public FinnishCollatorTest(CollatorTest testprogram) throws Exception
|
||||
{
|
||||
m_test_ = testprogram;
|
||||
m_collator_ = Collator.getInstance(new Locale("fi", "FI"));
|
||||
}
|
||||
|
||||
// public methods ================================================
|
||||
|
||||
/**
|
||||
* Test with primary collation strength
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestPrimary() throws Exception
|
||||
{
|
||||
m_collator_.setStrength(CollationAttribute.VALUE_PRIMARY);
|
||||
for (int i = 4; i < 5; i ++)
|
||||
m_test_.doTest(m_collator_, SOURCE_TEST_CASE_[i], TARGET_TEST_CASE_[i],
|
||||
EXPECTED_TEST_RESULT_[i]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test with tertiary collation strength
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestTertiary() throws Exception
|
||||
{
|
||||
m_collator_.setStrength(CollationAttribute.VALUE_TERTIARY);
|
||||
for (int i = 0; i < 4 ; i ++)
|
||||
m_test_.doTest(m_collator_, SOURCE_TEST_CASE_[i], TARGET_TEST_CASE_[i],
|
||||
EXPECTED_TEST_RESULT_[i]);
|
||||
}
|
||||
|
||||
// private variables =============================================
|
||||
|
||||
/**
|
||||
* RuleBasedCollator for testing
|
||||
*/
|
||||
private Collator m_collator_;
|
||||
|
||||
/**
|
||||
* Main Collation test program
|
||||
*/
|
||||
private CollatorTest m_test_;
|
||||
|
||||
/**
|
||||
* Source strings for testing
|
||||
*/
|
||||
private static final String SOURCE_TEST_CASE_[] =
|
||||
{
|
||||
"\u0077\u0061\u0074",
|
||||
"\u0076\u0061\u0074",
|
||||
"\u0061\u00FC\u0062\u0065\u0063\u006b",
|
||||
"\u004c\u00E5\u0076\u0069",
|
||||
"\u0077\u0061\u0074"
|
||||
};
|
||||
|
||||
/**
|
||||
* Target strings for testing
|
||||
*/
|
||||
private final String TARGET_TEST_CASE_[] =
|
||||
{
|
||||
"\u0076\u0061\u0074",
|
||||
"\u0077\u0061\u0079",
|
||||
"\u0061\u0078\u0062\u0065\u0063\u006b",
|
||||
"\u004c\u00E4\u0077\u0065",
|
||||
"\u0076\u0061\u0074"
|
||||
};
|
||||
|
||||
/**
|
||||
* Comparison result corresponding to above source and target cases
|
||||
*/
|
||||
private final int EXPECTED_TEST_RESULT_[] =
|
||||
{
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_EQUAL,
|
||||
};
|
||||
}
|
||||
|
|
@ -1,217 +0,0 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2000, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
* $Source:
|
||||
* /usr/cvs/icu4j/icu4j/src/com/ibm/icu/test/text/FrenchCollatorTest.java,v $
|
||||
* $Date: 2001/03/09 23:41:46 $
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu4jni.test.text;
|
||||
|
||||
import java.util.Locale;
|
||||
import com.ibm.icu4jni.text.Collator;
|
||||
import com.ibm.icu4jni.text.CollationAttribute;
|
||||
|
||||
/**
|
||||
* Testing class for french collator
|
||||
* Mostly following the test cases for ICU
|
||||
* @author Syn Wee Quek
|
||||
* @since jan 25 2001
|
||||
*/
|
||||
public final class FrenchCollatorTest
|
||||
{
|
||||
|
||||
// constructor ===================================================
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public FrenchCollatorTest(CollatorTest testprogram) throws Exception
|
||||
{
|
||||
m_test_ = testprogram;
|
||||
m_collator_ = Collator.getInstance(Locale.FRENCH);
|
||||
}
|
||||
|
||||
// public methods ================================================
|
||||
|
||||
/**
|
||||
* Test defined bugs
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestBugs() throws Exception
|
||||
{
|
||||
int jsize = BUGS_TEST_CASE_.length;
|
||||
int isize = jsize - 1;
|
||||
m_collator_.setStrength(CollationAttribute.VALUE_TERTIARY);
|
||||
for (int i = 0; i < isize; i ++)
|
||||
for (int j = i + 1; j < jsize; j ++)
|
||||
m_test_.doTest(m_collator_, BUGS_TEST_CASE_[i], BUGS_TEST_CASE_[j],
|
||||
Collator.RESULT_LESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test with secondary collation strength
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestSecondary() throws Exception
|
||||
{
|
||||
//test acute and grave ordering
|
||||
int expected;
|
||||
m_collator_.setStrength(CollationAttribute.VALUE_SECONDARY);
|
||||
int size = ACUTE_TEST_CASE_.length / (ACUTE_TEST_CASE_[0].length());
|
||||
for (int i = 0; i < size; i ++)
|
||||
for (int j = 0; j < size; j ++)
|
||||
{
|
||||
if (i < j)
|
||||
expected = Collator.RESULT_LESS;
|
||||
else
|
||||
if (i == j)
|
||||
expected = Collator.RESULT_EQUAL;
|
||||
else
|
||||
expected = Collator.RESULT_GREATER;
|
||||
m_test_.doTest(m_collator_, ACUTE_TEST_CASE_[i], ACUTE_TEST_CASE_[j],
|
||||
expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test with tertiary collation strength
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestTertiary() throws Exception
|
||||
{
|
||||
m_collator_.setStrength(CollationAttribute.VALUE_TERTIARY);
|
||||
int size = SOURCE_TEST_CASE_.length;
|
||||
for (int i = 0; i < size; i ++)
|
||||
m_test_.doTest(m_collator_, SOURCE_TEST_CASE_[i], TARGET_TEST_CASE_[i],
|
||||
EXPECTED_TEST_RESULT_[i]);
|
||||
}
|
||||
|
||||
// private variables =============================================
|
||||
|
||||
/**
|
||||
* RuleBasedCollator for testing
|
||||
*/
|
||||
private Collator m_collator_;
|
||||
|
||||
/**
|
||||
* Main Collation test program
|
||||
*/
|
||||
private CollatorTest m_test_;
|
||||
|
||||
/**
|
||||
* Source strings for testing
|
||||
*/
|
||||
private static final String SOURCE_TEST_CASE_[] =
|
||||
{
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0043\u004f\u0054\u0045",
|
||||
"\u0063\u006f\u002d\u006f\u0070",
|
||||
"\u0070\u00EA\u0063\u0068\u0065",
|
||||
"\u0070\u00EA\u0063\u0068\u0065\u0072",
|
||||
"\u0070\u00E9\u0063\u0068\u0065\u0072",
|
||||
"\u0070\u00E9\u0063\u0068\u0065\u0072",
|
||||
"\u0048\u0065\u006c\u006c\u006f",
|
||||
"\u01f1",
|
||||
"\ufb00",
|
||||
"\u01fa",
|
||||
"\u0101"
|
||||
};
|
||||
|
||||
/**
|
||||
* Target strings for testing
|
||||
*/
|
||||
private final String TARGET_TEST_CASE_[] =
|
||||
{
|
||||
"\u0041\u0042\u0043",
|
||||
"\00u63\u00f4\u0074\u0065",
|
||||
"\u0043\u004f\u004f\u0050",
|
||||
"\u0070\u00E9\u0063\u0068\u00E9",
|
||||
"\u0070\u00E9\u0063\u0068\u00E9",
|
||||
"\u0070\u00EA\u0063\u0068\u0065",
|
||||
"\u0070\u00EA\u0063\u0068\u0065\u0072",
|
||||
"\u0068\u0065\u006c\u006c\u004f",
|
||||
"\u01ee",
|
||||
"\u25ca",
|
||||
"\u00e0",
|
||||
"\u01df"
|
||||
};
|
||||
|
||||
/**
|
||||
* Comparison result corresponding to above source and target cases
|
||||
*/
|
||||
private final int EXPECTED_TEST_RESULT_[] =
|
||||
{
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS
|
||||
};
|
||||
|
||||
/**
|
||||
* Bug testing data set
|
||||
*/
|
||||
private final String BUGS_TEST_CASE_[] =
|
||||
{
|
||||
"\u0061",
|
||||
"\u0041",
|
||||
"\u0065",
|
||||
"\u0045",
|
||||
"\u00e9",
|
||||
"\u00e8",
|
||||
"\u00ea",
|
||||
"\u00eb",
|
||||
"\u0065\u0061",
|
||||
"\u0078"
|
||||
};
|
||||
|
||||
/**
|
||||
* \u000300 is grave\u000301 is acute.
|
||||
* the order of elements in this array must be different than the order in
|
||||
* CollationFrenchTest.
|
||||
* Data set for testing accents.
|
||||
*/
|
||||
private final String ACUTE_TEST_CASE_[] =
|
||||
{
|
||||
"\u0065\u0065",
|
||||
"\u0065\u0301\u0065",
|
||||
"\u0065\u0300\u0301\u0065",
|
||||
"\u0065\u0300\u0065",
|
||||
"\u0065\u0301\u0300\u0065",
|
||||
"\u0065\u0065\u0301",
|
||||
"\u0065\u0301\u0065\u0301",
|
||||
"\u0065\u0300\u0301\u0065\u0301",
|
||||
"\u0065\u0300\u0065\u0301",
|
||||
"\u0065\u0301\u0300\u0065\u0301",
|
||||
"\u0065\u0065\u0300\u0301",
|
||||
"\u0065\u0301\u0065\u0300\u0301",
|
||||
"\u0065\u0300\u0301\u0065\u0300\u0301",
|
||||
"\u0065\u0300\u0065\u0300\u0301",
|
||||
"\u0065\u0301\u0300\u0065\u0300\u0301",
|
||||
"\u0065\u0065\u0300",
|
||||
"\u0065\u0301\u0065\u0300",
|
||||
"\u0065\u0300\u0301\u0065\u0300",
|
||||
"\u0065\u0300\u0065\u0300",
|
||||
"\u0065\u0301\u0300\u0065\u0300",
|
||||
"\u0065\u0065\u0301\u0300",
|
||||
"\u0065\u0301\u0065\u0301\u0300",
|
||||
"\u0065\u0300\u0301\u0065\u0301\u0300",
|
||||
"\u0065\u0300\u0065\u0301\u0300",
|
||||
"\u0065\u0301\u0300\u0065\u0301\u0300"
|
||||
};
|
||||
}
|
||||
|
|
@ -1,241 +0,0 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2000, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
* $Source:
|
||||
* /usr/cvs/icu4j/icu4j/src/com/ibm/icu/test/text/G7CollatorTest.java,v $
|
||||
* $Date: 2001/03/09 23:41:46 $
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu4jni.test.text;
|
||||
|
||||
import java.util.Locale;
|
||||
import com.ibm.icu4jni.text.Collator;
|
||||
import com.ibm.icu4jni.text.RuleBasedCollator;
|
||||
|
||||
/**
|
||||
* Testing class for collation with 7 different locales
|
||||
* Mostly following the test cases for ICU
|
||||
* @author Syn Wee Quek
|
||||
* @since jan 23 2001
|
||||
*/
|
||||
public final class G7CollatorTest
|
||||
{
|
||||
|
||||
// constructor ===================================================
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public G7CollatorTest(CollatorTest testprogram) throws Exception
|
||||
{
|
||||
m_test_ = testprogram;
|
||||
//m_collator_ = Collator.getInstance(new Locale("tr", ""));
|
||||
}
|
||||
|
||||
// public methods ================================================
|
||||
|
||||
/**
|
||||
* Test with all 7 locales
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestLocales() throws Exception
|
||||
{
|
||||
RuleBasedCollator collator,
|
||||
testcollator;
|
||||
String rules;
|
||||
|
||||
for (int i = 0; i < LOCALES_.length; i ++)
|
||||
{
|
||||
collator = (RuleBasedCollator)Collator.getInstance(LOCALES_[i]);
|
||||
testcollator = new RuleBasedCollator(collator.getRules());
|
||||
|
||||
for (int j = 0; j < FIXED_TEST_COUNT_; j ++)
|
||||
for (int k = j + 1; j < FIXED_TEST_COUNT_; k ++)
|
||||
m_test_.doTest(testcollator,
|
||||
SOURCE_TEST_CASE_[EXPECTED_TEST_RESULT_[i][j]],
|
||||
SOURCE_TEST_CASE_[EXPECTED_TEST_RESULT_[i][k]],
|
||||
Collator.RESULT_LESS);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test default rules + addition rules.
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestRules1() throws Exception
|
||||
{
|
||||
Collator collator = Collator.getInstance();
|
||||
String rules = ((RuleBasedCollator)collator).getRules();
|
||||
String newrules = rules + " & Z < p, P";
|
||||
RuleBasedCollator newcollator = new RuleBasedCollator(newrules);
|
||||
|
||||
for (int j = 0; j < FIXED_TEST_COUNT_; j ++)
|
||||
for (int k = j + 1; k < FIXED_TEST_COUNT_; k ++)
|
||||
m_test_.doTest(newcollator,
|
||||
SOURCE_TEST_CASE_[EXPECTED_TEST_RESULT_[8][j]],
|
||||
SOURCE_TEST_CASE_[EXPECTED_TEST_RESULT_[8][k]],
|
||||
Collator.RESULT_LESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test default rules + addition rules.
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestRules2() throws Exception
|
||||
{
|
||||
Collator collator = Collator.getInstance();
|
||||
String rules = ((RuleBasedCollator)collator).getRules();
|
||||
String newrules = rules + "& C < ch , cH, Ch, CH";
|
||||
|
||||
RuleBasedCollator newcollator = new RuleBasedCollator(newrules);
|
||||
|
||||
for (int i = 0; i < TOTAL_TEST_COUNT_; i ++)
|
||||
for (int j = i + 1; j < TOTAL_TEST_COUNT_; j++)
|
||||
m_test_.doTest(newcollator,
|
||||
SOURCE_TEST_CASE_[EXPECTED_TEST_RESULT_[9][i]],
|
||||
SOURCE_TEST_CASE_[EXPECTED_TEST_RESULT_[9][j]],
|
||||
Collator.RESULT_LESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test default rules + addition rules.
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestRules3() throws Exception
|
||||
{
|
||||
Collator collator = Collator.getInstance();
|
||||
String rules = ((RuleBasedCollator)collator).getRules();
|
||||
String newrules = rules +
|
||||
"& Question'-'mark ; '?' & Hash'-'mark ; '#' & Ampersand ; '&'";
|
||||
|
||||
RuleBasedCollator newcollator = new RuleBasedCollator(newrules);
|
||||
|
||||
for (int i = 0; i < TOTAL_TEST_COUNT_; i ++)
|
||||
for (int j = i + 1; j < TOTAL_TEST_COUNT_; j++)
|
||||
m_test_.doTest(newcollator,
|
||||
SOURCE_TEST_CASE_[EXPECTED_TEST_RESULT_[10][i]],
|
||||
SOURCE_TEST_CASE_[EXPECTED_TEST_RESULT_[10][j]],
|
||||
Collator.RESULT_LESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test default rules + addition rules.
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestRules4() throws Exception
|
||||
{
|
||||
Collator collator = Collator.getInstance();
|
||||
String rules = ((RuleBasedCollator)collator).getRules();
|
||||
String newrules = rules +
|
||||
" & aa ; a'-' & ee ; e'-' & ii ; i'-' & oo ; o'-' & uu ; u'-' ";
|
||||
|
||||
RuleBasedCollator newcollator = new RuleBasedCollator(newrules);
|
||||
|
||||
for (int i = 0; i < TOTAL_TEST_COUNT_; i ++)
|
||||
for (int j = i + 1; j < TOTAL_TEST_COUNT_; j++)
|
||||
m_test_.doTest(newcollator,
|
||||
SOURCE_TEST_CASE_[EXPECTED_TEST_RESULT_[11][i]],
|
||||
SOURCE_TEST_CASE_[EXPECTED_TEST_RESULT_[11][j]],
|
||||
Collator.RESULT_LESS);
|
||||
}
|
||||
|
||||
// private variables =============================================
|
||||
|
||||
/**
|
||||
* Main Collation test program
|
||||
*/
|
||||
private CollatorTest m_test_;
|
||||
|
||||
/**
|
||||
* Constant test number
|
||||
*/
|
||||
private int FIXED_TEST_COUNT_ = 15;
|
||||
|
||||
/**
|
||||
* Constant test number
|
||||
*/
|
||||
private int TOTAL_TEST_COUNT_ = 30;
|
||||
|
||||
/**
|
||||
* List of 7 locales to be tested
|
||||
*/
|
||||
private final Locale LOCALES_[] = {Locale.US, Locale.UK, Locale.CANADA,
|
||||
Locale.FRANCE, Locale.CANADA_FRENCH,
|
||||
Locale.GERMAN, Locale.ITALY,
|
||||
Locale.JAPAN};
|
||||
|
||||
/**
|
||||
* Source strings for testing
|
||||
*/
|
||||
private static final String SOURCE_TEST_CASE_[] =
|
||||
{
|
||||
"\u0062\u006c\u0061\u0063\u006b\u002d\u0062\u0069\u0072\u0064\u0073",
|
||||
"\u0050\u0061\u0074",
|
||||
"\u0070\u00E9\u0063\u0068\u0000E9",
|
||||
"\u0070\u00EA\u0063\u0068\u0065",
|
||||
"\u0070\u00E9\u0063\u0068\u0065\u0072",
|
||||
"\u0070\u00EA\u0063\u0068\u0065\u0072",
|
||||
"\u0054\u006f\u0064",
|
||||
"\u0054\u00F6\u006e\u0065",
|
||||
"\u0054\u006f\u0066\u0075",
|
||||
"\u0062\u006c\u0061\u0063\u006b\u0062\u0069\u0072\u0064\u0073",
|
||||
"\u0054\u006f\u006e",
|
||||
"\u0050\u0041\u0054",
|
||||
"\u0062\u006c\u0061\u0063\u006b\u0062\u0069\u0072\u0064",
|
||||
"\u0062\u006c\u0061\u0063\u006b\u002d\u0062\u0069\u0072\u0064",
|
||||
"\u0070\u0061\u0074",
|
||||
"\u0063\u007a\u0061\u0072",
|
||||
"\u0063\u0068\u0075\u0072\u006f",
|
||||
"\u0063\u0061\u0074",
|
||||
"\u0064\u0061\u0072\u006e",
|
||||
"\u003f",
|
||||
"\u0071\u0075\u0069\u0063\u006b",
|
||||
"\u0023",
|
||||
"\u0026",
|
||||
"\u0061\u0061\u0072\u0064\u0076\u0061\u0072\u006b",
|
||||
"\u0061\u002d\u0072\u0064\u0076\u0061\u0072\u006b",
|
||||
"\u0061\u0062\u0062\u006f\u0074",
|
||||
"\u0063\u006f\u006f\u0070",
|
||||
"\u0063\u006f\u002d\u0070",
|
||||
"\u0063\u006f\u0070",
|
||||
"\u007a\u0065\u0062\u0072\u0061"
|
||||
};
|
||||
|
||||
/**
|
||||
* Comparison result corresponding to above source and target cases
|
||||
*/
|
||||
private final int EXPECTED_TEST_RESULT_[][] =
|
||||
{
|
||||
{12, 13, 9, 0, 14, 1, 11, 2, 3, 4, 5, 6, 8, 10, 7, 31, 31, 31, 31, 31,
|
||||
31, 31, 31, 31, 31, 31, 31, 31, 31, 31}, // en_US
|
||||
{12, 13, 9, 0, 14, 1, 11, 2, 3, 4, 5, 6, 8, 10, 7, 31, 31, 31, 31, 31,
|
||||
31, 31, 31, 31, 31, 31, 31, 31, 31, 31}, // en_GB
|
||||
{12, 13, 9, 0, 14, 1, 11, 2, 3, 4, 5, 6, 8, 10, 7, 31, 31, 31, 31, 31,
|
||||
31, 31, 31, 31, 31, 31, 31, 31, 31, 31}, // en_CA
|
||||
{12, 13, 9, 0, 14, 1, 11, 3, 2, 4, 5, 6, 8, 10, 7, 31, 31, 31, 31, 31,
|
||||
31, 31, 31, 31, 31, 31, 31, 31, 31, 31}, // fr_FR
|
||||
{12, 13, 9, 0, 14, 1, 11, 3, 2, 4, 5, 6, 8, 10, 7, 31, 31, 31, 31, 31,
|
||||
31, 31, 31, 31, 31, 31, 31, 31, 31, 31}, // fr_CA
|
||||
{12, 13, 9, 0, 14, 1, 11, 2, 3, 4, 5, 6, 8, 10, 7, 31, 31, 31, 31, 31,
|
||||
31, 31, 31, 31, 31, 31, 31, 31, 31, 31}, // de_DE
|
||||
{12, 13, 9, 0, 14, 1, 11, 2, 3, 4, 5, 6, 8, 10, 7, 31, 31, 31, 31, 31,
|
||||
31, 31, 31, 31, 31, 31, 31, 31, 31, 31}, // it_IT
|
||||
{12, 13, 9, 0, 14, 1, 11, 2, 3, 4, 5, 6, 8, 10, 7, 31, 31, 31, 31, 31,
|
||||
31, 31, 31, 31, 31, 31, 31, 31, 31, 31}, // ja_JP
|
||||
{12, 13, 9, 0, 6, 8, 10, 7, 14, 1, 11, 2, 3, 4, 5, 31, 31, 31, 31, 31,
|
||||
31, 31, 31, 31, 31, 31, 31, 31, 31, 31},
|
||||
{19, 22, 21, 23, 25, 24, 12, 13, 9, 0, 17, 26, 28, 27, 15, 16, 18, 14,
|
||||
1, 11, 2, 3, 4, 5, 20, 6, 8, 10, 7, 29},
|
||||
{23, 25, 22, 24, 12, 13, 9, 0, 17, 16, 26, 28, 27, 15, 18, 21, 14, 1,
|
||||
11, 2, 3, 4, 5, 19, 20, 6, 8, 10, 7, 29},
|
||||
{19, 22, 21, 23, 24, 25, 12, 13, 9, 0, 17, 16, 26, 27, 28, 15, 18, 14,
|
||||
1, 11, 2, 3, 4, 5, 20, 6, 8, 10, 7, 29}
|
||||
};
|
||||
}
|
||||
|
|
@ -1,136 +0,0 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2000, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
* $Source:
|
||||
* /usr/cvs/icu4j/icu4j/src/com/ibm/icu/test/text/GermanCollatorTest.java,v $
|
||||
* $Date: 2001/03/09 23:41:46 $
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu4jni.test.text;
|
||||
|
||||
import java.util.Locale;
|
||||
import com.ibm.icu4jni.text.Collator;
|
||||
import com.ibm.icu4jni.text.CollationAttribute;
|
||||
|
||||
/**
|
||||
* Testing class for german collator
|
||||
* Mostly following the test cases for ICU
|
||||
* @author Syn Wee Quek
|
||||
* @since jan 25 2001
|
||||
*/
|
||||
public final class GermanCollatorTest
|
||||
{
|
||||
|
||||
// constructor ===================================================
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public GermanCollatorTest(CollatorTest testprogram) throws Exception
|
||||
{
|
||||
m_test_ = testprogram;
|
||||
m_collator_ = Collator.getInstance(Locale.GERMAN);
|
||||
}
|
||||
|
||||
// public methods ================================================
|
||||
|
||||
/**
|
||||
* Test with primary collation strength
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestPrimary() throws Exception
|
||||
{
|
||||
m_collator_.setStrength(CollationAttribute.VALUE_PRIMARY);
|
||||
for (int i = 0; i < SOURCE_TEST_CASE_.length ; i++)
|
||||
m_test_.doTest(m_collator_, SOURCE_TEST_CASE_[i], TARGET_TEST_CASE_[i],
|
||||
EXPECTED_TEST_RESULT_[i][0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test with tertiary collation strength
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestTertiary() throws Exception
|
||||
{
|
||||
m_collator_.setStrength(CollationAttribute.VALUE_TERTIARY);
|
||||
for (int i = 0; i < 12 ; i++)
|
||||
m_test_.doTest(m_collator_, SOURCE_TEST_CASE_[i], TARGET_TEST_CASE_[i],
|
||||
EXPECTED_TEST_RESULT_[i][1]);
|
||||
}
|
||||
|
||||
// private variables =============================================
|
||||
|
||||
/**
|
||||
* RuleBasedCollator for testing
|
||||
*/
|
||||
private Collator m_collator_;
|
||||
|
||||
/**
|
||||
* Main Collation test program
|
||||
*/
|
||||
private CollatorTest m_test_;
|
||||
|
||||
/**
|
||||
* Source strings for testing
|
||||
*/
|
||||
private static final String SOURCE_TEST_CASE_[] =
|
||||
{
|
||||
"\u0047\u0072\u00F6\u00DF\u0065",
|
||||
"\u0061\u0062\u0063",
|
||||
"\u0054\u00F6\u006e\u0065",
|
||||
"\u0054\u00F6\u006e\u0065",
|
||||
"\u0054\u00F6\u006e\u0065",
|
||||
"\u0061\u0308\u0062\u0063",
|
||||
"\u00E4\u0062\u0063",
|
||||
"\u00E4\u0062\u0063",
|
||||
"\u0053\u0074\u0072\u0061\u00DF\u0065",
|
||||
"\u0065\u0066\u0067",
|
||||
"\u00E4\u0062\u0063",
|
||||
"\u0053\u0074\u0072\u0061\u00DF\u0065"
|
||||
};
|
||||
|
||||
/**
|
||||
* Target strings for testing
|
||||
*/
|
||||
private final String TARGET_TEST_CASE_[] =
|
||||
{
|
||||
"\u0047\u0072\u006f\u0073\u0073\u0069\u0073\u0074",
|
||||
"\u0061\u000308\u0062\u0063",
|
||||
"\u0054\u006f\u006e",
|
||||
"\u0054\u006f\u0064",
|
||||
"\u0054\u006f\u0066\u0075",
|
||||
"\u0041\u0308\u0062\u0063",
|
||||
"\u0061\u0308\u0062\u0063",
|
||||
"\u0061\u0065\u0062\u0063",
|
||||
"\u0053\u0074\u0072\u0061\u0073\u0073\u0065",
|
||||
"\u0065\u0066\u0067",
|
||||
"\u0061\u0065\u0062\u0063",
|
||||
"\u0053\u0074\u0072\u0061\u0073\u0073\u0065"
|
||||
};
|
||||
|
||||
/**
|
||||
* Comparison result corresponding to above source and target cases
|
||||
*/
|
||||
private final int EXPECTED_TEST_RESULT_[][] =
|
||||
{
|
||||
{Collator.RESULT_LESS, Collator.RESULT_LESS},
|
||||
{Collator.RESULT_EQUAL, Collator.RESULT_LESS},
|
||||
{Collator.RESULT_GREATER, Collator.RESULT_GREATER},
|
||||
{Collator.RESULT_GREATER, Collator.RESULT_GREATER},
|
||||
{Collator.RESULT_GREATER, Collator.RESULT_GREATER},
|
||||
{Collator.RESULT_EQUAL, Collator.RESULT_LESS},
|
||||
{Collator.RESULT_EQUAL, Collator.RESULT_EQUAL},
|
||||
{Collator.RESULT_LESS, Collator.RESULT_LESS},
|
||||
{Collator.RESULT_EQUAL, Collator.RESULT_GREATER},
|
||||
{Collator.RESULT_EQUAL, Collator.RESULT_EQUAL},
|
||||
{Collator.RESULT_LESS, Collator.RESULT_LESS},
|
||||
{Collator.RESULT_EQUAL, Collator.RESULT_GREATER}
|
||||
};
|
||||
}
|
||||
|
|
@ -1,123 +0,0 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2000, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
* $Source:
|
||||
* /usr/cvs/icu4j/icu4j/src/com/ibm/icu/test/text/KanaCollatorTest.java,v $
|
||||
* $Date: 2001/03/09 23:41:46 $
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu4jni.test.text;
|
||||
|
||||
import java.util.Locale;
|
||||
import com.ibm.icu4jni.text.Collator;
|
||||
import com.ibm.icu4jni.text.CollationAttribute;
|
||||
import com.ibm.icu4jni.text.NormalizationMode;
|
||||
|
||||
/**
|
||||
* Testing class for Kana collator
|
||||
* Mostly following the test cases for ICU
|
||||
* @author Syn Wee Quek
|
||||
* @since jan 23 2001
|
||||
*/
|
||||
public final class KanaCollatorTest
|
||||
{
|
||||
|
||||
// constructor ===================================================
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public KanaCollatorTest(CollatorTest testprogram) throws Exception
|
||||
{
|
||||
m_test_ = testprogram;
|
||||
m_collator_ = Collator.getInstance(Locale.JAPAN);
|
||||
m_collator_.setDecomposition(NormalizationMode.DECOMP_CAN);
|
||||
}
|
||||
|
||||
// public methods ================================================
|
||||
|
||||
/**
|
||||
* Test with tertiary collation strength
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestTertiary() throws Exception
|
||||
{
|
||||
m_collator_.setStrength(CollationAttribute.VALUE_TERTIARY);
|
||||
for (int i = 0; i < SOURCE_TEST_CASE_.length ; i ++)
|
||||
m_test_.doTest(m_collator_, SOURCE_TEST_CASE_[i], TARGET_TEST_CASE_[i],
|
||||
EXPECTED_TEST_RESULT_[i]);
|
||||
}
|
||||
|
||||
// private variables =============================================
|
||||
|
||||
/**
|
||||
* RuleBasedCollator for testing
|
||||
*/
|
||||
private Collator m_collator_;
|
||||
|
||||
/**
|
||||
* Main Collation test program
|
||||
*/
|
||||
private CollatorTest m_test_;
|
||||
|
||||
/**
|
||||
* Source strings for testing
|
||||
*/
|
||||
private static final String SOURCE_TEST_CASE_[] =
|
||||
{
|
||||
"\u0041\u0300\u0301",
|
||||
"\u0041\u0300\u0316",
|
||||
"\u0041\u0300",
|
||||
"\u00C0\u0301",
|
||||
"\u00C0\u0316",
|
||||
"\uff9E",
|
||||
"\u3042",
|
||||
"\u30A2",
|
||||
"\u3042\u3042",
|
||||
"\u30A2\u30FC",
|
||||
"\u30A2\u30FC\u30C8"
|
||||
};
|
||||
|
||||
/**
|
||||
* Target strings for testing
|
||||
*/
|
||||
private final String TARGET_TEST_CASE_[] =
|
||||
{
|
||||
"\u0041\u0301\u0300",
|
||||
"\u0041\u0316\u0300",
|
||||
"\u00C0",
|
||||
"\u0041\u0301\u0300",
|
||||
"\u0041\u0316\u0300",
|
||||
"\uFF9F",
|
||||
"\u30A2",
|
||||
"\u3042\u3042",
|
||||
"\u30A2\u30FC",
|
||||
"\u30A2\u30FC\u30C8",
|
||||
"\u3042\u3042\u3089"
|
||||
};
|
||||
|
||||
/**
|
||||
* Comparison result corresponding to above source and target cases
|
||||
*/
|
||||
private final int EXPECTED_TEST_RESULT_[] =
|
||||
{
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS
|
||||
};
|
||||
}
|
||||
|
|
@ -1,223 +0,0 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2000, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
* $Source:
|
||||
* /usr/cvs/icu4j/icu4j/src/com/ibm/icu/test/text/MonkeyCollatorTest.java,v $
|
||||
* $Date: 2001/03/09 23:41:46 $
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu4jni.test.text;
|
||||
|
||||
import java.util.Locale;
|
||||
import com.ibm.icu4jni.text.Collator;
|
||||
import com.ibm.icu4jni.text.RuleBasedCollator;
|
||||
import com.ibm.icu4jni.text.CollationKey;
|
||||
import com.ibm.icu4jni.text.CollationAttribute;
|
||||
|
||||
/**
|
||||
* Testing class for collation keys, comparison methods
|
||||
* Mostly following the test cases for ICU
|
||||
* @author Syn Wee Quek
|
||||
* @since jan 29 2001
|
||||
*/
|
||||
public final class MonkeyCollatorTest
|
||||
{
|
||||
|
||||
// constructor ===================================================
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public MonkeyCollatorTest(CollatorTest testprogram) throws Exception
|
||||
{
|
||||
m_test_ = testprogram;
|
||||
m_collator_ = Collator.getInstance();
|
||||
}
|
||||
|
||||
// public methods ================================================
|
||||
|
||||
/**
|
||||
* Testing collation keys
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestCollationKey() throws Exception
|
||||
{
|
||||
int s1 = (int)(Math.random() * SOURCE_TEST_CASE_.length());
|
||||
int t1 = (int)(Math.random() * SOURCE_TEST_CASE_.length());
|
||||
int s2 = (int)(Math.random() * SOURCE_TEST_CASE_.length());
|
||||
int t2 = (int)(Math.random() * SOURCE_TEST_CASE_.length());
|
||||
|
||||
String subs = SOURCE_TEST_CASE_.substring(Math.min(s1, s2),
|
||||
Math.max(s1, s2)),
|
||||
subt = SOURCE_TEST_CASE_.substring(Math.min(t1, 2),
|
||||
Math.max(t1, t2));
|
||||
|
||||
CollationKey ck1, ck2;
|
||||
m_collator_.setStrength(CollationAttribute.VALUE_TERTIARY);
|
||||
ck1 = m_collator_.getCollationKey(subs);
|
||||
ck2 = m_collator_.getCollationKey(subt);
|
||||
int result = ck1.compareTo(ck2); // Tertiary
|
||||
int revresult = ck2.compareTo(ck1) ; // Tertiary
|
||||
if (result != -revresult)
|
||||
{
|
||||
m_test_.errln("Failed : Round trip collation key comparison");
|
||||
return;
|
||||
}
|
||||
|
||||
m_collator_.setStrength(CollationAttribute.VALUE_SECONDARY);
|
||||
ck1 = m_collator_.getCollationKey(subs);
|
||||
ck2 = m_collator_.getCollationKey(subt);
|
||||
result = ck1.compareTo(ck2); // Secondary
|
||||
revresult = ck2.compareTo(ck1) ; // Secondary
|
||||
if (result != -revresult)
|
||||
{
|
||||
m_test_.errln("Failed : Round trip collation key comparison");
|
||||
return;
|
||||
}
|
||||
|
||||
m_collator_.setStrength(CollationAttribute.VALUE_PRIMARY);
|
||||
ck1 = m_collator_.getCollationKey(subs);
|
||||
ck2 = m_collator_.getCollationKey(subt);
|
||||
|
||||
result = ck1.compareTo(ck2); // Tertiary
|
||||
revresult = ck2.compareTo(ck1) ; // Tertiary
|
||||
|
||||
if (result != -revresult)
|
||||
{
|
||||
m_test_.errln("Failed : Round trip collation key comparison");
|
||||
return;
|
||||
}
|
||||
|
||||
String news = subs + "\uE000";
|
||||
ck1 = m_collator_.getCollationKey(subs);
|
||||
ck2 = m_collator_.getCollationKey(news);
|
||||
if (ck1.compareTo(ck2) != Collator.RESULT_LESS)
|
||||
{
|
||||
m_test_.errln("Failed : Collation key comparison of a string and " +
|
||||
"a similar string with an extra character is expected " +
|
||||
"to return a LESS");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ck2.compareTo(ck1) != Collator.RESULT_GREATER)
|
||||
{
|
||||
m_test_.errln("Failed : Collation key comparison of a string and " +
|
||||
"a similar string with one less character is expected " +
|
||||
"to return a GREATER");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test comparison methods
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestCompare() throws Exception
|
||||
{
|
||||
int s1 = (int)(Math.random() * SOURCE_TEST_CASE_.length());
|
||||
int t1 = (int)(Math.random() * SOURCE_TEST_CASE_.length());
|
||||
int s2 = (int)(Math.random() * SOURCE_TEST_CASE_.length());
|
||||
int t2 = (int)(Math.random() * SOURCE_TEST_CASE_.length());
|
||||
|
||||
String subs = SOURCE_TEST_CASE_.substring(Math.min(s1, s2),
|
||||
Math.max(s1, s2)),
|
||||
subt = SOURCE_TEST_CASE_.substring(Math.min(t1, 2),
|
||||
Math.max(t1, t2));
|
||||
|
||||
m_collator_.setStrength(CollationAttribute.VALUE_TERTIARY);
|
||||
int result = m_collator_.compare(subs, subt); // Tertiary
|
||||
int revresult = m_collator_.compare(subt, subs); // Tertiary
|
||||
if (result != -revresult)
|
||||
{
|
||||
m_test_.errln("Failed : Round trip collation key comparison");
|
||||
return;
|
||||
}
|
||||
|
||||
m_collator_.setStrength(CollationAttribute.VALUE_SECONDARY);
|
||||
result = m_collator_.compare(subs, subt); // Tertiary
|
||||
revresult = m_collator_.compare(subt, subs); // Tertiary
|
||||
if (result != -revresult)
|
||||
{
|
||||
m_test_.errln("Failed : Round trip collation key comparison");
|
||||
return;
|
||||
}
|
||||
|
||||
m_collator_.setStrength(CollationAttribute.VALUE_PRIMARY);
|
||||
result = m_collator_.compare(subs, subt); // Tertiary
|
||||
revresult = m_collator_.compare(subt, subs); // Tertiary
|
||||
if (result != -revresult)
|
||||
{
|
||||
m_test_.errln("Failed : Round trip collation key comparison");
|
||||
return;
|
||||
}
|
||||
|
||||
String news = subs + "\uE000";
|
||||
if (m_collator_.compare(subs, news) != Collator.RESULT_LESS)
|
||||
{
|
||||
m_test_.errln("Failed : Collation key comparison of a string and " +
|
||||
"a similar string with an extra character is expected " +
|
||||
"to return a LESS");
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_collator_.compare(news, subs) != Collator.RESULT_GREATER)
|
||||
{
|
||||
m_test_.errln("Failed : Collation key comparison of a string and " +
|
||||
"a similar string with one less character is expected " +
|
||||
"to return a GREATER");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test rules
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestRules() throws Exception
|
||||
{
|
||||
String source[] = {"\u0061\u0062\u007a", "\u0061\u0062\u007a"};
|
||||
String target[] = {"\u0061\u0062\u00e4", "\u0061\u0062\u0061\u0308"};
|
||||
|
||||
String rules = ((RuleBasedCollator)m_collator_).getRules();
|
||||
String newrules = rules + " & z < " + "\u00e4";
|
||||
|
||||
RuleBasedCollator collator = new RuleBasedCollator(newrules);
|
||||
|
||||
for (int i = 0; i < 2; i ++)
|
||||
m_test_.doTest(collator, source[i], target[i],
|
||||
Collator.RESULT_LESS);
|
||||
|
||||
newrules = rules + " & z < a" + "\u0308";
|
||||
|
||||
collator = new RuleBasedCollator(rules);
|
||||
|
||||
for (int i = 0; i < 2; i ++)
|
||||
m_test_.doTest(collator, source[i], target[i],
|
||||
Collator.RESULT_LESS);
|
||||
}
|
||||
|
||||
// private variables =============================================
|
||||
|
||||
/**
|
||||
* Main Collation test program
|
||||
*/
|
||||
private CollatorTest m_test_;
|
||||
|
||||
/**
|
||||
* Test collator
|
||||
*/
|
||||
private Collator m_collator_;
|
||||
|
||||
/**
|
||||
* Source string for testing
|
||||
*/
|
||||
private static final String SOURCE_TEST_CASE_ =
|
||||
"-abcdefghijklmnopqrstuvwxyz#&^$@";
|
||||
}
|
||||
|
|
@ -1,128 +0,0 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2000, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
* $Source:
|
||||
* /usr/cvs/icu4j/icu4j/src/com/ibm/icu/test/text/SpanishCollatorTest.java,v $
|
||||
* $Date: 2001/03/09 23:41:46 $
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu4jni.test.text;
|
||||
|
||||
import java.util.Locale;
|
||||
import com.ibm.icu4jni.text.Collator;
|
||||
import com.ibm.icu4jni.text.CollationKey;
|
||||
import com.ibm.icu4jni.text.CollationAttribute;
|
||||
|
||||
/**
|
||||
* Testing class for Spanish collator
|
||||
* Mostly following the test cases for ICU
|
||||
* @author Syn Wee Quek
|
||||
* @since jan 23 2001
|
||||
*/
|
||||
public final class SpanishCollatorTest
|
||||
{
|
||||
|
||||
// constructor ===================================================
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public SpanishCollatorTest(CollatorTest testprogram) throws Exception
|
||||
{
|
||||
m_test_ = testprogram;
|
||||
m_collator_ = Collator.getInstance(new Locale("es", "ES"));
|
||||
}
|
||||
|
||||
// public methods ================================================
|
||||
|
||||
/**
|
||||
* Test with primary collation strength
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestPrimary() throws Exception
|
||||
{
|
||||
m_collator_.setStrength(CollationAttribute.VALUE_PRIMARY);
|
||||
for (int i = 5; i < 9; i ++)
|
||||
m_test_.doTest(m_collator_, SOURCE_TEST_CASE_[i], TARGET_TEST_CASE_[i],
|
||||
EXPECTED_TEST_RESULT_[i]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test with tertiary collation strength
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestTertiary() throws Exception
|
||||
{
|
||||
m_collator_.setStrength(CollationAttribute.VALUE_TERTIARY);
|
||||
for (int i = 0; i < 5 ; i ++)
|
||||
m_test_.doTest(m_collator_, SOURCE_TEST_CASE_[i], TARGET_TEST_CASE_[i],
|
||||
EXPECTED_TEST_RESULT_[i]);
|
||||
}
|
||||
|
||||
// private variables =============================================
|
||||
|
||||
/**
|
||||
* RuleBasedCollator for testing
|
||||
*/
|
||||
private Collator m_collator_;
|
||||
|
||||
/**
|
||||
* Main Collation test program
|
||||
*/
|
||||
private CollatorTest m_test_;
|
||||
|
||||
/**
|
||||
* Source strings for testing
|
||||
*/
|
||||
private static final String SOURCE_TEST_CASE_[] =
|
||||
{
|
||||
"\u0061\u006c\u0069\u0061\u0073",
|
||||
"\u0045\u006c\u006c\u0069\u006f\u0074",
|
||||
"\u0048\u0065\u006c\u006c\u006f",
|
||||
"\u0061\u0063\u0048\u0063",
|
||||
"\u0061\u0063\u0063",
|
||||
"\u0061\u006c\u0069\u0061\u0073",
|
||||
"\u0061\u0063\u0048\u0063",
|
||||
"\u0061\u0063\u0063",
|
||||
"\u0048\u0065\u006c\u006c\u006f"
|
||||
};
|
||||
|
||||
/**
|
||||
* Target strings for testing
|
||||
*/
|
||||
private final String TARGET_TEST_CASE_[] =
|
||||
{
|
||||
"\u0061\u006c\u006c\u0069\u0061\u0073",
|
||||
"\u0045\u006d\u0069\u006f\u0074",
|
||||
"\u0068\u0065\u006c\u006c\u004f",
|
||||
"\u0061\u0043\u0048\u0063",
|
||||
"\u0061\u0043\u0048\u0063",
|
||||
"\u0061\u006c\u006c\u0069\u0061\u0073",
|
||||
"\u0061\u0043\u0048\u0063",
|
||||
"\u0061\u0043\u0048\u0063",
|
||||
"\u0068\u0065\u006c\u006c\u004f"
|
||||
};
|
||||
|
||||
/**
|
||||
* Comparison result corresponding to above source and target cases
|
||||
*/
|
||||
private final int EXPECTED_TEST_RESULT_[] =
|
||||
{
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_EQUAL
|
||||
};
|
||||
}
|
||||
|
|
@ -1,243 +0,0 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2000, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
* $Source:
|
||||
* /usr/cvs/icu4j/icu4j/src/com/ibm/icu/test/text/ThaiCollatorTest.java,v $
|
||||
* $Date: 2001/03/09 23:41:46 $
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu4jni.test.text;
|
||||
|
||||
import java.util.Locale;
|
||||
import com.ibm.icu4jni.text.Collator;
|
||||
import com.ibm.icu4jni.text.CollationKey;
|
||||
|
||||
/**
|
||||
* Testing class for Thai collator
|
||||
* Mostly following the test cases for ICU
|
||||
* @author Syn Wee Quek
|
||||
* @since jan 29 2001
|
||||
*/
|
||||
public final class ThaiCollatorTest
|
||||
{
|
||||
|
||||
// constructor ===================================================
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public ThaiCollatorTest(CollatorTest testprogram) throws Exception
|
||||
{
|
||||
m_test_ = testprogram;
|
||||
m_collator_ = Collator.getInstance(new Locale("th", "TH"));
|
||||
}
|
||||
|
||||
// public methods ================================================
|
||||
|
||||
/**
|
||||
* Test Thai strings.
|
||||
* Selective strings are taken out of th18057.txt from ICU for testing.
|
||||
* Every interval of a 1000 strings 5 consecutive ones are tested.
|
||||
* Strings are in sorted increasing order.
|
||||
* @exception thrown when error occurs
|
||||
*/
|
||||
public void TestStrings() throws Exception
|
||||
{
|
||||
String s,
|
||||
t;
|
||||
for (int i = 1; i < SOURCE_TEST_CASE_.length; i ++)
|
||||
{
|
||||
s = SOURCE_TEST_CASE_[i - 1];
|
||||
t = SOURCE_TEST_CASE_[i];
|
||||
if (m_collator_.compare(s, t) != Collator.RESULT_LESS)
|
||||
m_test_.errln("Failed : Thai strings are in sorted increasing order "
|
||||
+ s + " < " + t);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test odd corner conditions taken from "How to Sort Thai Without
|
||||
* Rewriting Sort", by Doug Cooper, http://seasrc.th.net/paper/thaisort.zip
|
||||
* @exception thrown when error occurs
|
||||
*/
|
||||
public void TestOddCase() throws Exception
|
||||
{
|
||||
String tests[] =
|
||||
{
|
||||
// Shorter words precede longer
|
||||
"\u0e01", "<", "\u0e01\u0e01",
|
||||
// Tone marks are considered after letters (i.e. are primary ignorable)
|
||||
"\u0e01\u0e32", "<", "\u0e01\u0e49\u0e32",
|
||||
// ditto for other over-marks
|
||||
"\u0e01\u0e32", "<", "\u0e01\u0e32\u0e4c",
|
||||
// commonly used mark-in-context order.
|
||||
// In effect, marks are sorted after each syllable.
|
||||
"\u0e01\u0e32\u0e01\u0e49\u0e32", "<",
|
||||
"\u0e01\u0e48\u0e32\u0e01\u0e49\u0e32",
|
||||
// Hyphens and other punctuation follow whitespace but come before
|
||||
// letters
|
||||
"\u0e01\u0e32", "<", "\u0e01\u0e32-",
|
||||
"\u0e01\u0e32-", "<", "\u0e01\u0e32\u0e01\u0e32",
|
||||
// Doubler follows an indentical word without the doubler
|
||||
"\u0e01\u0e32", "<", "\u0e01\u0e32\u0e46",
|
||||
"\u0e01\u0e32\u0e46", "<", "\u0e01\u0e32\u0e01\u0e32",
|
||||
// \u0e45 after either \u0e24 or \u0e26 is treated as a single
|
||||
// combining character, similar to "c < ch" in traditional spanish.
|
||||
"\u0e24\u0e29\u0e35", "<", "\u0e24\u0e45\u0e29\u0e35",
|
||||
"\u0e26\u0e29\u0e35", "<", "\u0e26\u0e45\u0e29\u0e35",
|
||||
// Vowels reorder, should compare \u0e2d and \u0e34
|
||||
"\u0e40\u0e01\u0e2d", "<", "\u0e40\u0e01\u0e34",
|
||||
// Tones are compared after the rest of the word
|
||||
// (e.g. primary ignorable)
|
||||
"\u0e01\u0e32\u0e01\u0e48\u0e32", "<", "\u0e01\u0e49\u0e32\u0e01\u0e32",
|
||||
// Periods are ignored entirely
|
||||
"\u0e01.\u0e01.", "<", "\u0e01\u0e32"
|
||||
};
|
||||
|
||||
for (int i = 0; i < tests.length; i += 3)
|
||||
{
|
||||
int expect = 0;
|
||||
if (tests[i + 1].equals("<"))
|
||||
expect = Collator.RESULT_LESS;
|
||||
else
|
||||
if (tests[i + 1].equals(">"))
|
||||
expect = Collator.RESULT_GREATER;
|
||||
else
|
||||
if (tests[i + 1].equals("="))
|
||||
expect = Collator.RESULT_EQUAL;
|
||||
else
|
||||
{
|
||||
// expect = Integer.decode(tests[i+1]).intValue();
|
||||
m_test_.errln("Failed : unknown operator " + tests[i + 1]);
|
||||
return;
|
||||
}
|
||||
|
||||
String s1 = tests[i],
|
||||
s2 = tests[i + 2];
|
||||
int result = m_collator_.compare(s1, s2);
|
||||
if (result != expect)
|
||||
m_test_.errln("Failed : " + s1 + tests[i + 1] + s2);
|
||||
else
|
||||
{
|
||||
// Collator.compare worked OK; now try the collation keys
|
||||
CollationKey k1 = m_collator_.getCollationKey(s1),
|
||||
k2 = m_collator_.getCollationKey(s2);
|
||||
result = k1.compareTo(k2);
|
||||
if (result != expect)
|
||||
m_test_.errln("Failed : Collation key comparison of " + s1 +
|
||||
tests[i + 1] + s2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// private variables =============================================
|
||||
|
||||
/**
|
||||
* RuleBasedCollator for testing
|
||||
*/
|
||||
private Collator m_collator_;
|
||||
|
||||
/**
|
||||
* Main Collation test program
|
||||
*/
|
||||
private CollatorTest m_test_;
|
||||
|
||||
/**
|
||||
* Source strings for testing
|
||||
*/
|
||||
private static final String SOURCE_TEST_CASE_[] =
|
||||
{
|
||||
"\u0e01\u0e24\u0e42\u0e28\u0e17\u0e23",
|
||||
"\u0e01\u0e24\u0e29\u0e0e\u0e32",
|
||||
"\u0e01\u0e24\u0e29\u0e0e\u0e32\u0e0d",
|
||||
"\u0e01\u0e24\u0e29\u0e0e\u0e32\u0e0d\u0e0a\u0e25\u0e34\u0e15",
|
||||
"\u0e01\u0e24\u0e29\u0e0e\u0e32\u0e0d\u0e0a\u0e25\u0e35",
|
||||
"\u0e01\u0e38\u0e25\u0e18\u0e23\u0e23\u0e21",
|
||||
"\u0e01\u0e38\u0e25\u0e18\u0e34\u0e14\u0e32",
|
||||
"\u0e01\u0e38\u0e25\u0e19\u0e32\u0e04",
|
||||
"\u0e01\u0e38\u0e25\u0e19\u0e32\u0e23\u0e35",
|
||||
"\u0e01\u0e38\u0e25\u0e19\u0e32\u0e28",
|
||||
"\u0e04\u0e25",
|
||||
"\u0e04\u0e25\u0e27\u0e07",
|
||||
"\u0e04\u0e25\u0e2d",
|
||||
"\u0e04\u0e25\u0e49\u0e2d",
|
||||
"\u0e04\u0e25\u0e2d\u0e01",
|
||||
"\u0e08\u0e49\u0e32\u0e25\u0e30\u0e2b\u0e27\u0e31\u0e48\u0e19",
|
||||
"\u0e08\u0e32\u0e27",
|
||||
"\u0e08\u0e48\u0e32\u0e27",
|
||||
"\u0e08\u0e49\u0e32\u0e27",
|
||||
"\u0e08\u0e48\u0e32\u0e2b\u0e27\u0e31\u0e01",
|
||||
"\u0e43\u0e0a\u0e48",
|
||||
"\u0e43\u0e0a\u0e49",
|
||||
"\u0e44\u0e0a",
|
||||
"\u0e44\u0e0a\u0e19\u0e30",
|
||||
"\u0e44\u0e0a\u0e22",
|
||||
"\u0e15\u0e31\u0e07\u0e42\u0e2d\u0e4b",
|
||||
"\u0e15\u0e31\u0e08\u0e09\u0e01",
|
||||
"\u0e15\u0e31\u0e08\u0e09\u0e19\u0e35",
|
||||
"\u0e15\u0e31\u0e13\u0e11\u0e38\u0e25",
|
||||
"\u0e15\u0e31\u0e13\u0e2b\u0e31\u0e01\u0e29\u0e31\u0e22",
|
||||
"\u0e40\u0e17\u0e34\u0e48\u0e07",
|
||||
"\u0e40\u0e17\u0e34\u0e07\u0e1a\u0e2d\u0e07",
|
||||
"\u0e40\u0e17\u0e34\u0e14",
|
||||
"\u0e40\u0e17\u0e34\u0e19",
|
||||
"\u0e40\u0e17\u0e34\u0e1a",
|
||||
"\u0e1a\u0e38\u0e01",
|
||||
"\u0e1a\u0e38\u0e04\u0e04\u0e25",
|
||||
"\u0e1a\u0e38\u0e04\u0e25\u0e32\u0e01\u0e23",
|
||||
"\u0e1a\u0e38\u0e04\u0e25\u0e32\u0e18\u0e34\u0e29\u0e10\u0e32\u0e19",
|
||||
"\u0e1a\u0e38\u0e04\u0e25\u0e34\u0e01",
|
||||
"\u0e1b\u0e31\u0e15\u0e16\u0e23",
|
||||
"\u0e1b\u0e31\u0e15\u0e16\u0e30",
|
||||
"\u0e1b\u0e31\u0e15\u0e19\u0e34",
|
||||
"\u0e1b\u0e31\u0e15\u0e19\u0e35",
|
||||
"\u0e1b\u0e31\u0e15\u0e22\u0e31\u0e22",
|
||||
"\u0e1e\u0e27\u0e19",
|
||||
"\u0e1e\u0e27\u0e22",
|
||||
"\u0e1e\u0e2a\u0e01",
|
||||
"\u0e1e\u0e2a\u0e19",
|
||||
"\u0e1e\u0e2a\u0e38",
|
||||
"\u0e21\u0e25\u0e48\u0e32\u0e27\u0e40\u0e21\u0e25\u0e32",
|
||||
"\u0e21\u0e25\u0e32\u0e2b\u0e23\u0e32",
|
||||
"\u0e21\u0e25\u0e34\u0e19",
|
||||
"\u0e21\u0e25\u0e34\u0e49\u0e19",
|
||||
"\u0e21\u0e25\u0e37\u0e48\u0e19",
|
||||
"\u0e40\u0e22\u0e0b\u0e39",
|
||||
"\u0e40\u0e22\u0e47\u0e14",
|
||||
"\u0e40\u0e22\u0e47\u0e19",
|
||||
"\u0e40\u0e22\u0e47\u0e19\u0e15\u0e32\u0e42\u0e1f",
|
||||
"\u0e40\u0e22\u0e47\u0e19\u0e40\u0e15\u0e32\u0e42\u0e1f",
|
||||
"\u0e25\u0e33\u0e40\u0e08\u0e35\u0e22\u0e01",
|
||||
"\u0e25\u0e33\u0e14\u0e27\u0e19",
|
||||
"\u0e25\u0e33\u0e14\u0e31\u0e1a",
|
||||
"\u0e25\u0e33\u0e19\u0e31\u0e01",
|
||||
"\u0e25\u0e33\u0e40\u0e19\u0e32",
|
||||
"\u0e44\u0e27\u0e11\u0e39\u0e23\u0e22\u0e4c",
|
||||
"\u0e44\u0e27\u0e17\u0e22\u0e4c",
|
||||
"\u0e44\u0e27\u0e1e\u0e08\u0e19\u0e4c",
|
||||
"\u0e44\u0e27\u0e22\u0e32\u0e01\u0e23\u0e13\u0e4c",
|
||||
"\u0e44\u0e27\u0e22\u0e32\u0e27\u0e31\u0e08\u0e01\u0e23",
|
||||
"\u0e2a\u0e31\u0e19\u0e1e\u0e23\u0e49\u0e32\u0e21\u0e2d\u0e0d",
|
||||
"\u0e2a\u0e31\u0e19\u0e1e\u0e23\u0e49\u0e32\u0e2b\u0e2d\u0e21",
|
||||
"\u0e2a\u0e31\u0e19\u0e23\u0e27\u0e07",
|
||||
"\u0e2a\u0e31\u0e19\u0e25\u0e36\u0e01",
|
||||
"\u0e2a\u0e31\u0e19\u0e2a\u0e01\u0e24\u0e15",
|
||||
"\u0e2b\u0e49\u0e27\u0e19",
|
||||
"\u0e2b\u0e27\u0e19\u0e04\u0e33\u0e19\u0e36\u0e07",
|
||||
"\u0e2b\u0e27\u0e22",
|
||||
"\u0e2b\u0e48\u0e27\u0e22",
|
||||
"\u0e2b\u0e49\u0e27\u0e22",
|
||||
"\u0e2d\u0e32\u0e19\u0e19",
|
||||
"\u0e2d\u0e32\u0e19\u0e19\u0e17\u0e4c",
|
||||
"\u0e2d\u0e32\u0e19\u0e30",
|
||||
"\u0e2d\u0e32\u0e19\u0e31\u0e19\u0e17\u0e4c",
|
||||
"\u0e2d\u0e32\u0e19\u0e31\u0e19\u0e17\u0e19\u0e30"
|
||||
};
|
||||
}
|
||||
|
|
@ -1,133 +0,0 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2000, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
* $Source:
|
||||
* /usr/cvs/icu4j/icu4j/src/com/ibm/icu/test/text/TurkishCollatorTest.java,v $
|
||||
* $Date: 2001/03/09 23:41:46 $
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu4jni.test.text;
|
||||
|
||||
import java.util.Locale;
|
||||
import com.ibm.icu4jni.text.Collator;
|
||||
import com.ibm.icu4jni.text.CollationAttribute;
|
||||
|
||||
/**
|
||||
* Testing class for Turkish collator
|
||||
* Mostly following the test cases for ICU
|
||||
* @author Syn Wee Quek
|
||||
* @since jan 23 2001
|
||||
*/
|
||||
public final class TurkishCollatorTest
|
||||
{
|
||||
|
||||
// constructor ===================================================
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public TurkishCollatorTest(CollatorTest testprogram) throws Exception
|
||||
{
|
||||
m_test_ = testprogram;
|
||||
m_collator_ = Collator.getInstance(new Locale("tr", ""));
|
||||
}
|
||||
|
||||
// public methods ================================================
|
||||
|
||||
/**
|
||||
* Test with primary collation strength
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestPrimary() throws Exception
|
||||
{
|
||||
m_collator_.setStrength(CollationAttribute.VALUE_PRIMARY);
|
||||
for (int i = 8; i < 11; i ++)
|
||||
m_test_.doTest(m_collator_, SOURCE_TEST_CASE_[i], TARGET_TEST_CASE_[i],
|
||||
EXPECTED_TEST_RESULT_[i]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test with tertiary collation strength
|
||||
* @exception thrown when error occurs while setting strength
|
||||
*/
|
||||
public void TestTertiary() throws Exception
|
||||
{
|
||||
m_collator_.setStrength(CollationAttribute.VALUE_TERTIARY);
|
||||
for (int i = 0; i < 8 ; i ++)
|
||||
m_test_.doTest(m_collator_, SOURCE_TEST_CASE_[i], TARGET_TEST_CASE_[i],
|
||||
EXPECTED_TEST_RESULT_[i]);
|
||||
}
|
||||
|
||||
// private variables =============================================
|
||||
|
||||
/**
|
||||
* RuleBasedCollator for testing
|
||||
*/
|
||||
private Collator m_collator_;
|
||||
|
||||
/**
|
||||
* Main Collation test program
|
||||
*/
|
||||
private CollatorTest m_test_;
|
||||
|
||||
/**
|
||||
* Source strings for testing
|
||||
*/
|
||||
private static final String SOURCE_TEST_CASE_[] =
|
||||
{
|
||||
"\u0073\u0327",
|
||||
"\u0076\u00E4\u0074",
|
||||
"\u006f\u006c\u0064",
|
||||
"\u00FC\u006f\u0069\u0064",
|
||||
"\u0068\u011E\u0061\u006c\u0074",
|
||||
"\u0073\u0074\u0072\u0065\u0073\u015E",
|
||||
"\u0076\u006f\u0131\u0064",
|
||||
"\u0069\u0064\u0065\u0061",
|
||||
"\u00FC\u006f\u0069\u0064",
|
||||
"\u0076\u006f\u0131\u0064",
|
||||
"\u0069\u0064\u0065\u0061"
|
||||
};
|
||||
|
||||
/**
|
||||
* Target strings for testing
|
||||
*/
|
||||
private final String TARGET_TEST_CASE_[] =
|
||||
{
|
||||
"\u0075\u0308",
|
||||
"\u0076\u0062\u0074",
|
||||
"\u00D6\u0061\u0079",
|
||||
"\u0076\u006f\u0069\u0064",
|
||||
"\u0068\u0061\u006c\u0074",
|
||||
"\u015E\u0074\u0072\u0065\u015E\u0073",
|
||||
"\u0076\u006f\u0069\u0064",
|
||||
"\u0049\u0064\u0065\u0061",
|
||||
"\u0076\u006f\u0069\u0064",
|
||||
"\u0076\u006f\u0069\u0064",
|
||||
"\u0049\u0064\u0065\u0061"
|
||||
};
|
||||
|
||||
/**
|
||||
* Comparison result corresponding to above source and target cases
|
||||
*/
|
||||
private final int EXPECTED_TEST_RESULT_[] =
|
||||
{
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_GREATER,
|
||||
Collator.RESULT_LESS,
|
||||
Collator.RESULT_EQUAL,
|
||||
Collator.RESULT_EQUAL
|
||||
};
|
||||
}
|
||||
|
Loading…
Add table
Reference in a new issue