From 34d451e3b153d71399ae1af9205da827873a7539 Mon Sep 17 00:00:00 2001 From: Ram Viswanadha Date: Thu, 7 Jul 2005 20:09:39 +0000 Subject: [PATCH] ICU-4451 improve API/code coverage X-SVN-Rev: 18162 --- icu4j/build.xml | 13 ++++-------- icu4j/src/com/ibm/icu/dev/test/TestAll.java | 5 +++-- .../test/charsetdet/TestCharsetDetector.java | 5 +++++ .../format/IntlTestDecimalFormatSymbols.java | 16 ++++++++++++++- .../ibm/icu/dev/test/lang/UCharacterTest.java | 20 +++++++++++++++++++ icu4j/src/com/ibm/icu/lang/UCharacter.java | 2 +- .../src/com/ibm/icu/lang/UCharacterEnums.java | 1 + icu4j/src/com/ibm/icu/text/Normalizer.java | 3 ++- icu4j/src/com/ibm/icu/util/Currency.java | 2 +- 9 files changed, 52 insertions(+), 15 deletions(-) diff --git a/icu4j/build.xml b/icu4j/build.xml index 38c9c2843e..50f6ba42b4 100644 --- a/icu4j/build.xml +++ b/icu4j/build.xml @@ -15,11 +15,12 @@ + - + @@ -38,17 +39,11 @@ - + - - - - - - - + diff --git a/icu4j/src/com/ibm/icu/dev/test/TestAll.java b/icu4j/src/com/ibm/icu/dev/test/TestAll.java index f09441a376..222f1e2d39 100755 --- a/icu4j/src/com/ibm/icu/dev/test/TestAll.java +++ b/icu4j/src/com/ibm/icu/dev/test/TestAll.java @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (C) 1996-2004, International Business Machines Corporation and * + * Copyright (C) 1996-2005, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* */ @@ -36,7 +36,8 @@ public class TestAll extends TestGroup { "com.ibm.icu.dev.test.bigdec.DiagBigDecimal", // not a group "com.ibm.icu.dev.test.impl.TestAll", "com.ibm.icu.dev.test.stringprep.TestAll", - "com.ibm.icu.dev.test.timescale.TestAll" + "com.ibm.icu.dev.test.timescale.TestAll", + "com.ibm.icu.dev.test.charsetdet.TestCharsetDetector" }, "All tests in ICU"); } diff --git a/icu4j/src/com/ibm/icu/dev/test/charsetdet/TestCharsetDetector.java b/icu4j/src/com/ibm/icu/dev/test/charsetdet/TestCharsetDetector.java index f048a58dd2..cb696f24ae 100644 --- a/icu4j/src/com/ibm/icu/dev/test/charsetdet/TestCharsetDetector.java +++ b/icu4j/src/com/ibm/icu/dev/test/charsetdet/TestCharsetDetector.java @@ -181,6 +181,10 @@ public class TestCharsetDetector extends TestFmwk CharsetMatch m; det.enableInputFilter(true); + if (!det.inputFilterEnabled()){ + errln("input filter should be enabled"); + } + det.setText(bytes); m = det.detect(); @@ -213,6 +217,7 @@ public class TestCharsetDetector extends TestFmwk reader = det.getReader(new ByteArrayInputStream(bytes), "UTF-8"); CheckAssert(s.equals(stringFromReader(reader))); + det.setDeclaredEncoding("UTF-8"); // Jitterbug 4451, for coverage } public void TestUTF16() throws Exception diff --git a/icu4j/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatSymbols.java b/icu4j/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatSymbols.java index 67f75e0695..6a2f667d40 100755 --- a/icu4j/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatSymbols.java +++ b/icu4j/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatSymbols.java @@ -1,6 +1,6 @@ /***************************************************************************************** * - * Copyright (C) 1996-2004, International Business Machines + * Copyright (C) 1996-2005, International Business Machines * Corporation and others. All Rights Reserved. **/ @@ -18,6 +18,8 @@ package com.ibm.icu.dev.test.format; import com.ibm.icu.text.*; +import com.ibm.icu.util.Currency; + import java.util.Locale; public class IntlTestDecimalFormatSymbols extends com.ibm.icu.dev.test.TestFmwk @@ -45,6 +47,18 @@ public class IntlTestDecimalFormatSymbols extends com.ibm.icu.dev.test.TestFmwk errln("ERROR: get/set ZeroDigit failed"); } + char sigDigit = en.getSignificantDigit(); + fr.setZeroDigit(sigDigit); + if(fr.getSignificantDigit() != en.getSignificantDigit()) { + errln("ERROR: get/set SignificantDigit failed"); + } + + Currency currency = Currency.getInstance("USD"); + fr.setCurrency(currency); + if (!fr.getCurrency().equals(currency)){ + errln("ERROR: get/set Currency failed"); + } + char group = en.getGroupingSeparator(); fr.setGroupingSeparator(group); if(fr.getGroupingSeparator() != en.getGroupingSeparator()) { diff --git a/icu4j/src/com/ibm/icu/dev/test/lang/UCharacterTest.java b/icu4j/src/com/ibm/icu/dev/test/lang/UCharacterTest.java index f69bcca485..4d4b748711 100755 --- a/icu4j/src/com/ibm/icu/dev/test/lang/UCharacterTest.java +++ b/icu4j/src/com/ibm/icu/dev/test/lang/UCharacterTest.java @@ -2307,6 +2307,26 @@ public final class UCharacterTest extends TestFmwk assertEquals("UCharacter.forDigit ", "7", String.valueOf(ch1)); char ch2 = UCharacter.forDigit(17, 20); assertEquals("UCharacter.forDigit ", "h", String.valueOf(ch2)); + + //Jitterbug 4451, for coverage + for (int i = 0x0041; i < 0x005B; i++) { + if (!UCharacter.isJavaLetter(i)) + errln("FAIL \\u" + hex(i) + " expected to be a letter"); + if (!UCharacter.isJavaIdentifierStart(i)) + errln("FAIL \\u" + hex(i) + " expected to be a Java identifier start character"); + if (!UCharacter.isJavaLetterOrDigit(i)) + errln("FAIL \\u" + hex(i) + " expected not to be a Java letter"); + if (!UCharacter.isJavaIdentifierPart(i)) + errln("FAIL \\u" + hex(i) + " expected to be a Java identifier part character"); + } + char[] spaces = {'\t','\n','\f','\r',' '}; + for (int i = 0; i < spaces.length; i++){ + if (!UCharacter.isSpace(spaces[i])) + errln("FAIL \\u" + hex(spaces[i]) + " expected to be a Java space"); + } + if (!UCharacter.getStringPropertyValue(UProperty.AGE,'\u3400',0).equals("3.0.0.0")){ + errln("FAIL \\u3400 expected to be 3.0.0.0"); + } } public void TestCasePropsDummy() { diff --git a/icu4j/src/com/ibm/icu/lang/UCharacter.java b/icu4j/src/com/ibm/icu/lang/UCharacter.java index ee445c6dd1..4242b7965d 100755 --- a/icu4j/src/com/ibm/icu/lang/UCharacter.java +++ b/icu4j/src/com/ibm/icu/lang/UCharacter.java @@ -3082,7 +3082,7 @@ public final class UCharacter implements ECharacterCategory, ECharacterDirection * @deprecated (Java) */ public static boolean isJavaLetterOrDigit(int cp) { - return isJavaLetterOrDigit(cp); + return isJavaIdentifierPart(cp); } /** diff --git a/icu4j/src/com/ibm/icu/lang/UCharacterEnums.java b/icu4j/src/com/ibm/icu/lang/UCharacterEnums.java index dd57c00fb9..ca7d8447cd 100644 --- a/icu4j/src/com/ibm/icu/lang/UCharacterEnums.java +++ b/icu4j/src/com/ibm/icu/lang/UCharacterEnums.java @@ -15,6 +15,7 @@ package com.ibm.icu.lang; public class UCharacterEnums { /** This is just a namespace, it is not instantiatable. */ + ///CLOVER:OFF private UCharacterEnums() {} /** diff --git a/icu4j/src/com/ibm/icu/text/Normalizer.java b/icu4j/src/com/ibm/icu/text/Normalizer.java index f4c3e0a245..59d00f2c8e 100755 --- a/icu4j/src/com/ibm/icu/text/Normalizer.java +++ b/icu4j/src/com/ibm/icu/text/Normalizer.java @@ -1883,11 +1883,12 @@ public final class Normalizer implements Cloneable { * @deprecated ICU 3.2 * @obsolete ICU 3.2 */ + ///CLOVER:OFF public int setIndex(int index) { setIndexOnly(index); return current(); } - + ///CLOVER:ON /** * Retrieve the index of the start of the input text. This is the begin * index of the CharacterIterator or the start (i.e. 0) of the diff --git a/icu4j/src/com/ibm/icu/util/Currency.java b/icu4j/src/com/ibm/icu/util/Currency.java index 4983339e04..f991be8b29 100644 --- a/icu4j/src/com/ibm/icu/util/Currency.java +++ b/icu4j/src/com/ibm/icu/util/Currency.java @@ -305,7 +305,7 @@ public class Currency extends MeasureUnit implements Serializable { * @deprecated This is a draft API and might change in a future release of ICU. */ public String getSymbol(ULocale uloc) { - return getName(uloc, SYMBOL_NAME, null); + return getName(uloc, SYMBOL_NAME, new boolean[1]); } /**