add test for equality with non-optional JDK-8195649-branch
authorsmarks
Wed, 28 Mar 2018 23:43:54 -0700
branchJDK-8195649-branch
changeset 56364 ed0bfd119607
parent 56360 44f4a81c3b96
child 56375 e0530ee8af48
add test for equality with non-optional
test/jdk/java/util/Optional/Basic.java
--- a/test/jdk/java/util/Optional/Basic.java	Wed Mar 28 15:24:53 2018 -0700
+++ b/test/jdk/java/util/Optional/Basic.java	Wed Mar 28 23:43:54 2018 -0700
@@ -62,8 +62,10 @@
     void checkEmpty(Optional<String> empty) {
         assertTrue(empty.equals(Optional.empty()));
         assertTrue(Optional.empty().equals(empty));
-        assertFalse(empty.equals(Optional.of("")));
-        assertFalse(Optional.of("").equals(empty));
+        assertFalse(empty.equals(Optional.of("unexpected")));
+        assertFalse(Optional.of("unexpected").equals(empty));
+        assertFalse(empty.equals("unexpected"));
+
         assertFalse(empty.isPresent());
         assertEquals(empty.hashCode(), 0);
         assertEquals(empty.orElse("x"), "x");
@@ -97,6 +99,8 @@
         assertTrue(Optional.of(expected).equals(opt));
         assertFalse(opt.equals(Optional.of("unexpected")));
         assertFalse(Optional.of("unexpected").equals(opt));
+        assertFalse(opt.equals("unexpected"));
+
         assertTrue(opt.isPresent());
         assertEquals(opt.hashCode(), expected.hashCode());
         assertEquals(opt.orElse("unexpected"), expected);