code coverage tests update
comments updated
and clean up.

X-SVN-Rev: 8356
This commit is contained in:
Syn Wee Quek 2002-04-03 04:32:00 +00:00
parent 78cf8067b7
commit efaab43afc
6 changed files with 940 additions and 738 deletions

View File

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/test/TestAll.java,v $
* $Date: 2002/03/15 02:13:10 $
* $Revision: 1.24 $
* $Date: 2002/04/03 04:31:59 $
* $Revision: 1.25 $
*
*****************************************************************************************
*/
@ -108,6 +108,8 @@ public class TestAll extends TestFmwk {
run(new TestFmwk[] {
new com.ibm.icu.dev.test.lang.UCharacterTest(),
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.UTF16Test()
});
}

View File

@ -0,0 +1,95 @@
/**
*******************************************************************************
* Copyright (C) 1996-2001, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*
* $Source:
* /usr/cvs/icu4j/icu4j/src/com/ibm/icu/text/UCharacterCategory.java $
* $Date: 2002/04/03 04:32:00 $
* $Revision: 1.1 $
*
*******************************************************************************
*/
package com.ibm.icu.dev.test.lang;
import com.ibm.icu.dev.test.TestFmwk;
import com.ibm.icu.dev.test.TestUtil;
import com.ibm.icu.lang.UCharacterCategory;
/**
* Testing UCharacterCategory
* @author Syn Wee Quek
* @since April 02 2002
*/
public class UCharacterCategoryTest extends TestFmwk
{
// constructor -----------------------------------------------------------
/**
* Private constructor to prevent initialisation
*/
public UCharacterCategoryTest()
{
}
// public methods --------------------------------------------------------
public static void main(String[] arg)
{
try
{
UCharacterCategoryTest test = new UCharacterCategoryTest();
test.run(arg);
}
catch (Exception e)
{
e.printStackTrace();
}
}
/**
* Gets the name of the argument category
* @param category to retrieve name
* @return category name
*/
public void TestToString()
{
String name[] = {"Unassigned",
"Letter, Uppercase",
"Letter, Lowercase",
"Letter, Titlecase",
"Letter, Modifier",
"Letter, Other",
"Mark, Non-Spacing",
"Mark, Enclosing",
"Mark, Spacing Combining",
"Number, Decimal Digit",
"Number, Letter",
"Number, Other",
"Separator, Space",
"Separator, Line",
"Separator, Paragraph",
"Other, Control",
"Other, Format",
"Other, Private Use",
"Other, Surrogate",
"Punctuation, Dash",
"Punctuation, Open",
"Punctuation, Close",
"Punctuation, Connector",
"Punctuation, Other",
"Symbol, Math",
"Symbol, Currency",
"Symbol, Modifier",
"Symbol, Other",
"Punctuation, Initial quote",
"Punctuation, Final quote"};
for (int i = UCharacterCategory.UNASSIGNED;
i < UCharacterCategory.CHAR_CATEGORY_COUNT; i ++) {
if (!UCharacterCategory.toString(i).equals(name[i])) {
errln("Error toString for category " + i + " expected " +
name[i]);
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/lang/UCharacter.java,v $
* $Date: 2002/03/20 05:11:15 $
* $Revision: 1.35 $
* $Date: 2002/04/03 04:32:00 $
* $Revision: 1.36 $
*
*******************************************************************************
*/
@ -184,7 +184,7 @@ public final class UCharacter
}
/**
* Returns the Unicode numeric value of the code point as a nonnegative
* Returns the numeric value of the code point as a nonnegative
* integer.
* <br>If the code point does not have a numeric value, then -1 is returned.
* <br>
@ -993,13 +993,12 @@ public final class UCharacter
}
/**
* Returns a code pointcorresponding to the two UTF16 characters.
* If the argument lead is not a high surrogate character or trail is not a
* low surrogate character, UCharacter.REPLACEMENT_CHAR is returned.
* Returns a code point corresponding to the two UTF16 characters.
* @param lead the lead char
* @param trail the trail char
* @return code point or UCharacter.REPLACEMENT_CHAR if surrogate characters
* are invalid.
* @return code point if surrogate characters are valid.
* @exception IllegalArgumentException thrown when argument characters do
* not form a valid codepoint
*/
public static int getCodePoint(char lead, char trail)
{
@ -1009,16 +1008,13 @@ public final class UCharacter
trail <= UTF16.TRAIL_SURROGATE_MAX_VALUE) {
return UCharacterProperty.getRawSupplementary(lead, trail);
}
return UCharacter.REPLACEMENT_CHAR;
throw new IllegalArgumentException("Illegal surrogate characters");
}
/**
* Returns the code point corresponding to the UTF16 character.
* If argument char16 is a surrogate character, UCharacter.REPLACEMENT_CHAR
* is returned
* @param char16 the UTF16 character
* @return code point or UCharacter.REPLACEMENT_CHAR if argument is not a
* invalid character.
* @return code point if argument is a valid character.
* @exception IllegalArgumentException thrown when char16 is not a valid
* codepoint
*/
@ -1778,11 +1774,6 @@ public final class UCharacter
return 0;
}
private static boolean isEuropeanDigit(int ch) {
return (ch <= 0x7a && ((ch >= 0x41 && ch <= 0x5a) || ch >= 0x61)) ||
(ch >= 0xff21 && (ch <= 0xff3a || (ch >= 0xff41 && ch <= 0xff5a)));
}
private static int getEuropeanDigit(int ch) {
if (ch <= 0x7a) {
if (ch >= 0x41 && ch <= 0x5a) {

View File

@ -6,8 +6,8 @@
*
* $Source:
* /usr/cvs/icu4j/icu4j/src/com/ibm/icu/text/UCharacterCategory.java $
* $Date: 2002/02/16 03:05:56 $
* $Revision: 1.5 $
* $Date: 2002/04/03 04:32:00 $
* $Revision: 1.6 $
*
*******************************************************************************
*/
@ -233,9 +233,9 @@ public class UCharacterCategory
case OTHER_SYMBOL :
return "Symbol, Other";
case INITIAL_PUNCTUATION :
return "Punctuation, Initial quote ";
return "Punctuation, Initial quote";
case FINAL_PUNCTUATION :
return "Punctuation, Final quote ";
return "Punctuation, Final quote";
}
return "Unassigned";
}

View File

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/lang/Attic/UCharacterUtil.java,v $
* $Date: 2002/02/16 03:05:58 $
* $Revision: 1.4 $
* $Date: 2002/04/03 04:32:00 $
* $Revision: 1.5 $
*
*******************************************************************************
*/
@ -43,27 +43,7 @@ final class UCharacterUtil
return ((msc << 16) | lsc);
}
/**
* converting first 2 bytes of a byte array into char
* if array size is < 2 then algorithmn will only return value == 1 byte
* @param bytes 2 byte argument
* @return char form
*/
protected static char toChar(byte bytes[])
{
if (bytes == null || bytes.length == 0) {
return 0;
}
if (bytes.length == 1) {
return toChar(bytes[0]);
}
char firstbyte = (char)(toChar(bytes[0]) << 8);
char secondbyte = toChar(bytes[1]);
return (char)(firstbyte | secondbyte);
}
/**
* converting 2 bytes into a char
* @param msb the most significant byte
@ -72,56 +52,7 @@ final class UCharacterUtil
*/
protected static char toChar(byte msb, byte lsb)
{
char firstbyte = (char)(toChar(msb) << 8);
char secondbyte = toChar(lsb);
return (char)(firstbyte | secondbyte);
}
/**
* converting first 4 bytes of a byte array into int
* if array size is < 4 then algorithmn will only return value == # bytes
* @param bytes 4 byte argument
* @return int form
*/
protected static int toInt(byte bytes[])
{
if (bytes == null || bytes.length == 0)
return 0;
int size = bytes.length;
if (size > 4)
size = 4;
int result = 0;
for (int i = 0; i < size; i ++)
result = (result << 8) | (0x000000FF & bytes[i]);
return result;
}
/**
* converting a byte into char
* @param onebyte
* @return char form
*/
protected static char toChar(byte onebyte)
{
char result = (char)(onebyte & 0x000000ff);
return result;
}
/**
* converting a integer to a array of 4 characters where each character
* corresponds to its respective byte
* @param i integer to be converted
* @return array of 4 characters
*/
protected static char[] to4Char(int i)
{
char result[] = new char[4];
result[0] = (char)((i >> 24) & 0xFF);
result[1] = (char)((i & 0x00FF0000) >> 16);
result[2] = (char)((i & 0x0000FF00) >> 8);
result[3] = (char)(i & 0xFF);
return result;
return (char)((msb << 8) | (lsb & 0xFF));
}
/**