From: Jeff M. <cus...@us...> - 2002-09-05 08:39:27
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/test In directory usw-pr-cvs1:/tmp/cvs-serv1044/src/core/com/mockobjects/test Modified Files: TestMapEntry.java Log Message: Fixed MapEntry's equality behaviour when working with arrays Index: TestMapEntry.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/test/TestMapEntry.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TestMapEntry.java 29 Jul 2001 19:50:24 -0000 1.1 +++ TestMapEntry.java 5 Sep 2002 08:39:22 -0000 1.2 @@ -1,9 +1,9 @@ package com.mockobjects.test; -import java.util.*; -import junit.framework.*; -import com.mockobjects.*; -import com.mockobjects.util.*; +import com.mockobjects.MapEntry; +import com.mockobjects.util.TestCaseMo; +import junit.framework.Test; +import junit.framework.TestSuite; /** * JUnit test case for TestMapEntry @@ -16,7 +16,7 @@ } public static void main(String[] args) { - start(new String[] { TestMapEntry.class.getName()}); + start(new String[]{TestMapEntry.class.getName()}); } public static Test suite() { @@ -28,19 +28,48 @@ "Should be expected value", new MapEntry("A", "2"), new MapEntry("A", "2")); + assertTrue( "Should not be equal", !new MapEntry("A", "2").equals(new MapEntry("A", "1"))); + assertTrue( "Should not be equal", !new MapEntry("A", "2").equals(new MapEntry("B", "2"))); + assertEquals( "Should be equal with null value", new MapEntry("A", null), new MapEntry("A", null)); + assertEquals( "Should be equal with null key", new MapEntry(null, "A"), new MapEntry(null, "A")); + + assertEquals( + "Should be equal byte arrays", + new MapEntry("A", "A".getBytes()), + new MapEntry("A", "A".getBytes())); + + assertTrue( + "Should not be equal byte arrays", + !new MapEntry("A", "AB".getBytes()).equals(new MapEntry("A", "A".getBytes()))); + + assertTrue( + "Should not be equal byte arrays", + !new MapEntry("A", "A".getBytes()).equals(new MapEntry("A", "AB".getBytes()))); + + assertTrue( + "Should not be equal byte arrays", + !new MapEntry("A", null).equals(new MapEntry("A", "AB".getBytes()))); + } + + public void testHashCode() { + assertEquals( + "Should be equal hashcodes", + new MapEntry("A", "A".getBytes()).hashCode(), + new MapEntry("A", "A".getBytes()).hashCode()); + } } |