CVS: junit/src/org/junit/tests AssertionTest.java, 1.6, 1.6.2.1
David Saff <[email protected]> Fri, 23 Mar 2007 16:04:41 -0700
| Newsgroups | gmane.comp.java.junit.devel |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/junit/junit/src/org/junit/tests
In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv22827/src/org/junit/tests
Modified Files:
Tag: Version431
AssertionTest.java
Log Message:
[Junit-trackers] [ junit-Bugs-1684562 ] assertEquals throws NPE while comparing null elements
Index: AssertionTest.java
===================================================================
RCS file: /cvsroot/junit/junit/src/org/junit/tests/AssertionTest.java,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -u -d -r1.6 -r1.6.2.1
--- AssertionTest.java 8 Feb 2007 22:45:20 -0000 1.6
+++ AssertionTest.java 23 Mar 2007 23:04:39 -0000 1.6.2.1
@@ -193,6 +193,36 @@
assertEquals(1.0d, 1.0d, 0.0d);
}
+ @Test(expected= AssertionError.class) public void notEqualsObjectWithNull() {
+ assertEquals(new Object(), null);
+ }
+
+ @Test(expected= AssertionError.class) public void notEqualsNullWithObject() {
+ assertEquals(null, new Object());
+ }
+
+ @Test public void notEqualsObjectWithNullWithMessage() {
+ Object o = new Object();
+ try {
+ assertEquals("message", null, o);
+ fail();
+ }
+ catch(AssertionError e) {
+ assertEquals("message expected:<null> but was:<" + o.toString() + ">", e.getMessage());
+ }
+ }
+
+ @Test public void notEqualsNullWithObjectWithMessage() {
+ Object o = new Object();
+ try {
+ assertEquals("message", o, null);
+ fail();
+ }
+ catch(AssertionError e) {
+ assertEquals("message expected:<"+ o.toString() + "> but was:<null>", e.getMessage());
+ }
+ }
+
@Test(expected= AssertionError.class) public void objectsNotEquals() {
assertEquals(new Object(), new Object());
}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV