Search in sources :

Example 11 with Duration

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

the class TCKDuration method factory_between_TemporalTemporal_LT.

@Test(dataProvider = "durationBetweenLocalTime")
public void factory_between_TemporalTemporal_LT(LocalTime start, LocalTime end, long expectedSeconds, int expectedNanoOfSecond) {
    Duration t = Duration.between(start, end);
    assertEquals(t.getSeconds(), expectedSeconds);
    assertEquals(t.getNano(), expectedNanoOfSecond);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 12 with Duration

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

the class TCKDuration method test_toMillis.

//-----------------------------------------------------------------------
// toMillis()
//-----------------------------------------------------------------------
@Test
public void test_toMillis() {
    Duration test = Duration.ofSeconds(321, 123456789);
    assertEquals(test.toMillis(), 321000 + 123);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 13 with Duration

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

the class TCKDuration method minusDays_long.

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

Example 14 with Duration

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

the class TCKDuration method test_equals.

//-----------------------------------------------------------------------
// equals()
//-----------------------------------------------------------------------
@Test
public void test_equals() {
    Duration test5a = Duration.ofSeconds(5L, 20);
    Duration test5b = Duration.ofSeconds(5L, 20);
    Duration test5n = Duration.ofSeconds(5L, 30);
    Duration test6 = Duration.ofSeconds(6L, 20);
    assertEquals(test5a.equals(test5a), true);
    assertEquals(test5a.equals(test5b), true);
    assertEquals(test5a.equals(test5n), false);
    assertEquals(test5a.equals(test6), false);
    assertEquals(test5b.equals(test5a), true);
    assertEquals(test5b.equals(test5b), true);
    assertEquals(test5b.equals(test5n), false);
    assertEquals(test5b.equals(test6), false);
    assertEquals(test5n.equals(test5a), false);
    assertEquals(test5n.equals(test5b), false);
    assertEquals(test5n.equals(test5n), true);
    assertEquals(test5n.equals(test6), false);
    assertEquals(test6.equals(test5a), false);
    assertEquals(test6.equals(test5b), false);
    assertEquals(test6.equals(test5n), false);
    assertEquals(test6.equals(test6), true);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 15 with Duration

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

the class TCKDuration method plusSeconds_long_overflowTooSmall.

@Test(expectedExceptions = { ArithmeticException.class })
public void plusSeconds_long_overflowTooSmall() {
    Duration t = Duration.ofSeconds(-1, 0);
    t.plusSeconds(Long.MIN_VALUE);
}
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