harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r437626 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/ArrayList.java test/java/tests/api/java/util/ArrayListTest.java
Date Mon, 28 Aug 2006 10:12:49 GMT
Author: pyang
Date: Mon Aug 28 03:12:46 2006
New Revision: 437626

URL: http://svn.apache.org/viewvc?rev=437626&view=rev
Log:
Patch applied for HARMONY-1293 ([classlib][luni] java.util.ArrayList.addAll(int, Collection)
behaves incorrectly)

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

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ArrayList.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ArrayList.java?rev=437626&r1=437625&r2=437626&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ArrayList.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ArrayList.java
Mon Aug 28 03:12:46 2006
@@ -337,7 +337,7 @@
 	private void growAtFront(int required) {
 		int size = size();
 		if (array.length - lastIndex >= required) {
-			int newFirst = array.length - lastIndex;
+			int newFirst = array.length - size;
 			if (size > 0) {
 				System.arraycopy(array, firstIndex, array, newFirst, size);
 				int length = firstIndex + size > newFirst ? newFirst
@@ -355,8 +355,8 @@
 			E[] newArray = newElementArray(size + increment);
 			if (size > 0)
 				System.arraycopy(array, firstIndex, newArray, newArray.length
-						- lastIndex, size);
-			firstIndex = newArray.length - lastIndex;
+						- size, size);
+			firstIndex = newArray.length - size;
 			lastIndex = newArray.length;
 			array = newArray;
 		}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ArrayListTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ArrayListTest.java?rev=437626&r1=437625&r2=437626&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ArrayListTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ArrayListTest.java
Mon Aug 28 03:12:46 2006
@@ -472,6 +472,49 @@
 					.get(i) == objArray[i]);
 	}
 
+    /**
+     * @test java.util.ArrayList#addAll(int, Collection)
+     */
+    public void test_addAll() {
+        ArrayList list = new ArrayList();
+        list.add("one");
+        list.add("two");
+        assertEquals(2, list.size());
+
+        list.remove(0);
+        assertEquals(1, list.size());
+        
+        ArrayList collection = new ArrayList();
+        collection.add("1");
+        collection.add("2");
+        collection.add("3");
+        assertEquals(3, collection.size());
+        
+        list.addAll(0, collection);
+        assertEquals(4, list.size());
+        
+        list.remove(0);
+        list.remove(0);
+        assertEquals(2, list.size());
+
+        collection.add("4");
+        collection.add("5");
+        collection.add("6");
+        collection.add("7");
+        collection.add("8");
+        collection.add("9");
+        collection.add("10");
+        collection.add("11");
+        collection.add("12");
+        
+        assertEquals(12, collection.size());
+        
+        list.addAll(0, collection);
+        assertEquals(14, list.size());
+    }
+    
+    
+    
 	/**
 	 * Sets up the fixture, for example, open a network connection. This method
 	 * is called before a test is executed.



Mime
View raw message