use of android.icu.text.DateIntervalInfo in project j2objc by google.
the class DateIntervalFormatTest method TestSetFallbackIntervalPattern.
/* Tests the method
* public void setFallbackIntervalPattern(String fallbackPattern)
*/
@Test
public void TestSetFallbackIntervalPattern() {
DateIntervalInfo dii = new DateIntervalInfo(new ULocale("en_US"));
// Tests when "if ( frozen )" is true
try {
dii.freeze();
dii.setFallbackIntervalPattern("");
errln("DateIntervalInfo.setFallbackIntervalPattern(String fallbackPattern) " + "was suppose to return an exception for a frozen object.");
} catch (Exception e) {
}
// Tests when "if ( firstPatternIndex == -1 || secondPatternIndex == -1 )" is true
dii = (DateIntervalInfo) dii.cloneAsThawed();
try {
dii.setFallbackIntervalPattern("");
errln("DateIntervalInfo.setFallbackIntervalPattern(String fallbackPattern) " + "was suppose to return an exception for a string object of ''.");
} catch (Exception e) {
}
try {
dii.setFallbackIntervalPattern("0");
errln("DateIntervalInfo.setFallbackIntervalPattern(String fallbackPattern) " + "was suppose to return an exception for a string object of 0.");
} catch (Exception e) {
}
// Tests when "if ( firstPatternIndex > secondPatternIndex )" is true
dii.setFallbackIntervalPattern("{1}{0}");
if (dii.getDefaultOrder() != true)
errln("DateIntervalInfo.setFallbackIntervalPattern(String fallbackPattern) " + "was suppose to change the variable 'fFirstDateInPtnIsLaterDate' " + "to true.");
}
use of android.icu.text.DateIntervalInfo in project j2objc by google.
the class DateIntervalFormatTest method TestT6396.
/*
* Ticket#6396 DateIntervalInfo of ICU4J 4.0d3 throw NullPointerException
*/
@Test
public void TestT6396() {
DateIntervalInfo dii = new DateIntervalInfo(new ULocale("th_TH"));
try {
// ticket#6396 reported toString() throws NullPointerException
String diiStr = dii.toString();
logln("new DateIntervalInfo(new ULocale(\"th_TH\")).toString() - " + diiStr);
// equals also had the similar problem
DateIntervalInfo dii1 = (DateIntervalInfo) dii.clone();
if (!dii.equals(dii1)) {
errln("FAIL: Cloned DateIntervalInfo is not equal to the source");
}
} catch (Exception e) {
errln("FAIL: Exception - " + e.getClass().getName());
}
}
Aggregations