Search in sources :

Example 41 with ChronoPeriod

use of java.time.chrono.ChronoPeriod in project j2objc by google.

the class TCKChronoPeriod method test_get.

@Test()
@UseDataProvider("data_of_calendars")
public void test_get(Chronology chrono) {
    ChronoPeriod period = chrono.period(1, 2, 3);
    assertEquals(period.get(YEARS), 1);
    assertEquals(period.get(MONTHS), 2);
    assertEquals(period.get(DAYS), 3);
}
Also used : ChronoPeriod(java.time.chrono.ChronoPeriod) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 42 with ChronoPeriod

use of java.time.chrono.ChronoPeriod in project j2objc by google.

the class TCKChronoPeriod method test_multipliedBy.

@Test()
@UseDataProvider("data_of_calendars")
public void test_multipliedBy(Chronology chrono) {
    ChronoPeriod period = chrono.period(1, 2, 3);
    assertEquals(period.multipliedBy(3), chrono.period(3, 6, 9));
}
Also used : ChronoPeriod(java.time.chrono.ChronoPeriod) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 43 with ChronoPeriod

use of java.time.chrono.ChronoPeriod in project j2objc by google.

the class TCKChronoPeriod method test_equals_notEqual.

@Test()
@UseDataProvider("data_of_calendars")
public void test_equals_notEqual(Chronology chrono) {
    ChronoPeriod a = chrono.period(1, 2, 3);
    ChronoPeriod b = chrono.period(2, 2, 3);
    assertEquals(a.equals(b), false);
    assertEquals(b.equals(a), false);
    assertEquals(a.equals(""), false);
    assertEquals(a.equals(null), false);
}
Also used : ChronoPeriod(java.time.chrono.ChronoPeriod) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 44 with ChronoPeriod

use of java.time.chrono.ChronoPeriod in project j2objc by google.

the class TCKChronoPeriod method test_subtractFrom.

/* J2ObjC removed: Only "gregorian" and "julian" calendars are supported.
    @Test(expected=DateTimeException.class)
    @UseDataProvider("data_of_calendars")
    public void test_addTo_wrongChrono(Chronology chrono) {
        ChronoPeriod period = chrono.period(1, 2, 3);
        ChronoLocalDate isoDate = LocalDate.of(2000, 1, 1);
        ChronoLocalDate thaiDate = ThaiBuddhistChronology.INSTANCE.date(2000, 1, 1);
        // one of these two will fail
        period.addTo(isoDate);
        period.addTo(thaiDate);
    } */
@Test()
@UseDataProvider("data_of_calendars")
public void test_subtractFrom(Chronology chrono) {
    ChronoPeriod period = chrono.period(1, 2, 3);
    ChronoLocalDate date = chrono.dateNow();
    Temporal result = period.subtractFrom(date);
    assertEquals(result, date.minus(14, MONTHS).minus(3, DAYS));
}
Also used : ChronoPeriod(java.time.chrono.ChronoPeriod) ChronoLocalDate(java.time.chrono.ChronoLocalDate) Temporal(java.time.temporal.Temporal) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 45 with ChronoPeriod

use of java.time.chrono.ChronoPeriod in project j2objc by google.

the class TCKChronoPeriod method test_get_unsupported.

@Test(expected = UnsupportedTemporalTypeException.class)
@UseDataProvider("data_of_calendars")
public void test_get_unsupported(Chronology chrono) {
    ChronoPeriod period = chrono.period(1, 2, 3);
    period.get(HOURS);
}
Also used : ChronoPeriod(java.time.chrono.ChronoPeriod) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Aggregations

ChronoPeriod (java.time.chrono.ChronoPeriod)55 Test (org.testng.annotations.Test)26 Test (org.junit.Test)21 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)14 ChronoLocalDate (java.time.chrono.ChronoLocalDate)6 MinguoDate (java.time.chrono.MinguoDate)5 List (java.util.List)5 BigDecimal (java.math.BigDecimal)4 Period (java.time.Period)4 ChronoUnit (java.time.temporal.ChronoUnit)4 Temporal (java.time.temporal.Temporal)4 TemporalAccessor (java.time.temporal.TemporalAccessor)4 Arrays (java.util.Arrays)4 Collections (java.util.Collections)4 Predicate (java.util.function.Predicate)4 Before (org.junit.Before)4 ComparablePeriod (org.kie.dmn.feel.lang.types.impl.ComparablePeriod)4 Duration (java.time.Duration)3 ThaiBuddhistDate (java.time.chrono.ThaiBuddhistDate)3 TemporalUnit (java.time.temporal.TemporalUnit)3