ICU-4094 Add API/Method Coverage tests for ICU4J

X-SVN-Rev: 16669
This commit is contained in:
GCL Shanghai 2004-10-29 10:50:27 +00:00
parent cf9a074264
commit 8bcd6c39e7
6 changed files with 91 additions and 4 deletions

View file

@ -533,5 +533,17 @@ public class ChineseTest extends CalendarTest {
} catch (java.text.ParseException ex) {
logln(ex.getMessage()); // chinese calendar can't parse this, no error for now
}
//new ChineseCalendar(TimeZone,ULocale)
ChineseCalendar ccal2 = new ChineseCalendar(TimeZone.getDefault(),
ULocale.CHINA);
if(ccal2==null){
errln("could not create ChineseCalendar with TimeZone ULocale");
} else {
fmt = (ChineseDateFormat)DateFormat.getDateInstance(ccal2, DateFormat.DEFAULT, ULocale.CHINA);
time = getDate(2001, Calendar.MAY, 23);
str = fmt.format(time);
logln("Chinese calendar time: " + time + " result: " + str);
}
}
}

View file

@ -13,6 +13,7 @@ import com.ibm.icu.text.DateFormat;
import com.ibm.icu.util.Calendar;
import com.ibm.icu.util.HebrewCalendar;
import com.ibm.icu.util.TimeZone;
import com.ibm.icu.util.ULocale;
/**
* Tests for the <code>HebrewCalendar</code> class.
@ -215,7 +216,7 @@ public class HebrewTest extends CalendarTest {
doTestCases(testCases, new HebrewCalendar());
}catch(Exception ex){
warnln("Got Exception: "+ ex.getMessage());
warnln("Got Exception: "+ ex.getMessage());
}
}
@ -368,7 +369,15 @@ public class HebrewTest extends CalendarTest {
errln("could not create HebrewCalendar with TimeZone");
}
}
{
// new HebrewCalendar(ULocale)
HebrewCalendar cal = new HebrewCalendar(ULocale.getDefault());
if(cal == null){
errln("could not create HebrewCalendar with ULocale");
}
}
{
// new HebrewCalendar(Locale)
HebrewCalendar cal = new HebrewCalendar(Locale.getDefault());

View file

@ -147,6 +147,16 @@ public class HolidayTest extends TestFmwk {
logln("first between " + abd + " and " + xbd + " is " + rdr.firstBetween(abd, xbd));
logln("first between " + abd + " and " + null + " is " + rdr.firstBetween(abd, null));
logln("first between " + xbd + " and " + null + " is " + rdr.firstBetween(xbd, null));
//getRule, setRule
logln("The rule in the holiday: " + h[1].getRule());
exerciseHoliday(h[1], Locale.getDefault());
h[1].setRule(rdr);
logln("Set the new rule to the SimpleHoliday ...");
if (!rdr.equals(h[1].getRule())) {
errln("FAIL: getRule and setRule not matched.");
}
exerciseHoliday(h[1], Locale.getDefault());
}
public void TestIsOn() {

View file

@ -196,6 +196,22 @@ public class IBMCalendarTest extends CalendarTest {
}
public void TestBuddhistCoverage() {
{
// new BuddhistCalendar(ULocale)
BuddhistCalendar cal = new BuddhistCalendar(ULocale.getDefault());
if(cal == null){
errln("could not create BuddhistCalendar with ULocale");
}
}
{
// new BuddhistCalendar(TimeZone,ULocale)
BuddhistCalendar cal = new BuddhistCalendar(TimeZone.getDefault(),ULocale.getDefault());
if(cal == null){
errln("could not create BuddhistCalendar with TimeZone ULocale");
}
}
{
// new BuddhistCalendar(TimeZone)
BuddhistCalendar cal = new BuddhistCalendar(TimeZone.getDefault());
@ -711,6 +727,20 @@ public class IBMCalendarTest extends CalendarTest {
/*int x=*/ cal.getWeekendTransition(weekendCease);
} catch (IllegalArgumentException e) {}
/*int x=*/ cal.isWeekend(new Date());
// new GregorianCalendar(ULocale)
GregorianCalendar gcal = new GregorianCalendar(ULocale.getDefault());
if(gcal==null){
errln("could not create GregorianCalendar with ULocale");
} else {
logln("Calendar display name: " + gcal.getDisplayName(ULocale.getDefault()));
}
//cover getAvailableULocales
final ULocale[] locales = Calendar.getAvailableULocales();
long count = locales.length;
if (count == 0)
errln("getAvailableULocales return empty list");
logln("" + count + " available ulocales in Calendar.");
}
}

View file

@ -14,6 +14,7 @@ import com.ibm.icu.text.DateFormat;
import com.ibm.icu.util.Calendar;
import com.ibm.icu.util.IslamicCalendar;
import com.ibm.icu.util.TimeZone;
import com.ibm.icu.util.ULocale;
/**
* Tests for the <code>IslamicCalendar</code> class.
@ -141,7 +142,15 @@ public class IslamicTest extends CalendarTest {
errln("could not create IslamicCalendar with TimeZone");
}
}
{
// new IslamicCalendar(ULocale)
IslamicCalendar cal = new IslamicCalendar(ULocale.getDefault());
if(cal == null){
errln("could not create IslamicCalendar with ULocale");
}
}
{
// new IslamicCalendar(Locale)
IslamicCalendar cal = new IslamicCalendar(Locale.getDefault());

View file

@ -14,6 +14,7 @@ import com.ibm.icu.text.DateFormat;
import com.ibm.icu.util.Calendar;
import com.ibm.icu.util.JapaneseCalendar;
import com.ibm.icu.util.TimeZone;
import com.ibm.icu.util.ULocale;
/**
* Tests for the <code>IslamicCalendar</code> class.
@ -31,6 +32,22 @@ public class JapaneseTest extends CalendarTest {
errln("could not create JapaneseCalendar with TimeZone");
}
}
{
// new JapaneseCalendar(ULocale)
JapaneseCalendar cal = new JapaneseCalendar(ULocale.getDefault());
if(cal == null){
errln("could not create JapaneseCalendar with ULocale");
}
}
{
// new JapaneseCalendar(TimeZone, ULocale)
JapaneseCalendar cal = new JapaneseCalendar(TimeZone.getDefault(), ULocale.getDefault());
if(cal == null){
errln("could not create JapaneseCalendar with TimeZone ULocale");
}
}
{
// new JapaneseCalendar(Locale)