ICU-3435 code coverage update

X-SVN-Rev: 14275
This commit is contained in:
Ram Viswanadha 2004-01-09 03:09:05 +00:00
parent 96969d34a2
commit 57d4092bc1
7 changed files with 93 additions and 72 deletions

View File

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/test/lang/UCharacterTest.java,v $
* $Date: 2003/10/04 00:37:16 $
* $Revision: 1.62 $
* $Date: 2004/01/09 03:06:37 $
* $Revision: 1.63 $
*
*******************************************************************************
*/
@ -795,16 +795,32 @@ public final class UCharacterTest extends TestFmwk
}
// ### TODO same tests for max ISO comment length as for max name length
int c[] = {0x0061, 0x000284, 0x003401, 0x007fed, 0x00ac00, 0x00d7a3,
0x00d800, 0x00dc00, 0xff08, 0x00ffe5, 0x00ffff,
0x0023456};
String name[] = {"LATIN SMALL LETTER A",
"LATIN SMALL LETTER DOTLESS J WITH STROKE AND HOOK",
"CJK UNIFIED IDEOGRAPH-3401",
"CJK UNIFIED IDEOGRAPH-7FED", "HANGUL SYLLABLE GA",
"HANGUL SYLLABLE HIH", "", "",
"FULLWIDTH LEFT PARENTHESIS",
"FULLWIDTH YEN SIGN", "", "CJK UNIFIED IDEOGRAPH-23456"};
int c[] = {0x0061, //LATIN SMALL LETTER A
0x000284, //LATIN SMALL LETTER DOTLESS J WITH STROKE AND HOOK
0x003401, //CJK UNIFIED IDEOGRAPH-3401
0x007fed, //CJK UNIFIED IDEOGRAPH-7FED
0x00ac00, //HANGUL SYLLABLE GA
0x00d7a3, //HANGUL SYLLABLE HIH
0x00d800, 0x00dc00, //LINEAR B SYLLABLE B008 A
0xff08, //FULLWIDTH LEFT PARENTHESIS
0x00ffe5, //FULLWIDTH YEN SIGN
0x00ffff, //null
0x0023456 //CJK UNIFIED IDEOGRAPH-23456
};
String name[] = {
"LATIN SMALL LETTER A",
"LATIN SMALL LETTER DOTLESS J WITH STROKE AND HOOK",
"CJK UNIFIED IDEOGRAPH-3401",
"CJK UNIFIED IDEOGRAPH-7FED",
"HANGUL SYLLABLE GA",
"HANGUL SYLLABLE HIH",
"",
"",
"FULLWIDTH LEFT PARENTHESIS",
"FULLWIDTH YEN SIGN",
"",
"CJK UNIFIED IDEOGRAPH-23456"
};
String oldname[] = {"", "LATIN SMALL LETTER DOTLESS J BAR HOOK", "",
"",
"", "", "", "", "FULLWIDTH OPENING PARENTHESIS", "",
@ -972,6 +988,20 @@ public final class UCharacterTest extends TestFmwk
logln("Ok: getCharNameCharacters() returned " + pattern1);
}
}
// improve code coverage
String expected = "LATIN SMALL LETTER A|LATIN SMALL LETTER DOTLESS J WITH STROKE AND HOOK|"+
"CJK UNIFIED IDEOGRAPH-3401|CJK UNIFIED IDEOGRAPH-7FED|HANGUL SYLLABLE GA|"+
"HANGUL SYLLABLE HIH|LINEAR B SYLLABLE B008 A|FULLWIDTH LEFT PARENTHESIS|"+
"FULLWIDTH YEN SIGN|"+
"null|"+ // getName returns null because 0xFFFF does not have a name, but has an extended name!
"CJK UNIFIED IDEOGRAPH-23456";
String separator= "|";
String source = Utility.valueOf(c);
String result = UCharacter.getName(source, separator);
if(!result.equals(expected)){
errln("UCharacter.getName did not return the expected result.\n\t Expected: "+ expected+"\n\t Got: "+ result);
}
}catch(IllegalArgumentException e){
if(e.getMessage().indexOf("unames.icu") >= 0){
warnln("Could not find unames.icu");
@ -979,8 +1009,10 @@ public final class UCharacterTest extends TestFmwk
throw e;
}
}
}
}
/**
* Testing name iteration
*/

View File

@ -5,21 +5,22 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/impl/StringUCharacterIterator.java,v $
* $Date: 2003/12/20 03:06:55 $
* $Revision: 1.2 $
* $Date: 2004/01/09 03:07:13 $
* $Revision: 1.3 $
*
*******************************************************************************
*/
package com.ibm.icu.impl;
import com.ibm.icu.text.UCharacterIterator;
import com.ibm.icu.text.UTF16;
/**
* Used by Collation. UCharacterIterator on Strings. Can't use
* ReplaceableUCharacterIterator because it is not easy to do a fast setText.
* @author synwee
*/
// TODO: Investivate if setText is a feature required by users so that we can
// move this method to the base class!
public final class StringUCharacterIterator extends UCharacterIterator
{
@ -54,6 +55,7 @@ public final class StringUCharacterIterator extends UCharacterIterator
* <code>String</code>object
* @return copy of this iterator
*/
///CLOVER:OFF
public Object clone()
{
try {
@ -62,7 +64,7 @@ public final class StringUCharacterIterator extends UCharacterIterator
return null; // never invoked
}
}
///CLOVER:ON
/**
* Returns the current UTF16 character.
* @return current UTF16 character
@ -75,38 +77,6 @@ public final class StringUCharacterIterator extends UCharacterIterator
return DONE;
}
/**
* Returns the current codepoint
* @return current codepoint
*/
public int currentCodePoint()
{
// cannot use charAt due to it different
// behaviour when index is pointing at a
// trail surrogate, check for surrogates
if (m_currentIndex_ >= m_text_.length()) {
return DONE;
}
char ch = m_text_.charAt(m_currentIndex_);
if (UTF16.isLeadSurrogate(ch)) {
// advance the index to get the next code point
m_currentIndex_ ++;
if (m_currentIndex_ < m_text_.length()) {
// due to post increment semantics current() after next()
// actually returns the next char which is what we want
char ch2 = m_text_.charAt(m_currentIndex_);
if (UTF16.isTrailSurrogate(ch2)) {
// we found a surrogate pair
return UCharacterProperty.getRawSupplementary(ch, ch2);
}
}
// current should never change the current index so back off
m_currentIndex_ --;
}
return ch;
}
/**
* Returns the length of the text
@ -213,6 +183,7 @@ public final class StringUCharacterIterator extends UCharacterIterator
* @exception IndexOutOfBounds exception if there is not enough
* room after offset in the array, or if offset &lt; 0.
*/
///CLOVER: OFF
public int getText(char[] fillIn, int offset)
{
int length = m_text_.length();
@ -222,7 +193,7 @@ public final class StringUCharacterIterator extends UCharacterIterator
m_text_.getChars(0, length, fillIn, offset);
return length;
}
///CLOVER: ON
/**
* Convenience method for returning the underlying text storage as as
* string

View File

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/impl/USerializedSet.java,v $
* $Date: 2003/06/11 16:31:31 $
* $Revision: 1.5 $
* $Date: 2004/01/09 03:07:12 $
* $Revision: 1.6 $
*
*****************************************************************************************
*/
@ -161,6 +161,7 @@ public final class USerializedSet {
* @return true if set contains c
* @draft ICU 2.4
*/
///CLOVER:OFF
public final boolean contains(int c) {
if(c>0x10ffff) {
@ -184,6 +185,7 @@ public final class USerializedSet {
return (boolean)(((i+bmpLength)&2)!=0);
}
}
///CLOVER:ON
/**
* Returns the number of disjoint ranges of characters contained in
* the given serialized set. Ignores any strings contained in the

View File

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/impl/Utility.java,v $
* $Date: 2003/10/07 18:11:01 $
* $Revision: 1.48 $
* $Date: 2004/01/09 03:07:11 $
* $Revision: 1.49 $
*
*****************************************************************************************
*/
@ -14,7 +14,8 @@ package com.ibm.icu.impl;
import com.ibm.icu.lang.*;
import com.ibm.icu.text.*;
import com.ibm.icu.impl.UCharacterProperty;
// This class contains utility functions so testing not needed
///CLOVER:OFF
public final class Utility {
private static final char APOSTROPHE = '\'';
@ -424,7 +425,7 @@ public final class Utility {
state[1] = value;
}
}
///CLOVER:OFF
/**
* Construct an array of ints from a run-length encoded string.
*/
@ -463,7 +464,7 @@ public final class Utility {
static final int getInt(String s, int i) {
return (((int) s.charAt(2*i)) << 16) | (int) s.charAt(2*i+1);
}
///CLOVER:ON
/**
* Construct an array of shorts from a run-length encoded string.
@ -1732,4 +1733,19 @@ public final class Utility {
return bit;
}
/**
* Utility method to take a int[] containing codepoints and return
* a string representation with code units.
* TODO: Investigate why this method is not on UTF16 class
* @param source
* @return
*/
public static String valueOf(int[]source){
StringBuffer result = new StringBuffer(source.length);
for(int i=0; i<source.length; i++){
UTF16.append(result,source[i]);
}
return result.toString();
}
}
///CLOVER:ON

View File

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/impl/UtilityExtensions.java,v $
* $Date: 2003/06/03 18:49:33 $
* $Revision: 1.3 $
* $Date: 2004/01/09 03:07:13 $
* $Revision: 1.4 $
*
*****************************************************************************************
*/
@ -18,12 +18,9 @@ import com.ibm.icu.text.UnicodeMatcher;
import com.ibm.icu.text.Transliterator;
/**
* @author Ram
*
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
//This class contains utility functions so testing not needed
///CLOVER:OFF
public class UtilityExtensions {
/**
* Append the given string to the rule. Calls the single-character
@ -119,3 +116,4 @@ public class UtilityExtensions {
}
}
//CLOVER:ON

View File

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/Punycode.java,v $
* $Date: 2003/08/27 21:12:04 $
* $Revision: 1.1 $
* $Date: 2004/01/09 03:08:46 $
* $Revision: 1.2 $
*
*****************************************************************************************
*/
@ -94,7 +94,7 @@ final class Punycode {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
};
///CLOVER:OFF
private static char asciiCaseMap(char b, boolean uppercase) {
if(uppercase) {
if(SMALL_A<=b && b<=SMALL_Z) {
@ -107,7 +107,7 @@ final class Punycode {
}
return b;
}
///CLOVER:ON
/**
* digitToBasic() returns the basic code point whose value
* (when used for representing integers) is d, which must be in the
@ -281,10 +281,11 @@ final class Punycode {
private static boolean isBasic(int ch){
return (ch < INITIAL_N);
}
///CLOVER:OFF
private static boolean isBasicUpperCase(int ch){
return( CAPITAL_A<=ch && ch >= CAPITAL_Z);
}
///CLOVER:ON
private static boolean isSurrogate(int ch){
return (((ch)&0xfffff800)==0xd800);
}

View File

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/util/LocaleData.java,v $
* $Date: 2003/12/01 21:20:24 $
* $Revision: 1.4 $
* $Date: 2004/01/09 03:09:05 $
* $Revision: 1.5 $
*
*******************************************************************************
*/
@ -30,8 +30,9 @@ public final class LocaleData {
private static final String PAPER_SIZE = "PaperSize";
// private constructor to prevent default construction
///CLOVER:OFF
private LocaleData(){}
///CLOVER:ON
/**
* Returns the exemplar characters for the given locale ID.
*