test/java/time/tck/java/time/TCKInstant.java
Print this page
*** 568,589 ****
//-----------------------------------------------------------------------
// truncated(TemporalUnit)
//-----------------------------------------------------------------------
TemporalUnit NINETY_MINS = new TemporalUnit() {
@Override
- public String getName() {
- return "NinetyMins";
- }
- @Override
public Duration getDuration() {
return Duration.ofMinutes(90);
}
@Override
public boolean isDurationEstimated() {
return false;
}
@Override
public boolean isSupportedBy(Temporal temporal) {
return false;
}
@Override
public <R extends Temporal> R addTo(R temporal, long amount) {
--- 568,593 ----
//-----------------------------------------------------------------------
// truncated(TemporalUnit)
//-----------------------------------------------------------------------
TemporalUnit NINETY_MINS = new TemporalUnit() {
@Override
public Duration getDuration() {
return Duration.ofMinutes(90);
}
@Override
public boolean isDurationEstimated() {
return false;
}
@Override
+ public boolean isDateBased() {
+ return false;
+ }
+ @Override
+ public boolean isTimeBased() {
+ return true;
+ }
+ @Override
public boolean isSupportedBy(Temporal temporal) {
return false;
}
@Override
public <R extends Temporal> R addTo(R temporal, long amount) {
*** 591,616 ****
}
@Override
public long between(Temporal temporal1, Temporal temporal2) {
throw new UnsupportedOperationException();
}
};
TemporalUnit NINETY_FIVE_MINS = new TemporalUnit() {
@Override
- public String getName() {
- return "NinetyFiveMins";
- }
- @Override
public Duration getDuration() {
return Duration.ofMinutes(95);
}
@Override
public boolean isDurationEstimated() {
return false;
}
@Override
public boolean isSupportedBy(Temporal temporal) {
return false;
}
@Override
public <R extends Temporal> R addTo(R temporal, long amount) {
--- 595,628 ----
}
@Override
public long between(Temporal temporal1, Temporal temporal2) {
throw new UnsupportedOperationException();
}
+ @Override
+ public String toString() {
+ return "NinetyMins";
+ }
};
TemporalUnit NINETY_FIVE_MINS = new TemporalUnit() {
@Override
public Duration getDuration() {
return Duration.ofMinutes(95);
}
@Override
public boolean isDurationEstimated() {
return false;
}
@Override
+ public boolean isDateBased() {
+ return false;
+ }
+ @Override
+ public boolean isTimeBased() {
+ return false;
+ }
+ @Override
public boolean isSupportedBy(Temporal temporal) {
return false;
}
@Override
public <R extends Temporal> R addTo(R temporal, long amount) {
*** 618,627 ****
--- 630,643 ----
}
@Override
public long between(Temporal temporal1, Temporal temporal2) {
throw new UnsupportedOperationException();
}
+ @Override
+ public String toString() {
+ return "NinetyFiveMins";
+ }
};
@DataProvider(name="truncatedToValid")
Object[][] data_truncatedToValid() {
return new Object[][] {
*** 1707,1717 ****
Instant i = Instant.ofEpochSecond(MIN_SECOND, 0);
i.minusNanos(1);
}
//-----------------------------------------------------------------------
! // periodUntil(Temporal, TemporalUnit)
//-----------------------------------------------------------------------
@DataProvider(name="periodUntilUnit")
Object[][] data_periodUntilUnit() {
return new Object[][] {
{5, 650, -1, 650, SECONDS, -6},
--- 1723,1733 ----
Instant i = Instant.ofEpochSecond(MIN_SECOND, 0);
i.minusNanos(1);
}
//-----------------------------------------------------------------------
! // until(Temporal, TemporalUnit)
//-----------------------------------------------------------------------
@DataProvider(name="periodUntilUnit")
Object[][] data_periodUntilUnit() {
return new Object[][] {
{5, 650, -1, 650, SECONDS, -6},
*** 1803,1837 ****
@Test(dataProvider="periodUntilUnit")
public void test_periodUntil_TemporalUnit(long seconds1, int nanos1, long seconds2, long nanos2, TemporalUnit unit, long expected) {
Instant i1 = Instant.ofEpochSecond(seconds1, nanos1);
Instant i2 = Instant.ofEpochSecond(seconds2, nanos2);
! long amount = i1.periodUntil(i2, unit);
assertEquals(amount, expected);
}
@Test(dataProvider="periodUntilUnit")
public void test_periodUntil_TemporalUnit_negated(long seconds1, int nanos1, long seconds2, long nanos2, TemporalUnit unit, long expected) {
Instant i1 = Instant.ofEpochSecond(seconds1, nanos1);
Instant i2 = Instant.ofEpochSecond(seconds2, nanos2);
! long amount = i2.periodUntil(i1, unit);
assertEquals(amount, -expected);
}
@Test(expectedExceptions = UnsupportedTemporalTypeException.class)
public void test_periodUntil_TemporalUnit_unsupportedUnit() {
! TEST_12345_123456789.periodUntil(TEST_12345_123456789, MONTHS);
}
@Test(expectedExceptions = NullPointerException.class)
public void test_periodUntil_TemporalUnit_nullEnd() {
! TEST_12345_123456789.periodUntil(null, HOURS);
}
@Test(expectedExceptions = NullPointerException.class)
public void test_periodUntil_TemporalUnit_nullUnit() {
! TEST_12345_123456789.periodUntil(TEST_12345_123456789, null);
}
//-----------------------------------------------------------------------
// atOffset()
//-----------------------------------------------------------------------
--- 1819,1853 ----
@Test(dataProvider="periodUntilUnit")
public void test_periodUntil_TemporalUnit(long seconds1, int nanos1, long seconds2, long nanos2, TemporalUnit unit, long expected) {
Instant i1 = Instant.ofEpochSecond(seconds1, nanos1);
Instant i2 = Instant.ofEpochSecond(seconds2, nanos2);
! long amount = i1.until(i2, unit);
assertEquals(amount, expected);
}
@Test(dataProvider="periodUntilUnit")
public void test_periodUntil_TemporalUnit_negated(long seconds1, int nanos1, long seconds2, long nanos2, TemporalUnit unit, long expected) {
Instant i1 = Instant.ofEpochSecond(seconds1, nanos1);
Instant i2 = Instant.ofEpochSecond(seconds2, nanos2);
! long amount = i2.until(i1, unit);
assertEquals(amount, -expected);
}
@Test(expectedExceptions = UnsupportedTemporalTypeException.class)
public void test_periodUntil_TemporalUnit_unsupportedUnit() {
! TEST_12345_123456789.until(TEST_12345_123456789, MONTHS);
}
@Test(expectedExceptions = NullPointerException.class)
public void test_periodUntil_TemporalUnit_nullEnd() {
! TEST_12345_123456789.until(null, HOURS);
}
@Test(expectedExceptions = NullPointerException.class)
public void test_periodUntil_TemporalUnit_nullUnit() {
! TEST_12345_123456789.until(TEST_12345_123456789, null);
}
//-----------------------------------------------------------------------
// atOffset()
//-----------------------------------------------------------------------