From a94e9c4d1b2dfc67cce47f020f5afbe0a7cce0fb Mon Sep 17 00:00:00 2001 From: Bhanu Prakash Gopularam Date: Wed, 25 May 2016 09:14:55 +0000 Subject: [PATCH] 8156718: Need tests for IsoFields getFrom for unsupported non-Iso Temporal fields Reviewed-by: rriggs, scolebourne --- .../tck/java/time/temporal/TCKIsoFields.java | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/jdk/test/java/time/tck/java/time/temporal/TCKIsoFields.java b/jdk/test/java/time/tck/java/time/temporal/TCKIsoFields.java index d1092d15ee6..c86805f9bfe 100644 --- a/jdk/test/java/time/tck/java/time/temporal/TCKIsoFields.java +++ b/jdk/test/java/time/tck/java/time/temporal/TCKIsoFields.java @@ -442,28 +442,44 @@ public class TCKIsoFields { } //----------------------------------------------------------------------- - // 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