1 29 30 package nextapp.echo2.app.test; 31 32 import java.util.List ; 33 34 import nextapp.echo2.app.util.ResizingArrayList; 35 import junit.framework.TestCase; 36 37 41 public class ResizingArrayListTest extends TestCase { 42 43 46 public void testRandomSetCalls() { 47 for (int i = 0; i < 10; ++i) { 48 List list = new ResizingArrayList(); 49 for (int j = 0; j < 10; ++j) { 50 int setIndex = (int) (Math.random() * 100); 51 list.set(setIndex, new Integer (setIndex)); 52 } 53 int size = list.size(); 54 for (int j = 0; j < size; ++j) { 55 Integer value = (Integer ) list.get(j); 56 assertTrue(value == null || value.intValue() == j); 57 } 58 } 59 } 60 61 64 public void testSetAndRemove() { 65 List list = new ResizingArrayList(); 66 list.set(4, "foo"); 67 assertEquals(5, list.size()); 68 assertEquals("foo", list.get(4)); 69 list.remove(4); 70 assertEquals(0, list.size()); 71 list.set(4, "foo"); 72 assertEquals("foo", list.get(4)); 73 assertTrue(list.remove("foo")); 74 assertEquals(0, list.size()); 75 } 76 } 77 | Popular Tags |