Search in sources :

Example 26 with Duration

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

the class TCKDuration method factory_days.

//-----------------------------------------------------------------------
// ofDays()
//-----------------------------------------------------------------------
@Test
public void factory_days() {
    Duration test = Duration.ofDays(2);
    assertEquals(test.getSeconds(), 2 * 86400);
    assertEquals(test.getNano(), 0);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 27 with Duration

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

the class TCKDuration method doTest_comparisons_Duration.

void doTest_comparisons_Duration(Duration... durations) {
    for (int i = 0; i < durations.length; i++) {
        Duration a = durations[i];
        for (int j = 0; j < durations.length; j++) {
            Duration b = durations[j];
            if (i < j) {
                assertEquals(a.compareTo(b) < 0, true, a + " <=> " + b);
                assertEquals(a.equals(b), false, a + " <=> " + b);
            } else if (i > j) {
                assertEquals(a.compareTo(b) > 0, true, a + " <=> " + b);
                assertEquals(a.equals(b), false, a + " <=> " + b);
            } else {
                assertEquals(a.compareTo(b), 0, a + " <=> " + b);
                assertEquals(a.equals(b), true, a + " <=> " + b);
            }
        }
    }
}
Also used : Duration(java.time.Duration)

Example 28 with Duration

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

the class TCKDuration method minusMillis_long_min.

@Test
public void minusMillis_long_min() {
    Duration t = Duration.ofSeconds(Long.MIN_VALUE, 1000000);
    t = t.minusMillis(1);
    assertEquals(t.getSeconds(), Long.MIN_VALUE);
    assertEquals(t.getNano(), 0);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 29 with Duration

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

the class TCKDuration method plus_longTemporalUnit_null.

@Test(expectedExceptions = NullPointerException.class)
public void plus_longTemporalUnit_null() {
    Duration t = Duration.ofSeconds(1);
    t.plus(1, (TemporalUnit) null);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 30 with Duration

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

the class TCKDuration method factory_nanos_nanos.

//-----------------------------------------------------------------------
// ofNanos(long)
//-----------------------------------------------------------------------
@Test
public void factory_nanos_nanos() {
    Duration test = Duration.ofNanos(1);
    assertEquals(test.getSeconds(), 0);
    assertEquals(test.getNano(), 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