Search in sources :

Example 6 with Period

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

the class TCKPeriod method factory_parse_plus.

@Test(dataProvider = "parseSuccess")
public void factory_parse_plus(String text, Period expected) {
    Period p = Period.parse("+" + text);
    assertEquals(p, expected);
}
Also used : Period(java.time.Period) Test(org.testng.annotations.Test)

Example 7 with Period

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

the class TCKPeriod method test_plusMonths_overflowTooSmall.

@Test(expectedExceptions = ArithmeticException.class)
public void test_plusMonths_overflowTooSmall() {
    Period test = Period.ofMonths(Integer.MIN_VALUE);
    test.plusMonths(-1);
}
Also used : Period(java.time.Period) Test(org.testng.annotations.Test)

Example 8 with Period

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

the class TCKPeriod method test_multipliedBy_overflowTooBig.

@Test(expectedExceptions = ArithmeticException.class)
public void test_multipliedBy_overflowTooBig() {
    Period test = Period.ofYears(Integer.MAX_VALUE / 2 + 1);
    test.multipliedBy(2);
}
Also used : Period(java.time.Period) Test(org.testng.annotations.Test)

Example 9 with Period

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

the class TCKPeriod method test_minusDays_overflowTooSmall.

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

Example 10 with Period

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

the class TCKPeriod method test_good_getUnit.

@Test(dataProvider = "GoodTemporalUnit")
public void test_good_getUnit(long amount, TemporalUnit unit) {
    Period period = Period.of(2, 2, 2);
    long actual = period.get(unit);
    assertEquals(actual, amount, "Value of unit: " + unit);
}
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