harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r400049 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/AbstractList.java test/java/tests/api/java/util/AbstractListTest.java
Date Fri, 05 May 2006 11:13:53 GMT
Author: mloenko
Date: Fri May  5 04:13:50 2006
New Revision: 400049

URL: http://svn.apache.org/viewcvs?rev=400049&view=rev
Log:
fixes for HARMONY-390
AbstractList subList addAll puts elements in the wrong place

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractList.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/AbstractListTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractList.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractList.java?rev=400049&r1=400048&r2=400049&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractList.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractList.java
Fri May  5 04:13:50 2006
@@ -243,16 +243,16 @@
 		}
 
 		public boolean addAll(Collection collection) {
-			if (modCount == fullList.modCount) {
-				boolean result = fullList.addAll(size, collection);
-				if (result) {
-					size += collection.size();
-					modCount = fullList.modCount;
-				}
-				return result;
-			}
-			throw new ConcurrentModificationException();
-		}
+            if (modCount == fullList.modCount) {
+                boolean result = fullList.addAll(offset + size, collection);
+                if (result) {
+                    size += collection.size();
+                    modCount = fullList.modCount;
+                }
+                return result;
+            }
+            throw new ConcurrentModificationException();
+        }
 
 		public Object get(int location) {
 			if (modCount == fullList.modCount) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/AbstractListTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/AbstractListTest.java?rev=400049&r1=400048&r2=400049&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/AbstractListTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/AbstractListTest.java
Fri May  5 04:13:50 2006
@@ -194,6 +194,34 @@
         }
     }
 
-	protected void doneSuite() {
-	}
+    /**
+     * @tests java.util.AbstractList#subList(int, int)
+     */
+    public void test_subList_addAll() {
+        // Regression for HARMONY-390
+        List mainList = new ArrayList();
+        Object[] mainObjects = { "a", "b", "c" };
+        mainList.addAll(Arrays.asList(mainObjects));
+        List subList = mainList.subList(1, 2);
+        assertFalse("subList should not contain \"a\"", subList.contains("a"));
+        assertFalse("subList should not contain \"c\"", subList.contains("c"));
+        assertTrue("subList should contain \"b\"", subList.contains("b"));
+
+        Object[] subObjects = { "one", "two", "three" };
+        subList.addAll(Arrays.asList(subObjects));
+        assertFalse("subList should not contain \"a\"", subList.contains("a"));
+        assertFalse("subList should not contain \"c\"", subList.contains("c"));
+
+        Object[] expected = { "b", "one", "two", "three" };
+        ListIterator iter = subList.listIterator();
+        for (int i = 0; i < expected.length; i++) {
+            assertTrue("subList should contain " + expected[i], subList
+                    .contains(expected[i]));
+            assertTrue("should be more elements", iter.hasNext());
+            assertEquals("element in incorrect position", expected[i], iter
+                    .next());
+        }
+    }
+
+    protected void doneSuite() {}
 }



Mime
View raw message