use of java.util.OptionalLong in project jdk8u_jdk by JetBrains.
the class BasicLong method testEmptyOrElseThrowNull.
@Test(expectedExceptions = NullPointerException.class)
public void testEmptyOrElseThrowNull() throws Throwable {
OptionalLong empty = OptionalLong.empty();
long got = empty.orElseThrow(null);
}
use of java.util.OptionalLong in project jdk8u_jdk by JetBrains.
the class BasicLong method testEmptyOrElseGetNull.
@Test(expectedExceptions = NullPointerException.class)
public void testEmptyOrElseGetNull() {
OptionalLong empty = OptionalLong.empty();
long got = empty.orElseGet(null);
}
use of java.util.OptionalLong in project jdk8u_jdk by JetBrains.
the class BasicLong method testEmpty.
@Test(groups = "unit")
public void testEmpty() {
OptionalLong empty = OptionalLong.empty();
OptionalLong present = OptionalLong.of(1);
// empty
assertTrue(empty.equals(empty));
assertTrue(empty.equals(OptionalLong.empty()));
assertTrue(!empty.equals(present));
assertTrue(0 == empty.hashCode());
assertTrue(!empty.toString().isEmpty());
assertTrue(!empty.isPresent());
empty.ifPresent(v -> {
fail();
});
assertEquals(2, empty.orElse(2));
assertEquals(2, empty.orElseGet(() -> 2));
}
Aggregations