use of java.time.DateTimeException in project jdk8u_jdk by JetBrains.
the class TCKMinguoChronology method test_resolve_yd_strict.
@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_strict(int y, int d, MinguoDate expected, boolean smart, boolean strict) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
fieldValues.put(ChronoField.YEAR, (long) y);
fieldValues.put(ChronoField.DAY_OF_YEAR, (long) d);
if (strict) {
MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
assertEquals(date, expected);
assertEquals(fieldValues.size(), 0);
} else {
try {
MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
fail("Should have failed");
} catch (DateTimeException ex) {
// expected
}
}
}
use of java.time.DateTimeException in project jdk8u_jdk by JetBrains.
the class TCKMinguoChronology method test_resolve_ymd_smart.
@Test(dataProvider = "resolve_ymd")
public void test_resolve_ymd_smart(int y, int m, int d, MinguoDate expected, Object smart, boolean strict) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
fieldValues.put(ChronoField.YEAR, (long) y);
fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m);
fieldValues.put(ChronoField.DAY_OF_MONTH, (long) d);
if (Boolean.TRUE.equals(smart)) {
MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
assertEquals(date, expected);
assertEquals(fieldValues.size(), 0);
} else if (smart instanceof MinguoDate) {
MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
assertEquals(date, smart);
} else {
try {
MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
fail("Should have failed");
} catch (DateTimeException ex) {
// expected
}
}
}
use of java.time.DateTimeException in project jdk8u_jdk by JetBrains.
the class TCKJapaneseChronology method test_resolve_yearOfEra_eraOnly_invalidTooLarge.
public void test_resolve_yearOfEra_eraOnly_invalidTooLarge() {
for (ResolverStyle style : ResolverStyle.values()) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
fieldValues.put(ChronoField.ERA, JapaneseEra.values()[JapaneseEra.values().length - 1].getValue() + 1L);
try {
JapaneseChronology.INSTANCE.resolveDate(fieldValues, style);
fail("Should have failed: " + style);
} catch (DateTimeException ex) {
// expected
}
}
}
use of java.time.DateTimeException in project jdk8u_jdk by JetBrains.
the class TCKJapaneseChronology method test_resolve_ymd_strict.
@Test(dataProvider = "resolve_ymd")
public void test_resolve_ymd_strict(int y, int m, int d, JapaneseDate expected, Object smart, boolean strict) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
fieldValues.put(ChronoField.YEAR, (long) y);
fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m);
fieldValues.put(ChronoField.DAY_OF_MONTH, (long) d);
if (strict) {
JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
assertEquals(date, expected);
assertEquals(fieldValues.size(), 0);
} else {
try {
JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
fail("Should have failed");
} catch (DateTimeException ex) {
// expected
}
}
}
use of java.time.DateTimeException in project jdk8u_jdk by JetBrains.
the class TCKJapaneseChronology method test_resolve_yd_strict.
@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_strict(int y, int d, JapaneseDate expected, boolean smart, boolean strict) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
fieldValues.put(ChronoField.YEAR, (long) y);
fieldValues.put(ChronoField.DAY_OF_YEAR, (long) d);
if (strict) {
JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
assertEquals(date, expected);
assertEquals(fieldValues.size(), 0);
} else {
try {
JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
fail("Should have failed");
} catch (DateTimeException ex) {
// expected
}
}
}
Aggregations