Search in sources :

Example 31 with Duration

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

the class TCKDuration method plusDays_long.

@Test(dataProvider = "PlusDays")
public void plusDays_long(long days, long amount, long expectedDays) {
    Duration t = Duration.ofDays(days);
    t = t.plusDays(amount);
    assertEquals(t.toDays(), expectedDays);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 32 with Duration

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

the class TCKDuration method test_getUnit.

@Test()
public void test_getUnit() {
    Duration test = Duration.ofSeconds(2000, 1000);
    long seconds = test.get(ChronoUnit.SECONDS);
    assertEquals(seconds, 2000, "duration.get(SECONDS)");
    long nanos = test.get(ChronoUnit.NANOS);
    assertEquals(nanos, 1000, "duration.get(NANOS)");
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 33 with Duration

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

the class TCKDuration method plusNanos_long_overflowTooBig.

@Test(expectedExceptions = { ArithmeticException.class })
public void plusNanos_long_overflowTooBig() {
    Duration t = Duration.ofSeconds(Long.MAX_VALUE, 999999999);
    t.plusNanos(1);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 34 with Duration

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

the class TCKDuration method factory_nanos_min.

@Test
public void factory_nanos_min() {
    Duration test = Duration.ofNanos(Long.MIN_VALUE);
    assertEquals(test.getSeconds(), Long.MIN_VALUE / 1000000000 - 1);
    assertEquals(test.getNano(), Long.MIN_VALUE % 1000000000 + 1000000000);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 35 with Duration

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

the class TCKDuration method plusMillis_long_overflowTooSmall.

@Test(expectedExceptions = { ArithmeticException.class })
public void plusMillis_long_overflowTooSmall() {
    Duration t = Duration.ofSeconds(Long.MIN_VALUE, 0);
    t.plusMillis(-1);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Aggregations

Duration (java.time.Duration)1205 Test (org.junit.Test)418 Test (org.testng.annotations.Test)139 Instant (java.time.Instant)128 Test (org.junit.jupiter.api.Test)83 List (java.util.List)82 ArrayList (java.util.ArrayList)81 CompletableFuture (java.util.concurrent.CompletableFuture)81 Collectors (java.util.stream.Collectors)73 Collections (java.util.Collections)62 Preconditions (com.google.common.base.Preconditions)61 Map (java.util.Map)60 Slf4j (lombok.extern.slf4j.Slf4j)59 lombok.val (lombok.val)55 HashMap (java.util.HashMap)54 Arrays (java.util.Arrays)52 Function (java.util.function.Function)51 IOException (java.io.IOException)49 HashSet (java.util.HashSet)47 TimeUnit (java.util.concurrent.TimeUnit)47