use of java.time.temporal.TemporalUnit in project j2objc by google.
the class TCKChronoZonedDateTime method test_badMinusTemporalUnitChrono.
@Test()
@UseDataProvider("data_of_calendars")
public void test_badMinusTemporalUnitChrono(Chronology chrono) {
LocalDate refDate = LocalDate.of(2013, 1, 1);
ChronoZonedDateTime<?> czdt = chrono.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC);
for (Chronology[] clist : (Chronology[][]) data_of_calendars()) {
Chronology chrono2 = clist[0];
ChronoZonedDateTime<?> czdt2 = chrono2.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC);
TemporalUnit adjuster = new FixedTemporalUnit(czdt2);
if (chrono != chrono2) {
try {
czdt.minus(1, adjuster);
Assert.fail("TemporalUnit.doPlus minus should have thrown a ClassCastException, " + czdt.getClass() + " can not be cast to " + czdt2.getClass());
} catch (ClassCastException cce) {
// Expected exception; not an error
}
} else {
// Same chronology,
ChronoZonedDateTime<?> result = czdt.minus(1, adjuster);
assertEquals("WithAdjuster failed to replace date", result, czdt2);
}
}
}
use of java.time.temporal.TemporalUnit in project j2objc by google.
the class TCKChronoLocalDateTime method test_badMinusTemporalUnitChrono.
@Test
@UseDataProvider("data_of_calendars")
public void test_badMinusTemporalUnitChrono(Chronology chrono) {
LocalDate refDate = LocalDate.of(2013, 1, 1);
ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON);
for (Chronology[] clist : (Chronology[][]) data_of_calendars()) {
Chronology chrono2 = clist[0];
ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON);
TemporalUnit adjuster = new FixedTemporalUnit(cdt2);
if (chrono != chrono2) {
try {
cdt.minus(1, adjuster);
Assert.fail("TemporalUnit.doPlus minus should have thrown a ClassCastException" + cdt.getClass() + ", can not be cast to " + cdt2.getClass());
} catch (ClassCastException cce) {
// Expected exception; not an error
}
} else {
// Same chronology,
ChronoLocalDateTime<?> result = cdt.minus(1, adjuster);
assertEquals("WithAdjuster failed to replace date", result, cdt2);
}
}
}
use of java.time.temporal.TemporalUnit in project j2objc by google.
the class TCKChronoLocalDateTime method test_badPlusTemporalUnitChrono.
@Test
@UseDataProvider("data_of_calendars")
public void test_badPlusTemporalUnitChrono(Chronology chrono) {
LocalDate refDate = LocalDate.of(2013, 1, 1);
ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON);
for (Chronology[] clist : (Chronology[][]) data_of_calendars()) {
Chronology chrono2 = clist[0];
ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON);
TemporalUnit adjuster = new FixedTemporalUnit(cdt2);
if (chrono != chrono2) {
try {
cdt.plus(1, adjuster);
Assert.fail("TemporalUnit.doPlus plus should have thrown a ClassCastException" + cdt + ", can not be cast to " + cdt2);
} catch (ClassCastException cce) {
// Expected exception; not an error
}
} else {
// Same chronology,
ChronoLocalDateTime<?> result = cdt.plus(1, adjuster);
assertEquals("WithAdjuster failed to replace date", result, cdt2);
}
}
}
use of java.time.temporal.TemporalUnit in project j2objc by google.
the class TCKChronoLocalDate method test_badMinusTemporalUnitChrono.
@Test
@UseDataProvider("data_of_calendars")
public void test_badMinusTemporalUnitChrono(Chronology chrono) {
LocalDate refDate = LocalDate.of(2013, 1, 1);
ChronoLocalDate date = chrono.date(refDate);
for (Chronology[] clist : (Chronology[][]) data_of_calendars()) {
Chronology chrono2 = clist[0];
ChronoLocalDate date2 = chrono2.date(refDate);
TemporalUnit adjuster = new FixedTemporalUnit(date2);
if (chrono != chrono2) {
try {
date.minus(1, adjuster);
Assert.fail("TemporalUnit.doAdd minus should have thrown a ClassCastException" + date.getClass() + ", can not be cast to " + date2.getClass());
} catch (ClassCastException cce) {
// Expected exception; not an error
}
} else {
// Same chronology,
ChronoLocalDate result = date.minus(1, adjuster);
assertEquals("WithAdjuster failed to replace date", result, date2);
}
}
}
use of java.time.temporal.TemporalUnit in project j2objc by google.
the class TCKLocalTime method test_minus_longTemporalUnit_invalidUnit.
@Test
public void test_minus_longTemporalUnit_invalidUnit() {
for (TemporalUnit unit : INVALID_UNITS) {
try {
TEST_12_30_40_987654321.minus(1, unit);
fail("Unit should not be allowed " + unit);
} catch (DateTimeException ex) {
// expected
}
}
}
Aggregations