Created
March 22, 2017 09:06
-
-
Save bmaggi/66a5803f79fefb6f57db887a9d9cec4f to your computer and use it in GitHub Desktop.
A simple class test to prove that null is not an instance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.junit.Assert; | |
import org.junit.Test; | |
/** | |
* A simple class test to prove that null is not an instance | |
* (aka useless: test!= null && test instanceOf MyClass) | |
* | |
* @author Benoit Maggi | |
*/ | |
public class InstanceOfTest { | |
@Test | |
public void testNotNull() { | |
String notNull = ""; | |
Assert.assertTrue(notNull instanceof String); | |
} | |
@Test | |
public void testNull() { | |
String isNull = null; | |
Assert.assertFalse(isNull instanceof String); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment