8156718: Need tests for IsoFields getFrom for unsupported non-Iso Temporal fields
Reviewed-by: rriggs, scolebourne
--- a/jdk/test/java/time/tck/java/time/temporal/TCKIsoFields.java Wed May 25 11:43:57 2016 +0530
+++ b/jdk/test/java/time/tck/java/time/temporal/TCKIsoFields.java Wed May 25 09:14:55 2016 +0000
@@ -442,29 +442,45 @@
}
//-----------------------------------------------------------------------
- // range refinedby
+ // rangeRefinedBy
//-----------------------------------------------------------------------
@DataProvider(name="isofields")
Object[][] data_isofields() {
return new Object[][] {
- {IsoFields.DAY_OF_QUARTER},
- {IsoFields.QUARTER_OF_YEAR},
- {IsoFields.WEEK_OF_WEEK_BASED_YEAR},
- {IsoFields.WEEK_BASED_YEAR},
+ {IsoFields.DAY_OF_QUARTER, 49, ValueRange.of(1, 91)},
+ {IsoFields.QUARTER_OF_YEAR, 2, ValueRange.of(1, 4)},
+ {IsoFields.WEEK_OF_WEEK_BASED_YEAR, 20, ValueRange.of(1, 52)},
+ {IsoFields.WEEK_BASED_YEAR, 2016, ValueRange.of(LocalDate.MIN.getYear(),
+ LocalDate.MAX.getYear())},
};
}
@Test(dataProvider = "isofields")
- public void test_isofields_rangerefinedby(TemporalField field) {
- field.rangeRefinedBy(LocalDate.now());
+ public void test_isofields_rangerefinedby(TemporalField field, int value, ValueRange valueRange) {
+ LocalDate date = LocalDate.of(2016, 5, 19);
+ assertEquals(field.rangeRefinedBy(date), valueRange);
}
@Test(dataProvider = "isofields", expectedExceptions = UnsupportedTemporalTypeException.class)
- public void test_nonisofields_rangerefinedby(TemporalField field) {
+ public void test_nonisofields_rangerefinedby(TemporalField field, int value, ValueRange valueRange) {
field.rangeRefinedBy(ThaiBuddhistDate.now());
}
//-----------------------------------------------------------------------
+ // getFrom
+ //-----------------------------------------------------------------------
+ @Test(dataProvider = "isofields")
+ public void test_isofields_getFrom(TemporalField field, int value, ValueRange valueRange) {
+ LocalDate date = LocalDate.of(2016, 5, 19);
+ assertEquals(field.getFrom(date), value);
+ }
+
+ @Test(dataProvider = "isofields", expectedExceptions = UnsupportedTemporalTypeException.class)
+ public void test_nonisofields_getFrom(TemporalField field, int value, ValueRange valueRange) {
+ field.getFrom(ThaiBuddhistDate.now());
+ }
+
+ //-----------------------------------------------------------------------
public void test_loop() {
// loop round at least one 400 year cycle, including before 1970
LocalDate date = LocalDate.of(1960, 1, 5); // Tuseday of week 1 1960