Author: julien(a)jboss.com
Date: 2007-10-19 05:53:23 -0400 (Fri, 19 Oct 2007)
New Revision: 8713
Modified:
modules/test/trunk/unit/src/main/org/jboss/test/unit/api/AssertTests.java
Log:
added tests cases for equals/notequals for integer and boolean
Modified: modules/test/trunk/unit/src/main/org/jboss/test/unit/api/AssertTests.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/api/AssertTests.java 2007-10-19
09:01:48 UTC (rev 8712)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/api/AssertTests.java 2007-10-19
09:53:23 UTC (rev 8713)
@@ -45,12 +45,72 @@
testObjectNotSame();
testFail();
testInstanceOf();
+ testInteger();
+ testBoolean();
}
- public static void testInstanceOf()
+ private static void testBoolean()
{
+ testAssertEquals(true, true);
+ testAssertEquals(true, new Boolean(true));
+ testAssertEquals(new Boolean(true), new Boolean(true));
+ testAssertEquals(new Boolean(true), true);
+ testAssertNotEquals(true, false);
+ testAssertNotEquals(new Boolean(true), false);
+ testAssertNotEquals(true, new Boolean(false));
+ testAssertNotEquals(true, new Boolean(false));
+ testAssertNotEquals(true, null);
+ testAssertNotEquals(new Boolean(true), null);
+ testAssertNotEquals(null, true);
+ testAssertNotEquals(null, new Boolean(true));
+ }
+
+ private static void testInteger()
+ {
+ testAssertEquals(1, 1);
+ testAssertEquals(1, new Integer(1));
+ testAssertEquals(new Integer(1), new Integer(1));
+ testAssertEquals(new Integer(1), 1);
+ testAssertNotEquals(1, 2);
+ testAssertNotEquals(new Integer(1), 2);
+ testAssertNotEquals(1, new Integer(2));
+ testAssertNotEquals(1, new Integer(2));
+ testAssertNotEquals(1, null);
+ testAssertNotEquals(new Integer(1), null);
+ testAssertNotEquals(null, 1);
+ testAssertNotEquals(null, new Integer(1));
+ }
+
+ private static void testAssertEquals(Object left, Object right)
+ {
+ Assert.assertEquals(left, right);
try
{
+ Assert.assertNotEquals(left, right);
+ throw new RuntimeException();
+ }
+ catch (AssertionError ignored)
+ {
+ }
+ }
+
+ private static void testAssertNotEquals(Object left, Object right)
+ {
+ Assert.assertNotEquals(left, right);
+ try
+ {
+ Assert.assertEquals(left, right);
+ throw new RuntimeException();
+ }
+ catch (AssertionError ignored)
+ {
+ }
+ }
+
+ private static void testInstanceOf()
+ {
+ try
+ {
Assert.assertInstanceOf(null, Object.class);
throw new RuntimeException();
}
@@ -150,7 +210,7 @@
{
}
- public static void testObjectEquals()
+ private static void testObjectEquals()
{
try
{
@@ -181,7 +241,7 @@
Assert.assertEquals((Object)null, null);
}
- public static void testObjectNotEquals()
+ private static void testObjectNotEquals()
{
Assert.assertNotEquals(o1, null);
Assert.assertNotEquals(null, o1);
@@ -212,7 +272,7 @@
}
}
- public static void testObjectSame()
+ private static void testObjectSame()
{
try
{
@@ -250,7 +310,7 @@
Assert.assertSame(null, null);
}
- public static void testObjectNotSame()
+ private static void testObjectNotSame()
{
Assert.assertNotSame(o1, null);
Assert.assertNotSame(null, o1);
@@ -274,7 +334,7 @@
}
}
- public static void testFail()
+ private static void testFail()
{
try
{