/** adding at an index places it in the indicated index */
  public void testAddIndex() {
    List full = populatedArray(3);
    full.add(0, m1);
    assertEquals(4, full.size());
    assertEquals(m1, full.get(0));
    assertEquals(zero, full.get(1));

    full.add(2, m2);
    assertEquals(5, full.size());
    assertEquals(m2, full.get(2));
    assertEquals(two, full.get(4));
  }
 /** get throws an IndexOutOfBoundsException on a negative index */
 public void testGet1_IndexOutOfBoundsException() {
   try {
     List c = emptyArray();
     c.get(-1);
     shouldThrow();
   } catch (IndexOutOfBoundsException e) {
   }
 }
 /** iterator.remove removes element */
 public void testIteratorRemove() {
   List full = populatedArray(SIZE);
   Iterator it = full.iterator();
   Object first = full.get(0);
   it.next();
   it.remove();
   assertFalse(full.contains(first));
 }
 /** get throws an IndexOutOfBoundsException on a too high index */
 public void testGet2_IndexOutOfBoundsException() {
   try {
     List c = emptyArray();
     c.add("asdasd");
     c.add("asdad");
     c.get(100);
     shouldThrow();
   } catch (IndexOutOfBoundsException e) {
   }
 }
  /** sublists contains elements at indexes offset from their base */
  public void testSubList() {
    List a = populatedArray(10);
    assertTrue(a.subList(1, 1).isEmpty());
    for (int j = 0; j < 9; ++j) {
      for (int i = j; i < 10; ++i) {
        List b = a.subList(j, i);
        for (int k = j; k < i; ++k) {
          assertEquals(new Integer(k), b.get(k - j));
        }
      }
    }

    List s = a.subList(2, 5);
    assertEquals(3, s.size());
    s.set(2, m1);
    assertEquals(a.get(4), m1);
    s.clear();
    assertEquals(7, a.size());
  }
 /** new list contains all elements of initializing array */
 public void testConstructor2() {
   Integer[] ints = new Integer[SIZE];
   for (int i = 0; i < SIZE - 1; ++i) ints[i] = new Integer(i);
   List a = ParallelArray.createUsingHandoff(ints, ParallelArray.defaultExecutor()).asList();
   for (int i = 0; i < SIZE; ++i) assertEquals(ints[i], a.get(i));
 }
 /** set changes the element at the given index */
 public void testSet() {
   List full = populatedArray(3);
   assertEquals(two, full.set(2, four));
   assertEquals(4, ((Integer) full.get(2)).intValue());
 }
 /** get returns the value at the given index */
 public void testGet() {
   List full = populatedArray(3);
   assertEquals(0, ((Integer) full.get(0)).intValue());
 }