Search in sources :

Example 6 with MinguoDate

use of java.time.chrono.MinguoDate in project jdk8u_jdk by JetBrains.

the class TCKMinguoChronology method test_resolve_ymaa_smart.

@Test(dataProvider = "resolve_ymaa")
public void test_resolve_ymaa_smart(int y, int m, int w, int d, MinguoDate 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 (smart) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
            fail("Should have failed");
        } catch (DateTimeException ex) {
        // expected
        }
    }
}
Also used : MinguoDate(java.time.chrono.MinguoDate) TemporalField(java.time.temporal.TemporalField) DateTimeException(java.time.DateTimeException) HashMap(java.util.HashMap) Test(org.testng.annotations.Test)

Example 7 with MinguoDate

use of java.time.chrono.MinguoDate in project jdk8u_jdk by JetBrains.

the class TCKMinguoChronology method test_resolve_ymaa_strict.

@Test(dataProvider = "resolve_ymaa")
public void test_resolve_ymaa_strict(int y, int m, int w, int d, MinguoDate 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) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
            fail("Should have failed");
        } catch (DateTimeException ex) {
        // expected
        }
    }
}
Also used : MinguoDate(java.time.chrono.MinguoDate) TemporalField(java.time.temporal.TemporalField) DateTimeException(java.time.DateTimeException) HashMap(java.util.HashMap) Test(org.testng.annotations.Test)

Example 8 with MinguoDate

use of java.time.chrono.MinguoDate in project jdk8u_jdk by JetBrains.

the class TCKMinguoChronology method test_resolve_yd_smart.

@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_smart(int y, int d, MinguoDate expected, boolean smart, boolean strict) {
    Map<TemporalField, Long> fieldValues = new HashMap<>();
    fieldValues.put(ChronoField.YEAR, (long) y);
    fieldValues.put(ChronoField.DAY_OF_YEAR, (long) d);
    if (smart) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
            fail("Should have failed");
        } catch (DateTimeException ex) {
        // expected
        }
    }
}
Also used : MinguoDate(java.time.chrono.MinguoDate) TemporalField(java.time.temporal.TemporalField) DateTimeException(java.time.DateTimeException) HashMap(java.util.HashMap) Test(org.testng.annotations.Test)

Example 9 with MinguoDate

use of java.time.chrono.MinguoDate in project jdk8u_jdk by JetBrains.

the class TCKMinguoChronology method test_periodUntilDate.

//-----------------------------------------------------------------------
// PeriodUntil()
//-----------------------------------------------------------------------
@Test
public void test_periodUntilDate() {
    MinguoDate mdate1 = MinguoDate.of(1970, 1, 1);
    MinguoDate mdate2 = MinguoDate.of(1971, 2, 2);
    ChronoPeriod period = mdate1.until(mdate2);
    assertEquals(period, MinguoChronology.INSTANCE.period(1, 1, 1));
}
Also used : ChronoPeriod(java.time.chrono.ChronoPeriod) MinguoDate(java.time.chrono.MinguoDate) Test(org.testng.annotations.Test)

Example 10 with MinguoDate

use of java.time.chrono.MinguoDate in project jdk8u_jdk by JetBrains.

the class TCKMinguoChronology method test_resolve_yearOfEra.

@Test(dataProvider = "resolve_yearOfEra")
public void test_resolve_yearOfEra(ResolverStyle style, Integer e, Integer yoe, Integer y, ChronoField field, Integer expected) {
    Map<TemporalField, Long> fieldValues = new HashMap<>();
    if (e != null) {
        fieldValues.put(ChronoField.ERA, (long) e);
    }
    if (yoe != null) {
        fieldValues.put(ChronoField.YEAR_OF_ERA, (long) yoe);
    }
    if (y != null) {
        fieldValues.put(ChronoField.YEAR, (long) y);
    }
    if (field != null) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, style);
        assertEquals(date, null);
        assertEquals(fieldValues.get(field), (Long) expected.longValue());
        assertEquals(fieldValues.size(), 1);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, style);
            fail("Should have failed");
        } catch (DateTimeException ex) {
        // expected
        }
    }
}
Also used : MinguoDate(java.time.chrono.MinguoDate) TemporalField(java.time.temporal.TemporalField) DateTimeException(java.time.DateTimeException) HashMap(java.util.HashMap) Test(org.testng.annotations.Test)

Aggregations

MinguoDate (java.time.chrono.MinguoDate)31 Test (org.testng.annotations.Test)29 TemporalField (java.time.temporal.TemporalField)10 HashMap (java.util.HashMap)10 DateTimeException (java.time.DateTimeException)7 ChronoPeriod (java.time.chrono.ChronoPeriod)5 DateTimeFormatter (java.time.format.DateTimeFormatter)5 DateTimeFormatterBuilder (java.time.format.DateTimeFormatterBuilder)3 TemporalAccessor (java.time.temporal.TemporalAccessor)3 ThaiBuddhistDate (java.time.chrono.ThaiBuddhistDate)2 LocalDate (java.time.LocalDate)1 LocalDateTime (java.time.LocalDateTime)1 OffsetDateTime (java.time.OffsetDateTime)1 ZoneOffset (java.time.ZoneOffset)1 ZonedDateTime (java.time.ZonedDateTime)1 ChronoLocalDate (java.time.chrono.ChronoLocalDate)1 ChronoLocalDateTime (java.time.chrono.ChronoLocalDateTime)1 ChronoZonedDateTime (java.time.chrono.ChronoZonedDateTime)1 JapaneseDate (java.time.chrono.JapaneseDate)1