ICU-6956 Increased test coverage and committing for the night so that Michael Ow can create a report tomorrow morning.

X-SVN-Rev: 26175
This commit is contained in:
John Vu 2009-06-26 04:02:59 +00:00
parent cb8a77277f
commit ed64ccd132
7 changed files with 139 additions and 12 deletions

View file

@ -1,6 +1,6 @@
/**
*******************************************************************************
* Copyright (C) 1996-2008, International Business Machines Corporation and *
* Copyright (C) 1996-2009, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -120,7 +120,7 @@ public final class UCharacterProperty
/**
* Gets the property value at the index.
* This is optimized.
* Note this is alittle different from CharTrie the index m_trieData_
* Note this is a little different from CharTrie the index m_trieData_
* is never negative.
* @param ch code point whose property value is to be retrieved
* @return property value of code point

View file

@ -2057,11 +2057,16 @@ public final class UCharacter implements ECharacterCategory, ECharacterDirection
DOMINO_TILES,
};
/* Clover Code Coverage is turned off becuase the COUNT and BLOCKS_.length
* are both static final and can't be externally changed by another file.*/
///CLOVER:OFF
static {
if (COUNT!=BLOCKS_.length) {
throw new java.lang.IllegalStateException("UnicodeBlock fields are inconsistent!");
}
}
///CLOVER:ON
/**
* Identification code for this UnicodeBlock
*/
@ -3073,14 +3078,14 @@ public final class UCharacter implements ECharacterCategory, ECharacterDirection
// slightly pruned version of getUnicodeNumericValue(), plus getEuropeanDigit()
int props = PROPERTY_.getProperty(ch);
int numericType = getNumericType(props);
if(numericType==0) {
return getEuropeanDigit(ch);
}
if(numericType==UCharacterProperty.NT_FRACTION || numericType>=UCharacterProperty.NT_COUNT) {
return -2;
}
int numericValue = UCharacterProperty.getUnsignedValue(props);
if(numericType<NumericType.COUNT) {

View file

@ -1,6 +1,6 @@
/*
******************************************************************************
* Copyright (C) 1996-2008, International Business Machines Corporation and *
* Copyright (C) 1996-2009, International Business Machines Corporation and *
* others. All Rights Reserved. *
******************************************************************************
*/
@ -70,12 +70,17 @@ class UCharacterNameIterator implements ValueIterator
return true;
}
}
/* JOHNVU:
// The following code was comment out for "return false"
// because it can never be reached due to:
// 1) It has already been checked earlier
// 2) When m_current_ is updated earlier, it returns true
// 3) No updates on m_limit_
if (m_current_ >= m_limit_) {
// after iterateGroup fails, current codepoint may be
// greater than limit
return false;
}
}*/
element.integer = m_current_;
element.value = m_name_.getAlgorithmName(m_algorithmIndex_,

View file

@ -13,7 +13,6 @@ import com.ibm.icu.util.ULocale;
import com.ibm.icu.util.UResourceBundle;
import java.util.Locale;
import java.util.MissingResourceException;
/**
* A class to reflect UTR #24: Script Names
@ -735,12 +734,20 @@ public final class UScript {
*/
private static int[] findCodeFromLocale(ULocale locale) {
ICUResourceBundle rb;
/* JOHNVU:
// The following was comment out becuase the MissingResourceException
// seems to never be called because the "getBundleInstance" seems to
// correct this to ICUResourceBundle.FROM_DEFAULT if such invalid locale enters in.
try {
rb = (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, locale);
}
catch (MissingResourceException e) {
return null;
}
*/
rb = (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, locale);
// if rb is not a strict fallback of the requested locale, return null
//if(!LocaleUtility.isFallbackOf(rb.getULocale().toString(), locale.toString())){

View file

@ -1,6 +1,6 @@
/**
*******************************************************************************
* Copyright (C) 1999-2008, International Business Machines Corporation and *
* Copyright (C) 1999-2009, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -301,6 +301,25 @@ public class TestUScriptRun extends TestFmwk
} catch (IllegalArgumentException iae) {
logln("PASS: scriptRun.reset failed as expected");
}
try {
scriptRun.reset(dummy, 0, dummy.length);
scriptRun.reset();
} catch(IllegalArgumentException iae){
errln("scriptRun.reset() produced an IllegalArgumentException!");
}
try {
scriptRun.reset((char[]) null);
} catch(IllegalArgumentException iae){
errln("scriptRun.reset((char[])null) produced an IllegalArgumentException!");
}
try {
scriptRun.reset((String) null);
} catch(IllegalArgumentException iae){
errln("scriptRun.reset((String)null) produced an IllegalArgumentException!");
}
}
public void TestRuns()

View file

@ -1,6 +1,6 @@
/**
*******************************************************************************
* Copyright (C) 2001-2006, International Business Machines Corporation and *
* Copyright (C) 2001-2009, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -19,7 +19,7 @@ public class UCharacterDirectionTest extends TestFmwk
// constructor -----------------------------------------------------------
/**
* Private constructor to prevent initialisation
* Private constructor to prevent initialization
*/
public UCharacterDirectionTest()
{
@ -66,8 +66,13 @@ public class UCharacterDirectionTest extends TestFmwk
"Non-Spacing Mark",
"Boundary Neutral",
"Unassigned"};
for (int i = UCharacterDirection.LEFT_TO_RIGHT;
i < UCharacterDirection.CHAR_DIRECTION_COUNT; i ++) {
i <= UCharacterDirection.CHAR_DIRECTION_COUNT; i++) {
// Placed <= because we need to consider 'Unassigned'
// because it's out of bounds
if (!UCharacterDirection.toString(i).equals(name[i])) {
errln("Error toString for direction " + i + " expected " +
name[i]);

View file

@ -2424,4 +2424,90 @@ public final class UCharacterTest extends TestFmwk
}
}
}
public void TestGetInstance(){
// Testing values for invalid and valid ID
int[] invalid_test = {-1,-10,-100};
for(int i=0; i< invalid_test.length; i++){
if(UCharacter.UnicodeBlock.INVALID_CODE != UCharacter.UnicodeBlock.getInstance(invalid_test[i])){
errln("UCharacter.UnicodeBlock.getInstance(invalid_test[i]) was " +
"suppose to return UCharacter.UnicodeBlock.INVALID_CODE. Got " +
UCharacter.UnicodeBlock.getInstance(invalid_test[i]) + ". Expected " +
UCharacter.UnicodeBlock.INVALID_CODE);
}
}
}
public void TestOf(){
if(UCharacter.UnicodeBlock.INVALID_CODE != UCharacter.UnicodeBlock.of(UTF16.CODEPOINT_MAX_VALUE+1)){
errln("UCharacter.UnicodeBlock.of(UTF16.CODEPOINT_MAX_VALUE+1) was " +
"suppose to return UCharacter.UnicodeBlock.INVALID_CODE. Got " +
UCharacter.UnicodeBlock.of(UTF16.CODEPOINT_MAX_VALUE+1) + ". Expected " +
UCharacter.UnicodeBlock.INVALID_CODE);
}
}
// The method idOf can only be accessed through getIntPropertyValue
public void TestIDOf(){
int[] invalid_test = {-2, -1, UTF16.CODEPOINT_MAX_VALUE+1, UTF16.CODEPOINT_MAX_VALUE+2};
for(int i=0; i < invalid_test.length; i++){
int result = UCharacter.getIntPropertyValue(invalid_test[i], UProperty.BLOCK);
if(result != -1){
errln("UCharacter.UnicodeBlock.idOf() was suppose to return -1. Got " + result);
}
}
int[] valid_test = {0, 1, UTF16.CODEPOINT_MAX_VALUE, UTF16.CODEPOINT_MAX_VALUE-1};
for(int i=0; i < valid_test.length; i++){
int result = UCharacter.getIntPropertyValue(valid_test[i], UProperty.BLOCK);
if(result == -1){
errln("UCharacter.UnicodeBlock.idOf() was not suppose to return -1. Got " + result);
}
}
}
/*public void TestForName(){
UCharacter.UnicodeBlock.forName("");
}*/
public void TestGetNumericValue(){
// The following tests the else statement when
// if(numericType<NumericType.COUNT) is false
// The following values were obtained by testing all values from
// UTF16.CODEPOINT_MIN_VALUE to UTF16.CODEPOINT_MAX_VALUE inclusively
// to obtain the value to go through the else statement.
int[] valid_values =
{3058,3442,4988,8558,8559,8574,8575,8576,8577,8578,8583,8584,19975,
20159,20191,20740,20806,21315,33836,38433,65819,65820,65821,65822,
65823,65824,65825,65826,65827,65828,65829,65830,65831,65832,65833,
65834,65835,65836,65837,65838,65839,65840,65841,65842,65843,65861,
65862,65863,65868,65869,65870,65875,65876,65877,65878,65899,65900,
65901,65902,65903,65904,65905,65906,66378,68167};
int[] results =
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,-1,-1,-1,-1,-1,-1,-1};
if(valid_values.length != results.length){
errln("The valid_values array and the results array need to be "+
"the same length.");
} else {
for(int i = 0; i < valid_values.length; i++){
try{
if(UCharacter.getNumericValue(i) != results[i]){
errln("UCharacter.getNumericValue(i) returned a " +
"different value from the expected result. " +
"Got " + UCharacter.getNumericValue(i) +
"Expected" + results[i]);
}
} catch(Exception e){
errln("UCharacter.getNumericValue(int) returned an exception " +
"with the parameter value");
}
}
}
}
}