Search in sources :

Example 6 with ChronoPeriod

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

the class TCKChronoPeriod method test_get_unsupported.

@Test(dataProvider = "calendars", expectedExceptions = UnsupportedTemporalTypeException.class)
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.testng.annotations.Test)

Example 7 with ChronoPeriod

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

the class TCKChronoPeriod method test_negated.

//-----------------------------------------------------------------------
@Test(dataProvider = "calendars")
public void test_negated(Chronology chrono) {
    ChronoPeriod period = chrono.period(1, 2, 3);
    assertEquals(period.negated(), chrono.period(-1, -2, -3));
}
Also used : ChronoPeriod(java.time.chrono.ChronoPeriod) Test(org.testng.annotations.Test)

Example 8 with ChronoPeriod

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

the class TCKChronoPeriod method test_addTo.

//-----------------------------------------------------------------------
@Test(dataProvider = "calendars")
public void test_addTo(Chronology chrono) {
    ChronoPeriod period = chrono.period(1, 2, 3);
    ChronoLocalDate date = chrono.dateNow();
    Temporal result = period.addTo(date);
    assertEquals(result, date.plus(14, MONTHS).plus(3, DAYS));
}
Also used : ChronoPeriod(java.time.chrono.ChronoPeriod) ChronoLocalDate(java.time.chrono.ChronoLocalDate) Temporal(java.time.temporal.Temporal) Test(org.testng.annotations.Test)

Example 9 with ChronoPeriod

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

the class TCKChronoPeriod method test_equals_notEqual.

@Test(dataProvider = "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.testng.annotations.Test)

Example 10 with ChronoPeriod

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

the class TCKChronoPeriod method test_subtractFrom.

@Test(dataProvider = "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.testng.annotations.Test)

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