commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject svn commit: r169097 - in /jakarta/commons/proper/collections/trunk/src: java/org/apache/commons/collections/map/TransformedMap.java test/org/apache/commons/collections/map/AbstractTestMap.java
Date Sat, 07 May 2005 17:13:41 GMT
Author: scolebourne
Date: Sat May  7 10:13:40 2005
New Revision: 169097

URL: http://svn.apache.org/viewcvs?rev=169097&view=rev
Log:
Fix so putAll works with an empty map
bug 34686, reported by Marc Lottman

Modified:
    jakarta/commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/TransformedMap.java
    jakarta/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/AbstractTestMap.java

Modified: jakarta/commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/TransformedMap.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/TransformedMap.java?rev=169097&r1=169096&r2=169097&view=diff
==============================================================================
--- jakarta/commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/TransformedMap.java
(original)
+++ jakarta/commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/TransformedMap.java
Sat May  7 10:13:40 2005
@@ -150,6 +150,9 @@
      * @throws the transformed object
      */
     protected Map transformMap(Map map) {
+        if (map.isEmpty()) {
+            return map;
+        }
         Map result = new LinkedMap(map.size());
         for (Iterator it = map.entrySet().iterator(); it.hasNext(); ) {
             Map.Entry entry = (Map.Entry) it.next();

Modified: jakarta/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/AbstractTestMap.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/AbstractTestMap.java?rev=169097&r1=169096&r2=169097&view=diff
==============================================================================
--- jakarta/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/AbstractTestMap.java
(original)
+++ jakarta/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/AbstractTestMap.java
Sat May  7 10:13:40 2005
@@ -907,23 +907,46 @@
             return;
         }
 
+        // check putAll OK adding empty map to empty map
         resetEmpty();
+        assertEquals(0, map.size());
+        map.putAll(new HashMap());
+        assertEquals(0, map.size());
 
-        Map m2 = makeFullMap();
+        // check putAll OK adding empty map to non-empty map
+        resetFull();
+        int size = map.size();
+        map.putAll(new HashMap());
+        assertEquals(size, map.size());
 
+        // check putAll OK adding non-empty map to empty map
+        resetEmpty();
+        Map m2 = makeFullMap();
         map.putAll(m2);
         confirmed.putAll(m2);
         verify();
 
+        // check putAll OK adding non-empty JDK map to empty map
         resetEmpty();
-
         m2 = makeConfirmedMap();
         Object[] keys = getSampleKeys();
         Object[] values = getSampleValues();
         for(int i = 0; i < keys.length; i++) {
             m2.put(keys[i], values[i]);
         }
+        map.putAll(m2);
+        confirmed.putAll(m2);
+        verify();
 
+        // check putAll OK adding non-empty JDK map to non-empty map
+        resetEmpty();
+        m2 = makeConfirmedMap();
+        map.put(keys[0], values[0]);
+        confirmed.put(keys[0], values[0]);
+        verify();
+        for(int i = 1; i < keys.length; i++) {
+            m2.put(keys[i], values[i]);
+        }
         map.putAll(m2);
         confirmed.putAll(m2);
         verify();



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message