Search in sources :

Example 21 with Duration

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

the class TCKDuration method factory_parse.

@Test(dataProvider = "parseSuccess")
public void factory_parse(String text, long expectedSeconds, int expectedNanoOfSecond) {
    Duration test = Duration.parse(text);
    assertEquals(test.getSeconds(), expectedSeconds);
    assertEquals(test.getNano(), expectedNanoOfSecond);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 22 with Duration

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

the class TCKDuration method minusNanos_long_overflowTooSmall.

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

Example 23 with Duration

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

the class TCKDuration method minusMillis_long_overflowTooSmall.

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

Example 24 with Duration

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

the class TCKDuration method test_toString.

@Test(dataProvider = "toString")
public void test_toString(long seconds, int nanos, String expected) {
    Duration t = Duration.ofSeconds(seconds, nanos);
    assertEquals(t.toString(), expected);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 25 with Duration

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

the class TCKDuration method test_toMillis_tooBig.

@Test(expectedExceptions = ArithmeticException.class)
public void test_toMillis_tooBig() {
    Duration test = Duration.ofSeconds(Long.MAX_VALUE / 1000, ((Long.MAX_VALUE % 1000) + 1) * 1000000);
    test.toMillis();
}
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