ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgl...@apache.org
Subject svn commit: r1367736 - /ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/VectorSetTest.java
Date Tue, 31 Jul 2012 20:03:00 GMT
Author: jglick
Date: Tue Jul 31 20:02:59 2012
New Revision: 1367736

URL: http://svn.apache.org/viewvc?rev=1367736&view=rev
Log:
Stronger tests in preparation for #53622.

Modified:
    ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/VectorSetTest.java

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/VectorSetTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/VectorSetTest.java?rev=1367736&r1=1367735&r2=1367736&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/VectorSetTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/VectorSetTest.java Tue Jul 31
20:02:59 2012
@@ -18,6 +18,7 @@
 
 package org.apache.tools.ant.util;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 
 import junit.framework.TestCase;
@@ -206,13 +207,26 @@ public class VectorSetTest extends TestC
         Object c = new Object();
         v.addAll(Arrays.asList(new Object[] {O, a, b, c}));
         assertEquals(0, v.indexOf(O));
-        v.retainAll(Arrays.asList(new Object[] {c, O}));
+        assertTrue(v.retainAll(Arrays.asList(new Object[] {c, O})));
         assertEquals(2, v.size());
         assertTrue(v.contains(O));
         assertTrue(v.contains(c));
         assertEquals(0, v.indexOf(O));
     }
 
+    public void testRetainAllReturnValueAndEmptiness() {
+        v.add(1);
+        v.add(2);
+        v.add(3);
+        assertTrue(v.retainAll(Arrays.asList(1, 2)));
+        assertEquals(2, v.size());
+        assertFalse(v.retainAll(Arrays.asList(1, 2)));
+        assertEquals(2, v.size());
+        assertTrue(v.retainAll(Arrays.asList(4, 5)));
+        assertEquals(0, v.size());
+        assertFalse(v.retainAll(Arrays.asList(4, 5)));
+    }
+
     public void testSet() {
         v.add(O);
         Object a = new Object();
@@ -228,4 +242,24 @@ public class VectorSetTest extends TestC
         assertSame(a, v.get(0));
         assertEquals(1, v.size());
     }
-}
\ No newline at end of file
+
+    public void testRetainAllSpeed() {
+        int size = 50000;
+        for (int i = 0; i < size; i++) {
+            v.add(i);
+            v.add(i);
+        }
+        assertEquals(size, v.size());
+        ArrayList<Integer> list = new ArrayList<Integer>();
+        for (int i = size - 4; i < 2 * size; i++) {
+            list.add(i);
+            v.add(i);
+        }
+        long start = System.currentTimeMillis();
+        assertTrue(v.retainAll(list));
+        long stop = System.currentTimeMillis();
+        System.out.println("testRetainAllSpeed: " + (stop - start) + "msec");
+        assertEquals(v.toString(), size + 4, v.size());
+    }
+
+}



Mime
View raw message