< prev index next >

test/jdk/java/util/Objects/BasicObjectsTest.java

Print this page
*** 43,10 ***
--- 43,11 ---
          errors += testCompare();
          errors += testRequireNonNull();
          errors += testIsNull();
          errors += testNonNull();
          errors += testNonNullOf();
+         errors += testNewIdentity();
          if (errors > 0 )
              throw new RuntimeException();
      }
  
      private static int testEquals() {

*** 304,6 ***
--- 305,21 ---
              // expected
              errors += npe.getMessage().equals("supplier") ? 0 : 1;
          }
          return errors;
      }
+ 
+     private static int testNewIdentity() {
+         int errors = 0;
+ 
+         Object o1 = Objects.newIdentity();
+         Object o2 = Objects.newIdentity();
+ 
+         if (o1 == null || o2 == null)
+             errors += 1;
+ 
+         if (o1 == o2)
+             errors += 1;
+ 
+         return errors;
+     }
  }
< prev index next >