use of java.time.chrono.ThaiBuddhistDate in project jdk8u_jdk by JetBrains.
the class TCKThaiBuddhistChronology method test_adjust2.
@Test
public void test_adjust2() {
ThaiBuddhistDate base = ThaiBuddhistChronology.INSTANCE.date(1728, 12, 2);
ThaiBuddhistDate test = base.with(TemporalAdjusters.lastDayOfMonth());
assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(1728, 12, 31));
}
use of java.time.chrono.ThaiBuddhistDate in project jdk8u_jdk by JetBrains.
the class TCKThaiBuddhistChronology method test_resolve_ymaa_strict.
@Test(dataProvider = "resolve_ymaa")
public void test_resolve_ymaa_strict(int y, int m, int w, int d, ThaiBuddhistDate expected, boolean smart, boolean strict) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
fieldValues.put(ChronoField.YEAR, (long) y);
fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m);
fieldValues.put(ChronoField.ALIGNED_WEEK_OF_MONTH, (long) w);
fieldValues.put(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH, (long) d);
if (strict) {
ThaiBuddhistDate date = ThaiBuddhistChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
assertEquals(date, expected);
assertEquals(fieldValues.size(), 0);
} else {
try {
ThaiBuddhistChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
fail("Should have failed");
} catch (DateTimeException ex) {
// expected
}
}
}
use of java.time.chrono.ThaiBuddhistDate in project jdk8u_jdk by JetBrains.
the class TCKThaiBuddhistChronology method test_periodUntilDate.
//-----------------------------------------------------------------------
// PeriodUntil()
//-----------------------------------------------------------------------
@Test
public void test_periodUntilDate() {
ThaiBuddhistDate mdate1 = ThaiBuddhistDate.of(1, 1, 1);
ThaiBuddhistDate mdate2 = ThaiBuddhistDate.of(2, 2, 2);
ChronoPeriod period = mdate1.until(mdate2);
assertEquals(period, ThaiBuddhistChronology.INSTANCE.period(1, 1, 1));
}
use of java.time.chrono.ThaiBuddhistDate in project jdk8u_jdk by JetBrains.
the class TCKThaiBuddhistChronology method test_adjust_toLocalDate.
//-----------------------------------------------------------------------
// BuddhistDate.with(Local*)
//-----------------------------------------------------------------------
@Test
public void test_adjust_toLocalDate() {
ThaiBuddhistDate jdate = ThaiBuddhistChronology.INSTANCE.date(1726, 1, 4);
ThaiBuddhistDate test = jdate.with(LocalDate.of(2012, 7, 6));
assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(2555, 7, 6));
}
use of java.time.chrono.ThaiBuddhistDate in project jdk8u_jdk by JetBrains.
the class TCKThaiBuddhistChronology method test_resolve_ymd_strict.
@Test(dataProvider = "resolve_ymd")
public void test_resolve_ymd_strict(int y, int m, int d, ThaiBuddhistDate expected, Object smart, boolean strict) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
fieldValues.put(ChronoField.YEAR, (long) y);
fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m);
fieldValues.put(ChronoField.DAY_OF_MONTH, (long) d);
if (strict) {
ThaiBuddhistDate date = ThaiBuddhistChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
assertEquals(date, expected);
assertEquals(fieldValues.size(), 0);
} else {
try {
ThaiBuddhistChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
fail("Should have failed");
} catch (DateTimeException ex) {
// expected
}
}
}
Aggregations