test/java/time/tck/java/time/zone/TCKZoneOffsetTransition.java

Print this page

        

*** 60,76 **** package tck.java.time.zone; import static java.time.temporal.ChronoUnit.HOURS; import static org.testng.Assert.assertEquals; - import tck.java.time.AbstractTCKTest; import java.time.Duration; import java.time.LocalDateTime; - import java.time.ZoneOffset; import java.time.Year; import java.time.zone.ZoneOffsetTransition; import org.testng.annotations.Test; /** * Test ZoneOffsetTransition. */ @Test --- 60,77 ---- package tck.java.time.zone; import static java.time.temporal.ChronoUnit.HOURS; import static org.testng.Assert.assertEquals; import java.time.Duration; import java.time.LocalDateTime; import java.time.Year; + import java.time.ZoneOffset; import java.time.zone.ZoneOffsetTransition; + import org.testng.annotations.Test; + import tck.java.time.AbstractTCKTest; /** * Test ZoneOffsetTransition. */ @Test
*** 83,121 **** private static final ZoneOffset OFFSET_0400 = ZoneOffset.ofHours(4); //----------------------------------------------------------------------- // factory //----------------------------------------------------------------------- ! @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) public void test_factory_nullTransition() { ZoneOffsetTransition.of(null, OFFSET_0100, OFFSET_0200); } ! @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) public void test_factory_nullOffsetBefore() { ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), null, OFFSET_0200); } ! @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) public void test_factory_nullOffsetAfter() { ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), OFFSET_0200, null); } ! @Test(expectedExceptions=IllegalArgumentException.class, groups={"tck"}) public void test_factory_sameOffset() { ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), OFFSET_0200, OFFSET_0200); } ! @Test(expectedExceptions=IllegalArgumentException.class, groups={"tck"}) public void test_factory_noNanos() { ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30, 0, 500), OFFSET_0200, OFFSET_0300); } //----------------------------------------------------------------------- // getters //----------------------------------------------------------------------- ! @Test(groups={"tck"}) public void test_getters_gap() throws Exception { LocalDateTime before = LocalDateTime.of(2010, 3, 31, 1, 0); LocalDateTime after = LocalDateTime.of(2010, 3, 31, 2, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(before, OFFSET_0200, OFFSET_0300); assertEquals(test.isGap(), true); --- 84,122 ---- private static final ZoneOffset OFFSET_0400 = ZoneOffset.ofHours(4); //----------------------------------------------------------------------- // factory //----------------------------------------------------------------------- ! @Test(expectedExceptions=NullPointerException.class) public void test_factory_nullTransition() { ZoneOffsetTransition.of(null, OFFSET_0100, OFFSET_0200); } ! @Test(expectedExceptions=NullPointerException.class) public void test_factory_nullOffsetBefore() { ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), null, OFFSET_0200); } ! @Test(expectedExceptions=NullPointerException.class) public void test_factory_nullOffsetAfter() { ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), OFFSET_0200, null); } ! @Test(expectedExceptions=IllegalArgumentException.class) public void test_factory_sameOffset() { ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), OFFSET_0200, OFFSET_0200); } ! @Test(expectedExceptions=IllegalArgumentException.class) public void test_factory_noNanos() { ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30, 0, 500), OFFSET_0200, OFFSET_0300); } //----------------------------------------------------------------------- // getters //----------------------------------------------------------------------- ! @Test public void test_getters_gap() throws Exception { LocalDateTime before = LocalDateTime.of(2010, 3, 31, 1, 0); LocalDateTime after = LocalDateTime.of(2010, 3, 31, 2, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(before, OFFSET_0200, OFFSET_0300); assertEquals(test.isGap(), true);
*** 127,137 **** assertEquals(test.getOffsetAfter(), OFFSET_0300); assertEquals(test.getDuration(), Duration.of(1, HOURS)); assertSerializable(test); } ! @Test(groups={"tck"}) public void test_getters_overlap() throws Exception { LocalDateTime before = LocalDateTime.of(2010, 10, 31, 1, 0); LocalDateTime after = LocalDateTime.of(2010, 10, 31, 0, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(before, OFFSET_0300, OFFSET_0200); assertEquals(test.isGap(), false); --- 128,138 ---- assertEquals(test.getOffsetAfter(), OFFSET_0300); assertEquals(test.getDuration(), Duration.of(1, HOURS)); assertSerializable(test); } ! @Test public void test_getters_overlap() throws Exception { LocalDateTime before = LocalDateTime.of(2010, 10, 31, 1, 0); LocalDateTime after = LocalDateTime.of(2010, 10, 31, 0, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(before, OFFSET_0300, OFFSET_0200); assertEquals(test.isGap(), false);
*** 161,182 **** } //----------------------------------------------------------------------- // isValidOffset() //----------------------------------------------------------------------- ! @Test(groups={"tck"}) public void test_isValidOffset_gap() { LocalDateTime ldt = LocalDateTime.of(2010, 3, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0200, OFFSET_0300); assertEquals(test.isValidOffset(OFFSET_0100), false); assertEquals(test.isValidOffset(OFFSET_0200), false); assertEquals(test.isValidOffset(OFFSET_0230), false); assertEquals(test.isValidOffset(OFFSET_0300), false); assertEquals(test.isValidOffset(OFFSET_0400), false); } ! @Test(groups={"tck"}) public void test_isValidOffset_overlap() { LocalDateTime ldt = LocalDateTime.of(2010, 10, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0300, OFFSET_0200); assertEquals(test.isValidOffset(OFFSET_0100), false); assertEquals(test.isValidOffset(OFFSET_0200), true); --- 162,183 ---- } //----------------------------------------------------------------------- // isValidOffset() //----------------------------------------------------------------------- ! @Test public void test_isValidOffset_gap() { LocalDateTime ldt = LocalDateTime.of(2010, 3, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0200, OFFSET_0300); assertEquals(test.isValidOffset(OFFSET_0100), false); assertEquals(test.isValidOffset(OFFSET_0200), false); assertEquals(test.isValidOffset(OFFSET_0230), false); assertEquals(test.isValidOffset(OFFSET_0300), false); assertEquals(test.isValidOffset(OFFSET_0400), false); } ! @Test public void test_isValidOffset_overlap() { LocalDateTime ldt = LocalDateTime.of(2010, 10, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0300, OFFSET_0200); assertEquals(test.isValidOffset(OFFSET_0100), false); assertEquals(test.isValidOffset(OFFSET_0200), true);
*** 186,196 **** } //----------------------------------------------------------------------- // compareTo() //----------------------------------------------------------------------- ! @Test(groups={"tck"}) public void test_compareTo() { ZoneOffsetTransition a = ZoneOffsetTransition.of( LocalDateTime.ofEpochSecond(23875287L - 1, 0, OFFSET_0200), OFFSET_0200, OFFSET_0300); ZoneOffsetTransition b = ZoneOffsetTransition.of( LocalDateTime.ofEpochSecond(23875287L, 0, OFFSET_0300), OFFSET_0300, OFFSET_0200); --- 187,197 ---- } //----------------------------------------------------------------------- // compareTo() //----------------------------------------------------------------------- ! @Test public void test_compareTo() { ZoneOffsetTransition a = ZoneOffsetTransition.of( LocalDateTime.ofEpochSecond(23875287L - 1, 0, OFFSET_0200), OFFSET_0200, OFFSET_0300); ZoneOffsetTransition b = ZoneOffsetTransition.of( LocalDateTime.ofEpochSecond(23875287L, 0, OFFSET_0300), OFFSET_0300, OFFSET_0200);
*** 208,218 **** assertEquals(c.compareTo(a) > 0, true); assertEquals(c.compareTo(b) > 0, true); assertEquals(c.compareTo(c) == 0, true); } ! @Test(groups={"tck"}) public void test_compareTo_sameInstant() { ZoneOffsetTransition a = ZoneOffsetTransition.of( LocalDateTime.ofEpochSecond(23875287L, 0, OFFSET_0200), OFFSET_0200, OFFSET_0300); ZoneOffsetTransition b = ZoneOffsetTransition.of( LocalDateTime.ofEpochSecond(23875287L, 0, OFFSET_0300), OFFSET_0300, OFFSET_0200); --- 209,219 ---- assertEquals(c.compareTo(a) > 0, true); assertEquals(c.compareTo(b) > 0, true); assertEquals(c.compareTo(c) == 0, true); } ! @Test public void test_compareTo_sameInstant() { ZoneOffsetTransition a = ZoneOffsetTransition.of( LocalDateTime.ofEpochSecond(23875287L, 0, OFFSET_0200), OFFSET_0200, OFFSET_0300); ZoneOffsetTransition b = ZoneOffsetTransition.of( LocalDateTime.ofEpochSecond(23875287L, 0, OFFSET_0300), OFFSET_0300, OFFSET_0200);
*** 233,243 **** } //----------------------------------------------------------------------- // equals() //----------------------------------------------------------------------- ! @Test(groups={"tck"}) public void test_equals() { LocalDateTime ldtA = LocalDateTime.of(2010, 3, 31, 1, 0); ZoneOffsetTransition a1 = ZoneOffsetTransition.of(ldtA, OFFSET_0200, OFFSET_0300); ZoneOffsetTransition a2 = ZoneOffsetTransition.of(ldtA, OFFSET_0200, OFFSET_0300); LocalDateTime ldtB = LocalDateTime.of(2010, 10, 31, 1, 0); --- 234,244 ---- } //----------------------------------------------------------------------- // equals() //----------------------------------------------------------------------- ! @Test public void test_equals() { LocalDateTime ldtA = LocalDateTime.of(2010, 3, 31, 1, 0); ZoneOffsetTransition a1 = ZoneOffsetTransition.of(ldtA, OFFSET_0200, OFFSET_0300); ZoneOffsetTransition a2 = ZoneOffsetTransition.of(ldtA, OFFSET_0200, OFFSET_0300); LocalDateTime ldtB = LocalDateTime.of(2010, 10, 31, 1, 0);
*** 258,268 **** } //----------------------------------------------------------------------- // hashCode() //----------------------------------------------------------------------- ! @Test(groups={"tck"}) public void test_hashCode_floatingWeek_gap_notEndOfDay() { LocalDateTime ldtA = LocalDateTime.of(2010, 3, 31, 1, 0); ZoneOffsetTransition a1 = ZoneOffsetTransition.of(ldtA, OFFSET_0200, OFFSET_0300); ZoneOffsetTransition a2 = ZoneOffsetTransition.of(ldtA, OFFSET_0200, OFFSET_0300); LocalDateTime ldtB = LocalDateTime.of(2010, 10, 31, 1, 0); --- 259,269 ---- } //----------------------------------------------------------------------- // hashCode() //----------------------------------------------------------------------- ! @Test public void test_hashCode_floatingWeek_gap_notEndOfDay() { LocalDateTime ldtA = LocalDateTime.of(2010, 3, 31, 1, 0); ZoneOffsetTransition a1 = ZoneOffsetTransition.of(ldtA, OFFSET_0200, OFFSET_0300); ZoneOffsetTransition a2 = ZoneOffsetTransition.of(ldtA, OFFSET_0200, OFFSET_0300); LocalDateTime ldtB = LocalDateTime.of(2010, 10, 31, 1, 0);
*** 274,291 **** } //----------------------------------------------------------------------- // toString() //----------------------------------------------------------------------- ! @Test(groups={"tck"}) public void test_toString_gap() { LocalDateTime ldt = LocalDateTime.of(2010, 3, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0200, OFFSET_0300); assertEquals(test.toString(), "Transition[Gap at 2010-03-31T01:00+02:00 to +03:00]"); } ! @Test(groups={"tck"}) public void test_toString_overlap() { LocalDateTime ldt = LocalDateTime.of(2010, 10, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0300, OFFSET_0200); assertEquals(test.toString(), "Transition[Overlap at 2010-10-31T01:00+03:00 to +02:00]"); } --- 275,292 ---- } //----------------------------------------------------------------------- // toString() //----------------------------------------------------------------------- ! @Test public void test_toString_gap() { LocalDateTime ldt = LocalDateTime.of(2010, 3, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0200, OFFSET_0300); assertEquals(test.toString(), "Transition[Gap at 2010-03-31T01:00+02:00 to +03:00]"); } ! @Test public void test_toString_overlap() { LocalDateTime ldt = LocalDateTime.of(2010, 10, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0300, OFFSET_0200); assertEquals(test.toString(), "Transition[Overlap at 2010-10-31T01:00+03:00 to +02:00]"); }