test/java/util/Objects/BasicObjectsTest.java
Print this page
rev 7044 : 8013712: Add Objects.nonNull and Objects.isNull
Reviewed-by: duke
*** 38,47 ****
--- 38,49 ----
errors += testHashCode();
errors += testHash();
errors += testToString();
errors += testToString2();
errors += testCompare();
+ errors += testRequireNonNull();
+ errors += testIsNull();
errors += testNonNull();
if (errors > 0 )
throw new RuntimeException();
}
*** 156,166 ****
a, b, result, expected);
}
return errors;
}
! private static int testNonNull() {
int errors = 0;
String s;
// Test 1-arg variant
try {
--- 158,168 ----
a, b, result, expected);
}
return errors;
}
! private static int testRequireNonNull() {
int errors = 0;
String s;
// Test 1-arg variant
try {
*** 204,209 ****
--- 206,229 ----
errors++;
}
}
return errors;
}
+
+ private static int testIsNull() {
+ int errors = 0;
+
+ errors += Objects.isNull(null) ? 0 : 1;
+ errors += Objects.isNull(Objects.class) ? 1 : 0;
+
+ return errors;
+ }
+
+ private static int testNonNull() {
+ int errors = 0;
+
+ errors += Objects.nonNull(null) ? 1 : 0;
+ errors += Objects.nonNull(Objects.class) ? 0 : 1;
+
+ return errors;
+ }
}