use of java.time.ZoneOffset in project j2objc by google.
the class TCKZoneOffset method test_compareTo.
// -----------------------------------------------------------------------
// compareTo()
// -----------------------------------------------------------------------
@Test
public void test_compareTo() {
ZoneOffset offset1 = ZoneOffset.ofHoursMinutesSeconds(1, 2, 3);
ZoneOffset offset2 = ZoneOffset.ofHoursMinutesSeconds(2, 3, 4);
assertTrue(offset1.compareTo(offset2) > 0);
assertTrue(offset2.compareTo(offset1) < 0);
assertTrue(offset1.compareTo(offset1) == 0);
assertTrue(offset2.compareTo(offset2) == 0);
}
use of java.time.ZoneOffset in project j2objc by google.
the class TCKZoneOffset method test_equals.
// -----------------------------------------------------------------------
// equals() / hashCode()
// -----------------------------------------------------------------------
@Test
public void test_equals() {
ZoneOffset offset1 = ZoneOffset.ofHoursMinutesSeconds(1, 2, 3);
ZoneOffset offset2 = ZoneOffset.ofHoursMinutesSeconds(2, 3, 4);
ZoneOffset offset2b = ZoneOffset.ofHoursMinutesSeconds(2, 3, 4);
assertEquals(offset1.equals(offset2), false);
assertEquals(offset2.equals(offset1), false);
assertEquals(offset1.equals(offset1), true);
assertEquals(offset2.equals(offset2), true);
assertEquals(offset2.equals(offset2b), true);
assertEquals(offset1.hashCode() == offset1.hashCode(), true);
assertEquals(offset2.hashCode() == offset2.hashCode(), true);
assertEquals(offset2.hashCode() == offset2b.hashCode(), true);
}
use of java.time.ZoneOffset in project j2objc by google.
the class TCKZoneOffset method test_constant_UTC.
// -----------------------------------------------------------------------
// constants
// -----------------------------------------------------------------------
@Test
public void test_constant_UTC() {
ZoneOffset test = ZoneOffset.UTC;
doTestOffset(test, 0, 0, 0);
}
use of java.time.ZoneOffset in project j2objc by google.
the class TCKOffsetDateTime method now_Clock_offsets.
@Test
public void now_Clock_offsets() {
OffsetDateTime base = OffsetDateTime.of(1970, 1, 1, 12, 0, 0, 0, ZoneOffset.UTC);
for (int i = -9; i < 15; i++) {
ZoneOffset offset = ZoneOffset.ofHours(i);
Clock clock = Clock.fixed(base.toInstant(), offset);
OffsetDateTime test = OffsetDateTime.now(clock);
assertEquals(test.getHour(), (12 + i) % 24);
assertEquals(test.getMinute(), 0);
assertEquals(test.getSecond(), 0);
assertEquals(test.getNano(), 0);
assertEquals(test.getOffset(), offset);
}
}
use of java.time.ZoneOffset in project j2objc by google.
the class TCKZoneId method test_invalidPrefixOfOffset.
@Test(expected = java.lang.IllegalArgumentException.class)
@UseDataProvider("data_prefixInvalid")
public void test_invalidPrefixOfOffset(String prefix, String offset) {
ZoneOffset zoff = ZoneOffset.of(offset);
ZoneId zoneId = ZoneId.ofOffset(prefix, zoff);
fail("should have thrown an exception for prefix: " + prefix);
}
Aggregations