ICU-2118 code coverage

X-SVN-Rev: 12467
This commit is contained in:
Syn Wee Quek 2003-06-11 19:55:18 +00:00
parent 4271f9f5d9
commit 14d6791698
6 changed files with 90 additions and 9 deletions

View File

@ -35,6 +35,57 @@ public class UtilityTest extends TestFmwk {
}
}
public void TestFormat()
{
String data[] = {
"the quick brown fox jumps over the lazy dog",
// result of this conversion will exceed the original length and
// cause a newline to be inserted
"testing space , quotations \"",
"testing weird supplementary characters \ud800\udc00",
"testing control characters \u0001 and line breaking \n are we done yet?"
};
String result[] = {
" \"the quick brown fox jumps over the lazy dog\"",
" \"testing space , quotations \\042\"",
" \"testing weird supplementary characters \\uD800\\uDC00\"",
" \"testing control characters \\001 and line breaking \\012 are we done ye\"+"
+ Utility.LINE_SEPARATOR + " \"t?\""
};
String result1[] = {
"\"the quick brown fox jumps over the lazy dog\"",
"\"testing space , quotations \\042\"",
"\"testing weird supplementary characters \\uD800\\uDC00\"",
"\"testing control characters \\001 and line breaking \\012 are we done yet?\""
};
for (int i = 0; i < data.length; i ++) {
if (!result[i].equals(Utility.formatForSource(data[i]))) {
errln("Fail: Utility.formatForSource(\""
+ Utility.unescape(data[i]) + "expected to be " + result[i]);
}
}
for (int i = 0; i < data.length; i ++) {
if (!result1[i].equals(Utility.format1ForSource (data[i]))) {
errln("Fail: Utility.formatForSource(\""
+ Utility.unescape(data[i]) + "expected to be " + result1[i]);
}
}
}
public void TestHighBit()
{
int data[] = {-1, -1276, 0, 0xFFFF, 0x1234};
byte result[] = {-1, -1, -1, 15, 12};
for (int i = 0; i < data.length; i ++) {
if (Utility.highBit(data[i]) != result[i]) {
errln("Fail: Highest bit of \\u"
+ Integer.toHexString(data[i]) + " should be "
+ result[i]);
}
}
}
public void TestCompareUnsigned()
{
int data[] = {0, 1, 0x8fffffff, -1, Integer.MAX_VALUE,

View File

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/impl/BOCU.java,v $
* $Date: 2003/06/03 18:49:32 $
* $Revision: 1.6 $
* $Date: 2003/06/11 19:55:18 $
* $Revision: 1.7 $
*
*******************************************************************************
*/
@ -244,9 +244,11 @@ public class BOCU
/**
* Constructor private to prevent initialization
*/
///CLOVER:OFF
private BOCU()
{
}
}
///CLOVER:ON
// private methods -------------------------------------------------------

View File

@ -5,8 +5,8 @@
******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/impl/Trie.java,v $
* $Date: 2003/06/03 18:49:32 $
* $Revision: 1.11 $
* $Date: 2003/06/11 19:55:18 $
* $Revision: 1.12 $
*
******************************************************************************
*/
@ -93,6 +93,7 @@ public abstract class Trie
* @return true if the argument Trie has the same data as this Trie, false
* otherwise
*/
///CLOVER:OFF
public boolean equals(Object other)
{
if (other == this) {
@ -107,6 +108,7 @@ public abstract class Trie
&& m_dataLength_ == othertrie.m_dataLength_
&& Arrays.equals(m_index_, othertrie.m_index_);
}
///CLOVER:ON
// protected constructor -------------------------------------------

View File

@ -593,11 +593,13 @@ public final class UPropertyAliases implements ICUBinary.Authenticate {
* array of stringPool[] indices. MODIFIES THE ARRAY IN
* PLACE.
*/
///CLOVER:OFF
private void stringOffsetToIndex(short array[]) {
for (int i=0; i<array.length; ++i) {
array[i] = stringOffsetToIndex(array[i]);
}
}
///CLOVER:ON
/**
* Convert an offset into the value map into a valueMap[]

View File

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/impl/Utility.java,v $
* $Date: 2003/06/09 23:15:00 $
* $Revision: 1.41 $
* $Date: 2003/06/11 19:55:18 $
* $Revision: 1.42 $
*
*****************************************************************************************
*/
@ -468,6 +468,7 @@ public final class Utility {
/**
* Construct an array of shorts from a run-length encoded string.
*/
///CLOVER:OFF
static public final short[] RLEStringToShortArray(String s) {
int length = (((int) s.charAt(0)) << 16) | ((int) s.charAt(1));
short[] array = new short[length];
@ -494,6 +495,7 @@ public final class Utility {
return array;
}
///CLOVER:ON
/**
* Construct an array of shorts from a run-length encoded string.
@ -855,6 +857,7 @@ public final class Utility {
* Convert all escapes in a given string using unescapeAt().
* Leave invalid escape sequences unchanged.
*/
///CLOVER:OFF
public static String unescapeLeniently(String s) {
StringBuffer buf = new StringBuffer();
int[] pos = new int[1];
@ -875,40 +878,49 @@ public final class Utility {
}
return buf.toString();
}
///CLOVER:ON
/**
* Convert a char to 4 hex uppercase digits. E.g., hex('a') =>
* "0041".
*/
///CLOVER:OFF
public static String hex(char ch) {
StringBuffer temp = new StringBuffer();
return hex(ch, temp).toString();
}
///CLOVER:ON
/**
* Convert a string to comma-separated groups of 4 hex uppercase
* digits. E.g., hex('ab') => "0041,0042".
*/
///CLOVER:OFF
public static String hex(String s) {
StringBuffer temp = new StringBuffer();
return hex(s, temp).toString();
}
///CLOVER:ON
/**
* Convert a string to comma-separated groups of 4 hex uppercase
* digits. E.g., hex('ab') => "0041,0042".
*/
///CLOVER:OFF
public static String hex(StringBuffer s) {
return hex(s.toString());
}
///CLOVER:ON
/**
* Convert a char to 4 hex uppercase digits. E.g., hex('a') =>
* "0041". Append the output to the given StringBuffer.
*/
///CLOVER:OFF
public static StringBuffer hex(char ch, StringBuffer output) {
return appendNumber(output, ch, 16, 4);
}
///CLOVER:ON
/**
* Convert a integer to size width hex uppercase digits.
@ -935,6 +947,7 @@ public final class Utility {
* digits. E.g., hex('ab') => "0041,0042". Append the output
* to the given StringBuffer.
*/
///CLOVER:OFF
public static StringBuffer hex(String s, StringBuffer result) {
for (int i = 0; i < s.length(); ++i) {
if (i != 0) result.append(',');
@ -942,6 +955,7 @@ public final class Utility {
}
return result;
}
///CLOVER:ON
/**
* Split a string into pieces based on the given divider character
@ -954,6 +968,7 @@ public final class Utility {
* character will place empty strings into output. Before
* returning, output is padded out with empty strings.
*/
///CLOVER:OFF
public static void split(String s, char divider, String[] output) {
int last = 0;
int current = 0;
@ -969,6 +984,7 @@ public final class Utility {
output[current++] = "";
}
}
///CLOVER:ON
/**
* Look up a given string in a string array. Returns the index at
@ -980,12 +996,14 @@ public final class Utility {
* @return the index of target at which source first occurs, or -1
* if not found
*/
///CLOVER:OFF
public static int lookup(String source, String[] target) {
for (int i = 0; i < target.length; ++i) {
if (source.equals(target[i])) return i;
}
return -1;
}
///CLOVER:ON
/**
* Skip over a sequence of zero or more white space characters
@ -1270,6 +1288,7 @@ public final class Utility {
/**
* Trim whitespace from ends of a StringBuffer.
*/
///CLOVER:OFF
public static StringBuffer trim(StringBuffer b) {
// TODO update to handle surrogates
int i;
@ -1278,6 +1297,7 @@ public final class Utility {
for (i=b.length()-1; i>=0 && Character.isWhitespace(b.charAt(i)); --i) {}
return b.delete(i+1, b.length());
}
///CLOVER:ON
static final char DIGITS[] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
@ -1290,9 +1310,11 @@ public final class Utility {
* Append a number to the given StringBuffer in the radix 10
* generating at least one digit.
*/
///CLOVER:OFF
public static StringBuffer appendNumber(StringBuffer result, int n) {
return appendNumber(result, n, 10, 1);
}
///CLOVER:ON
/**
* Append the digits of a positive integer to the given

View File

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/CollationKey.java,v $
* $Date: 2003/06/03 18:49:33 $
* $Revision: 1.16 $
* $Date: 2003/06/11 19:55:18 $
* $Revision: 1.17 $
*
*******************************************************************************
*/
@ -127,7 +127,9 @@ public final class CollationKey implements Comparable
/**
* Private Constructor
*/
///CLOVER:OFF
private BoundMode(){};
///CLOVER:ON
};
// public constructor ---------------------------------------------------