test/java/time/tck/java/time/TCKZoneOffset.java

Print this page

        

*** 65,93 **** import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; - import java.util.ArrayList; - import java.util.Arrays; - import java.util.List; - import java.time.DateTimeException; import java.time.Duration; import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.temporal.ChronoField; import java.time.temporal.JulianFields; - import java.time.temporal.OffsetDate; import java.time.temporal.Queries; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import org.testng.annotations.Test; /** * Test ZoneOffset. */ --- 65,93 ---- import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.time.DateTimeException; import java.time.Duration; import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.temporal.ChronoField; import java.time.temporal.JulianFields; import java.time.temporal.Queries; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; + import java.time.temporal.TemporalQuery; + import java.util.ArrayList; + import java.util.Arrays; + import java.util.List; + import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** * Test ZoneOffset. */
*** 478,488 **** //----------------------------------------------------------------------- // from() //----------------------------------------------------------------------- @Test(groups={"tck"}) public void test_factory_CalendricalObject() { - assertEquals(ZoneOffset.from(OffsetDate.of(LocalDate.of(2012, 5, 2), ZoneOffset.ofHours(6))), ZoneOffset.ofHours(6)); assertEquals(ZoneOffset.from(ZonedDateTime.of(LocalDateTime.of(LocalDate.of(2007, 7, 15), LocalTime.of(17, 30)), ZoneOffset.ofHours(2))), ZoneOffset.ofHours(2)); } @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) --- 478,487 ----
*** 558,605 **** } //----------------------------------------------------------------------- // query(TemporalQuery) //----------------------------------------------------------------------- ! @Test ! public void test_query_chrono() { ! ZoneOffset test = ZoneOffset.ofHoursMinutes(1, 30); ! assertEquals(test.query(Queries.chrono()), null); ! assertEquals(Queries.chrono().queryFrom(test), null); ! } ! ! @Test ! public void test_query_zoneId() { ! ZoneOffset test = ZoneOffset.ofHoursMinutes(1, 30); ! assertEquals(test.query(Queries.zoneId()), null); ! assertEquals(Queries.zoneId().queryFrom(test), null); ! } ! ! @Test ! public void test_query_precision() { ! ZoneOffset test = ZoneOffset.ofHoursMinutes(1, 30); ! assertEquals(test.query(Queries.precision()), null); ! assertEquals(Queries.precision().queryFrom(test), null); } ! @Test ! public void test_query_offset() { ! ZoneOffset test = ZoneOffset.ofHoursMinutes(1, 30); ! assertEquals(test.query(Queries.offset()), test); ! assertEquals(Queries.offset().queryFrom(test), test); } ! @Test ! public void test_query_zone() { ! ZoneOffset test = ZoneOffset.ofHoursMinutes(1, 30); ! assertEquals(test.query(Queries.zone()), test); ! assertEquals(Queries.zone().queryFrom(test), test); } @Test(expectedExceptions=NullPointerException.class) public void test_query_null() { ! ZoneOffset.ofHoursMinutes(1, 30).query(null); } //----------------------------------------------------------------------- // compareTo() //----------------------------------------------------------------------- --- 557,592 ---- } //----------------------------------------------------------------------- // query(TemporalQuery) //----------------------------------------------------------------------- ! @DataProvider(name="query") ! Object[][] data_query() { ! return new Object[][] { ! {ZoneOffset.UTC, Queries.chronology(), null}, ! {ZoneOffset.UTC, Queries.zoneId(), null}, ! {ZoneOffset.UTC, Queries.precision(), null}, ! {ZoneOffset.UTC, Queries.zone(), ZoneOffset.UTC}, ! {ZoneOffset.UTC, Queries.offset(), ZoneOffset.UTC}, ! {ZoneOffset.UTC, Queries.localDate(), null}, ! {ZoneOffset.UTC, Queries.localTime(), null}, ! }; } ! @Test(dataProvider="query") ! public <T> void test_query(TemporalAccessor temporal, TemporalQuery<T> query, T expected) { ! assertEquals(temporal.query(query), expected); } ! @Test(dataProvider="query") ! public <T> void test_queryFrom(TemporalAccessor temporal, TemporalQuery<T> query, T expected) { ! assertEquals(query.queryFrom(temporal), expected); } @Test(expectedExceptions=NullPointerException.class) public void test_query_null() { ! ZoneOffset.UTC.query(null); } //----------------------------------------------------------------------- // compareTo() //-----------------------------------------------------------------------