X-Git-Url: http://git.nikiroo.be/?p=nikiroo-utils.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Ftest%2FTestCase.java;h=b37ea987ffca27677a32eb5d31d05e2632974c52;hp=e4860fa11f51e0f5e4cda5d366fffa8db0eef285;hb=16d593780fa5a4c39cc36b29382da610eae951da;hpb=009196a48ec0820288dac580f661c8884e1c1108 diff --git a/src/be/nikiroo/utils/test/TestCase.java b/src/be/nikiroo/utils/test/TestCase.java index e4860fa..b37ea98 100644 --- a/src/be/nikiroo/utils/test/TestCase.java +++ b/src/be/nikiroo/utils/test/TestCase.java @@ -233,6 +233,29 @@ abstract public class TestCase { assertEquals(errorMessage, new Double(expected), new Double(actual)); } + /** + * Check that given {@link Object} is not NULL. + * + * @param the + * error message to display if it is NULL + * @param actual + * the actual value + * + * @throws AssertException + * in case they differ + */ + public void assertNotNull(String errorMessage, Object actual) + throws AssertException { + if (actual == null) { + if (errorMessage == null) { + errorMessage = String.format("" // + + "Assertion failed!\n" // + + "Object should have been NULL: [%s]", actual); + } + throw new AssertException(errorMessage); + } + } + /** * Generate the default assert message for 2 different values that were * supposed to be equals.