Search in sources :

Example 76 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 77 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 78 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)

Example 79 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 80 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)

Aggregations

Duration (java.time.Duration)195 Test (org.testng.annotations.Test)135 Instant (java.time.Instant)17 Test (org.junit.Test)16 List (java.util.List)6 Map (java.util.Map)4 ZonedDateTime (java.time.ZonedDateTime)3 ArrayList (java.util.ArrayList)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 ReplSetHeartbeatReply (com.torodb.mongodb.commands.signatures.internal.ReplSetHeartbeatReply)2 LocalDateTime (java.time.LocalDateTime)2 OffsetDateTime (java.time.OffsetDateTime)2 ZoneId (java.time.ZoneId)2 DateTimeFormatter (java.time.format.DateTimeFormatter)2 Iterator (java.util.Iterator)2 Optional (java.util.Optional)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 Collectors (java.util.stream.Collectors)2 Edge (org.apache.tinkerpop.gremlin.structure.Edge)2 JSONLexer (com.alibaba.fastjson.parser.JSONLexer)1