Test cloning of maps works correctly

bug 27159, identified by Fabrizio Giustina


git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131597 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2004-02-27 00:25:14 +00:00
parent 5c255a657e
commit 137114ee9f
5 changed files with 45 additions and 5 deletions

View File

@ -27,7 +27,7 @@ import org.apache.commons.collections.BulkTest;
/**
* Tests for the {@link CaseInsensitiveMap} implementation.
*
* @version $Revision: 1.3 $ $Date: 2004/02/18 01:20:38 $
* @version $Revision: 1.4 $ $Date: 2004/02/27 00:25:14 $
*
* @author Commons-Collections team
*/
@ -100,6 +100,14 @@ public class TestCaseInsensitiveMap extends AbstractTestIterableMap {
assertEquals(caseInsensitiveMap.get(null), "Four");
}
public void testClone() {
CaseInsensitiveMap map = new CaseInsensitiveMap(10);
map.put("1", "1");
Map cloned = (Map) map.clone();
assertEquals(map.size(), cloned.size());
assertSame(map.get("1"), cloned.get("1"));
}
/*
public void testCreate() throws Exception {
resetEmpty();

View File

@ -25,7 +25,7 @@ import org.apache.commons.collections.BulkTest;
/**
* JUnit tests.
*
* @version $Revision: 1.6 $ $Date: 2004/02/18 01:20:38 $
* @version $Revision: 1.7 $ $Date: 2004/02/27 00:25:14 $
*
* @author Stephen Colebourne
*/
@ -51,6 +51,14 @@ public class TestHashedMap extends AbstractTestIterableMap {
return "3";
}
public void testClone() {
HashedMap map = new HashedMap(10);
map.put("1", "1");
Map cloned = (Map) map.clone();
assertEquals(map.size(), cloned.size());
assertSame(map.get("1"), cloned.get("1"));
}
// public void testCreate() throws Exception {
// resetEmpty();
// writeExternalFormToDisk((java.io.Serializable) map, "D:/dev/collections/data/test/HashedMap.emptyCollection.version3.obj");

View File

@ -30,7 +30,7 @@ import org.apache.commons.collections.IterableMap;
/**
* JUnit tests.
*
* @version $Revision: 1.6 $ $Date: 2004/02/18 01:20:38 $
* @version $Revision: 1.7 $ $Date: 2004/02/27 00:25:14 $
*
* @author Stephen Colebourne
*/
@ -125,6 +125,14 @@ public class TestIdentityMap extends AbstractTestObject {
}
}
public void testClone() {
IdentityMap map = new IdentityMap(10);
map.put("1", "1");
Map cloned = (Map) map.clone();
assertEquals(map.size(), cloned.size());
assertSame(map.get("1"), cloned.get("1"));
}
// public void testCreate() throws Exception {
// Map map = new IdentityMap();
// writeExternalFormToDisk((java.io.Serializable) map, "D:/dev/collections/data/test/IdentityMap.emptyCollection.version3.obj");

View File

@ -30,7 +30,7 @@ import org.apache.commons.collections.ResettableIterator;
/**
* JUnit tests.
*
* @version $Revision: 1.5 $ $Date: 2004/02/18 01:20:38 $
* @version $Revision: 1.6 $ $Date: 2004/02/27 00:25:14 $
*
* @author Stephen Colebourne
*/
@ -210,6 +210,14 @@ public class TestLRUMap extends AbstractTestOrderedMap {
assertSame(values[3], it.next());
}
public void testClone() {
LRUMap map = new LRUMap(10);
map.put("1", "1");
Map cloned = (Map) map.clone();
assertEquals(map.size(), cloned.size());
assertSame(map.get("1"), cloned.get("1"));
}
// public void testCreate() throws Exception {
// resetEmpty();
// writeExternalFormToDisk((java.io.Serializable) map, "D:/dev/collections/data/test/LRUMap.emptyCollection.version3.obj");

View File

@ -32,7 +32,7 @@ import org.apache.commons.collections.list.AbstractTestList;
/**
* JUnit tests.
*
* @version $Revision: 1.6 $ $Date: 2004/02/18 01:20:38 $
* @version $Revision: 1.7 $ $Date: 2004/02/27 00:25:14 $
*
* @author Stephen Colebourne
*/
@ -255,6 +255,14 @@ public class TestLinkedMap extends AbstractTestOrderedMap {
}
public void testClone() {
LinkedMap map = new LinkedMap(10);
map.put("1", "1");
Map cloned = (Map) map.clone();
assertEquals(map.size(), cloned.size());
assertSame(map.get("1"), cloned.get("1"));
}
// public void testCreate() throws Exception {
// resetEmpty();
// writeExternalFormToDisk((java.io.Serializable) map, "D:/dev/collections/data/test/LinkedMap.emptyCollection.version3.obj");