code coverage updates and removal of redundant code

X-SVN-Rev: 9286
This commit is contained in:
Syn Wee Quek 2002-07-22 23:28:21 +00:00
parent 0e23352a30
commit 164838c4d0
4 changed files with 171 additions and 246 deletions

View file

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/test/TestAll.java,v $
* $Date: 2002/07/16 17:01:13 $
* $Revision: 1.29 $
* $Date: 2002/07/22 23:28:21 $
* $Revision: 1.30 $
*
*****************************************************************************************
*/
@ -123,6 +123,7 @@ public class TestAll extends TestFmwk {
new com.ibm.icu.dev.test.lang.UCharacterCaseTest(),
new com.ibm.icu.dev.test.lang.UCharacterIteratorTest(),
new com.ibm.icu.dev.test.lang.UCharacterCategoryTest(),
new com.ibm.icu.dev.test.lang.UCharacterDirectionTest(),
new com.ibm.icu.dev.test.lang.UTF16Test()
});
}
@ -189,4 +190,10 @@ public class TestAll extends TestFmwk {
new com.ibm.icu.dev.test.util.ICUServiceThreadTest()
});
}
public void TestVersionInfo() throws Exception {
run(new TestFmwk[] {
new com.ibm.icu.dev.test.util.VersionInfoTest()
});
}
}

View file

@ -24,8 +24,8 @@ import java.text.CharacterIterator;
public class CollationAPITest extends TestFmwk {
public static void main(String[] args) throws Exception {
new CollationAPITest().run(args);
// new CollationAPITest().TestDecomposition();
// new CollationAPITest().run(args);
new CollationAPITest().TestRuleBasedColl();
}
/**
@ -454,7 +454,8 @@ public class CollationAPITest extends TestFmwk {
String ruleset1 = "&9 < a, A < b, B < c, C; ch, cH, Ch, CH < d, D, e, E";
String ruleset2 = "&9 < a, A < b, B < c, C < d, D, e, E";
String ruleset3 = "&";
try {
col1 = new RuleBasedCollator(ruleset1);
} catch (Exception e) {
@ -469,6 +470,14 @@ public class CollationAPITest extends TestFmwk {
return;
}
try {
// empty rules fail
col3 = new RuleBasedCollator(ruleset3);
errln("Failure: Empty rules for the collator should fail");
return;
} catch (Exception e) {
}
Locale locale = new Locale("aa", "AA");
try {
col3 = (RuleBasedCollator)Collator.getInstance(locale);

View file

@ -6,8 +6,8 @@
*
* $Source:
* /usr/cvs/icu4j/icu4j/src/com/ibm/icu/text/UCharacterPropertyDB.java $
* $Date: 2002/07/22 20:41:10 $
* $Revision: 1.13 $
* $Date: 2002/07/22 23:28:21 $
* $Revision: 1.14 $
*
*******************************************************************************
*/
@ -144,22 +144,6 @@ public final class UCharacterProperty implements Trie.DataManipulate
public static final char LATIN_SMALL_LETTER_I_ = 0x69;
// public methods ----------------------------------------------------
/**
* toString method for printing
*/
public String toString()
{
StringBuffer result = new StringBuffer("Property block\n");
result.append(super.toString());
result.append("\nsize of property data ");
result.append(m_property_.length);
result.append("\nsize of exception data ");
result.append(m_exception_.length);
result.append("\nsize of case data ");
result.append(m_case_.length);
return result.toString();
}
/**
* Extracts out the type value from property.
@ -1304,7 +1288,8 @@ public final class UCharacterProperty implements Trie.DataManipulate
* @return 0 if names are equal, < 0 if name1 is less than name2 and > 0
* if name1 is greater than name2.
*/
public static int comparePropertyNames(String name1, String name2)
/* to be implemented in 2.4
* public static int comparePropertyNames(String name1, String name2)
{
int result = 0;
int i1 = 0;
@ -1317,7 +1302,7 @@ public final class UCharacterProperty implements Trie.DataManipulate
ch1 = name1.charAt(i1 ++);
}
while (ch1 == '-' || ch1 == '_' || ch1 == ' ' || ch1 == '\t'
|| ch1 == '\n' /* synwee what is || ch1 == '\v' */
|| ch1 == '\n' // synwee what is || ch1 == '\v'
|| ch1 == '\f' || ch1=='\r') {
if (i1 < name1.length()) {
ch1 = name1.charAt(i1 ++);
@ -1330,7 +1315,7 @@ public final class UCharacterProperty implements Trie.DataManipulate
ch2 = name2.charAt(i2 ++);
}
while (ch2 == '-' || ch2 == '_' || ch2 == ' ' || ch2 == '\t'
|| ch2 == '\n' /* synwee what is || ch1 == '\v' */
|| ch2 == '\n' // synwee what is || ch1 == '\v'
|| ch2 == '\f' || ch2=='\r') {
if (i2 < name2.length()) {
ch2 = name2.charAt(i2 ++);
@ -1355,6 +1340,7 @@ public final class UCharacterProperty implements Trie.DataManipulate
}
}
}
*/
/**
* Checks if the argument c is to be treated as a white space in ICU
@ -1719,25 +1705,6 @@ public final class UCharacterProperty implements Trie.DataManipulate
// private methods -------------------------------------------------------
/**
* <p>Sets a codepoint to the argument char array.</p>
* <p>This method does not bother to check the validity of the codepoint</p>
* @param target char array to be set with the new code point
* @param char32 code point
* @return the size of the codepoint
*/
private static int setCodePoint(char[] target, int char32)
{
// Write the UTF-16 values
if (char32 >= UTF16.SUPPLEMENTARY_MIN_VALUE) {
target[0] = UTF16.getLeadSurrogate(char32);
target[1] = UTF16.getTrailSurrogate(char32);
return 2;
}
target[0] = (char)char32;
return 1;
}
/**
* <p>Returns a value indicating a code point's Unicode category.</p>
* <p>This method does not check for the codepoint validity</p>
@ -1833,38 +1800,6 @@ public final class UCharacterProperty implements Trie.DataManipulate
return false; // not preceded by TYPE_i
}
/**
* Determines if a string at offset is preceded by base characters 'I' with
* no intervening combining class = 230
* @param uchariter text iterator to be determined
* @param offset offset in string to check
* @return true if some characters preceding the offset index is the
* character 'I' with no intervening combining class = 230
* @see SpecialCasing.txt
*/
private static boolean isAFTER_I(UnicodeCharacterIterator uchariter, int offset)
{
uchariter.setIndex(offset);
int ch = uchariter.previousCodePoint();
while (ch != UnicodeCharacterIterator.DONE_CODEPOINT) {
if (ch == LATIN_CAPITAL_LETTER_I_) {
return true; // preceded by I
}
int cc = NormalizerImpl.getCombiningClass(ch);
if (cc == 0 || cc == COMBINING_MARK_ABOVE_CLASS_) {
// preceded by different base character (not I), or
// intervening cc == 230
return false;
}
ch = uchariter.previousCodePoint();
}
return false; // not preceded by I
}
/**
* Determines if codepoint at offset is not followed by a sequence

View file

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/lang/Attic/UCharacterUtil.java,v $
* $Date: 2002/04/03 04:32:00 $
* $Revision: 1.5 $
* $Date: 2002/07/22 23:28:21 $
* $Revision: 1.6 $
*
*******************************************************************************
*/
@ -21,182 +21,156 @@ package com.ibm.icu.lang;
final class UCharacterUtil
{
// constructor =====================================================
/**
* private constructor to avoid initialisation
*/
private UCharacterUtil()
{
}
// protected methods ===============================================
/**
* joining 2 chars to form an int
* @param msc most significant char
* @param lsc least significant char
* @return int form
*/
protected static int toInt(char msc, char lsc)
{
return ((msc << 16) | lsc);
}
/**
* converting 2 bytes into a char
* @param msb the most significant byte
* @param lsb the least significant byte
* @return char form
*/
protected static char toChar(byte msb, byte lsb)
{
return (char)((msb << 8) | (lsb & 0xFF));
}
/**
* Retrieves a null terminated substring from an array of bytes.
* Substring is a set of non-zero bytes starting from argument start to the
* next zero byte. If the first byte is a zero, the next byte will be taken as
* the first byte.
* @param str stringbuffer to store data in, data will be store with each
* byte as a char
* @param array byte array
* @param index to start substring in byte count
* @return the end position of the substring within the character array
*/
protected static int getNullTermByteSubString(StringBuffer str, byte[] array,
int index)
{
byte b = 1;
while (b != 0)
// constructor =====================================================
/**
* private constructor to avoid initialisation
*/
private UCharacterUtil()
{
b = array[index];
if (b != 0) {
str.append((char)(b & 0x00FF));
}
index ++;
}
return index;
}
/**
* Compares a null terminated substring from an array of bytes.
* Substring is a set of non-zero bytes starting from argument start to the
* next zero byte. if the first byte is a zero, the next byte will be taken as
* the first byte.
* @param str string to compare
* @param array byte array
* @param strindex index within str to start comparing
* @param aindex array index to start in byte count
* @return the end position of the substring within str if matches otherwise
* a -1
*/
protected static int compareNullTermByteSubString(String str, byte[] array,
int strindex, int aindex)
{
byte b = 1;
int length = str.length();
while (b != 0)
// protected methods ===============================================
/**
* joining 2 chars to form an int
* @param msc most significant char
* @param lsc least significant char
* @return int form
*/
protected static int toInt(char msc, char lsc)
{
b = array[aindex];
aindex ++;
if (b == 0) {
break;
}
// if we have reached the end of the string and yet the array has not
// reached the end of their substring yet, abort
if (strindex == length || (str.charAt(strindex) != (char)(b & 0xFF))) {
return -1;
}
strindex ++;
return ((msc << 16) | lsc);
}
return strindex;
}
/**
* Skip null terminated substrings from an array of bytes.
* Substring is a set of non-zero bytes starting from argument start to the
* next zero byte. If the first byte is a zero, the next byte will be taken as
* the first byte.
* @param array byte array
* @param index to start substrings in byte count
* @param skipcount number of null terminated substrings to skip
* @return the end position of the substrings within the character array
*/
protected static int skipNullTermByteSubString(byte[] array, int index,
int skipcount)
{
byte b;
for (int i = 0; i < skipcount; i ++)
/**
* converting 2 bytes into a char
* @param msb the most significant byte
* @param lsb the least significant byte
* @return char form
*/
protected static char toChar(byte msb, byte lsb)
{
b = 1;
while (b != 0)
{
b = array[index];
index ++;
}
return (char)((msb << 8) | (lsb & 0xFF));
}
return index;
}
/**
* skip substrings from an array of characters, where each character is a set
* of 2 bytes. substring is a set of non-zero bytes starting from argument
* start to the byte of the argument value. skips up to a max number of
* characters
* @param array byte array to parse
* @param index to start substrings in byte count
* @param length the max number of bytes to skip
* @param skipend value of byte to skip to
* @return the number of bytes skipped
*/
protected static int skipByteSubString(byte[] array, int index, int length,
byte skipend)
{
int result;
byte b;
for (result = 0; result < length; result ++)
/**
* Retrieves a null terminated substring from an array of bytes.
* Substring is a set of non-zero bytes starting from argument start to the
* next zero byte. If the first byte is a zero, the next byte will be taken as
* the first byte.
* @param str stringbuffer to store data in, data will be store with each
* byte as a char
* @param array byte array
* @param index to start substring in byte count
* @return the end position of the substring within the character array
*/
protected static int getNullTermByteSubString(StringBuffer str, byte[] array,
int index)
{
b = array[index + result];
if (b == skipend)
{
result ++;
break;
}
byte b = 1;
while (b != 0)
{
b = array[index];
if (b != 0) {
str.append((char)(b & 0x00FF));
}
index ++;
}
return index;
}
return result;
}
/**
* skip substrings from an array of characters, where each character is a set
* of 2 bytes. substring is a set of non-zero bytes starting from argument
* start to the byte of the argument value.
* @param array byte array to parse
* @param index to start substrings in byte count
* @param skipend value of byte to skip to
* @return the number of bytes skipped
*/
protected static int skipByteSubString(byte[] array, int index, byte skipend)
{
int result = 0;
byte b;
while (true)
/**
* Compares a null terminated substring from an array of bytes.
* Substring is a set of non-zero bytes starting from argument start to the
* next zero byte. if the first byte is a zero, the next byte will be taken as
* the first byte.
* @param str string to compare
* @param array byte array
* @param strindex index within str to start comparing
* @param aindex array index to start in byte count
* @return the end position of the substring within str if matches otherwise
* a -1
*/
protected static int compareNullTermByteSubString(String str, byte[] array,
int strindex, int aindex)
{
b = array[index + result];
result ++;
if (b == skipend) {
break;
}
byte b = 1;
int length = str.length();
while (b != 0)
{
b = array[aindex];
aindex ++;
if (b == 0) {
break;
}
// if we have reached the end of the string and yet the array has not
// reached the end of their substring yet, abort
if (strindex == length
|| (str.charAt(strindex) != (char)(b & 0xFF))) {
return -1;
}
strindex ++;
}
return strindex;
}
/**
* Skip null terminated substrings from an array of bytes.
* Substring is a set of non-zero bytes starting from argument start to the
* next zero byte. If the first byte is a zero, the next byte will be taken as
* the first byte.
* @param array byte array
* @param index to start substrings in byte count
* @param skipcount number of null terminated substrings to skip
* @return the end position of the substrings within the character array
*/
protected static int skipNullTermByteSubString(byte[] array, int index,
int skipcount)
{
byte b;
for (int i = 0; i < skipcount; i ++)
{
b = 1;
while (b != 0)
{
b = array[index];
index ++;
}
}
return index;
}
/**
* skip substrings from an array of characters, where each character is a set
* of 2 bytes. substring is a set of non-zero bytes starting from argument
* start to the byte of the argument value. skips up to a max number of
* characters
* @param array byte array to parse
* @param index to start substrings in byte count
* @param length the max number of bytes to skip
* @param skipend value of byte to skip to
* @return the number of bytes skipped
*/
protected static int skipByteSubString(byte[] array, int index, int length,
byte skipend)
{
int result;
byte b;
for (result = 0; result < length; result ++)
{
b = array[index + result];
if (b == skipend)
{
result ++;
break;
}
}
return result;
}
return result;
}
}