Search in sources :

Example 11 with Period

use of java.time.Period in project jdk8u_jdk by JetBrains.

the class TCKPeriod method test_plusDays_overflowTooBig.

@Test(expectedExceptions = ArithmeticException.class)
public void test_plusDays_overflowTooBig() {
    Period test = Period.ofDays(Integer.MAX_VALUE);
    test.plusDays(1);
}
Also used : Period(java.time.Period) Test(org.testng.annotations.Test)

Example 12 with Period

use of java.time.Period in project jdk8u_jdk by JetBrains.

the class TCKPeriod method test_equals_self.

public void test_equals_self() {
    Period test = Period.of(1, 2, 3);
    assertEquals(test.equals(test), true);
}
Also used : Period(java.time.Period)

Example 13 with Period

use of java.time.Period in project jdk8u_jdk by JetBrains.

the class TCKPeriod method test_Period_getUnits.

//-----------------------------------------------------------------------
// get units
//-----------------------------------------------------------------------
@Test
public void test_Period_getUnits() {
    Period period = Period.of(2012, 1, 1);
    List<TemporalUnit> units = period.getUnits();
    assertEquals(units.size(), 3, "Period.getUnits should return 3 units");
    assertEquals(units.get(0), ChronoUnit.YEARS, "Period.getUnits contains ChronoUnit.YEARS");
    assertEquals(units.get(1), ChronoUnit.MONTHS, "Period.getUnits contains ChronoUnit.MONTHS");
    assertEquals(units.get(2), ChronoUnit.DAYS, "Period.getUnits contains ChronoUnit.DAYS");
}
Also used : TemporalUnit(java.time.temporal.TemporalUnit) Period(java.time.Period) Test(org.testng.annotations.Test)

Example 14 with Period

use of java.time.Period in project jdk8u_jdk by JetBrains.

the class TCKPeriod method test_multipliedBy.

//-----------------------------------------------------------------------
// multipliedBy()
//-----------------------------------------------------------------------
@Test
public void test_multipliedBy() {
    Period test = Period.of(1, 2, 3);
    assertPeriod(test.multipliedBy(0), 0, 0, 0);
    assertPeriod(test.multipliedBy(1), 1, 2, 3);
    assertPeriod(test.multipliedBy(2), 2, 4, 6);
    assertPeriod(test.multipliedBy(-3), -3, -6, -9);
}
Also used : Period(java.time.Period) Test(org.testng.annotations.Test)

Example 15 with Period

use of java.time.Period in project jdk8u_jdk by JetBrains.

the class TCKPeriod method test_minusDays_overflowTooBig.

@Test(expectedExceptions = ArithmeticException.class)
public void test_minusDays_overflowTooBig() {
    Period test = Period.ofDays(Integer.MAX_VALUE);
    test.minusDays(-1);
}
Also used : Period(java.time.Period) Test(org.testng.annotations.Test)

Aggregations

Period (java.time.Period)108 Test (org.junit.Test)38 Test (org.testng.annotations.Test)27 LocalDate (java.time.LocalDate)20 Duration (java.time.Duration)9 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)8 LocalDateTime (java.time.LocalDateTime)7 ZonedDateTime (java.time.ZonedDateTime)7 Date (java.util.Date)6 LocalTime (java.time.LocalTime)5 ZoneId (java.time.ZoneId)5 DateTimeFormatter (java.time.format.DateTimeFormatter)5 List (java.util.List)5 Test (org.junit.jupiter.api.Test)5 Instant (java.time.Instant)4 DateTimeParseException (java.time.format.DateTimeParseException)4 Temporal (java.time.temporal.Temporal)4 TemporalAmount (java.time.temporal.TemporalAmount)4 Arrays (java.util.Arrays)4 Collectors (java.util.stream.Collectors)4