From 234cb0715c24c3aae85a026efa105960a8d9359a Mon Sep 17 00:00:00 2001 From: GCL Shanghai Date: Fri, 29 Oct 2004 15:41:59 +0000 Subject: [PATCH] ICU-4094 Add API/Method Coverage tests for ICU4J X-SVN-Rev: 16673 --- .../icu/dev/test/format/DateFormatTest.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/icu4j/src/com/ibm/icu/dev/test/format/DateFormatTest.java b/icu4j/src/com/ibm/icu/dev/test/format/DateFormatTest.java index ac1d131f2bf..38cc0e373e3 100755 --- a/icu4j/src/com/ibm/icu/dev/test/format/DateFormatTest.java +++ b/icu4j/src/com/ibm/icu/dev/test/format/DateFormatTest.java @@ -20,6 +20,7 @@ import java.text.ParseException; import java.text.ParsePosition; import java.util.Locale; import java.text.FieldPosition; +import java.util.ResourceBundle; public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk { @@ -1026,6 +1027,9 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk { sym = new ChineseDateFormatSymbols(); sym = new ChineseDateFormatSymbols(new ChineseCalendar(), foo); + // cover new ChineseDateFormatSymbols(Calendar, ULocale) + ChineseCalendar ccal = new ChineseCalendar(); + sym = new ChineseDateFormatSymbols(ccal, ULocale.CHINA); //gclsh1 add StringBuffer buf = new StringBuffer(); FieldPosition pos = new FieldPosition(0); @@ -1318,6 +1322,39 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk { } } + { + //cover getAvailableULocales + final ULocale[] locales = DateFormat.getAvailableULocales(); + long count = locales.length; + if (count==0) { + errln(" got a empty list for getAvailableULocales"); + }else{ + logln("" + count + " available ulocales"); + } + } + + { + //cover DateFormatSymbols.getDateFormatBundle + cal = new GregorianCalendar(); + Locale loc = Locale.getDefault(); + DateFormatSymbols mysym = new DateFormatSymbols(cal, loc); + if (mysym == null) + errln("FAIL: constructs DateFormatSymbols with calendar and locale failed"); + + uloc = ULocale.getDefault(); + ResourceBundle resb = DateFormatSymbols.getDateFormatBundle(cal, loc); + ResourceBundle resb2 = DateFormatSymbols.getDateFormatBundle(cal, uloc); + ResourceBundle resb3 = DateFormatSymbols.getDateFormatBundle(cal.getClass(), loc); + ResourceBundle resb4 = DateFormatSymbols.getDateFormatBundle(cal.getClass(), uloc); + + /* (ToDo) Not sure how to construct resourceBundle for this test + So comment out the verifying code. + if (!resb.equals(resb2) || + !resb.equals(resb3) || + !resb.equals(resb4) ) + errln("FAIL: getDateFormatBundle failed!"); + */ + } } /**