static List populatedArray(int n) {
   List a = ParallelArray.createEmpty(n, Object.class, ParallelArray.defaultExecutor()).asList();
   assertTrue(a.isEmpty());
   for (int i = 0; i < n; ++i) a.add(new Integer(i));
   assertFalse(a.isEmpty());
   assertEquals(n, a.size());
   return a;
 }
 /** lastIndexOf returns the index for the given object */
 public void testLastIndexOf1() {
   List full = populatedArray(3);
   full.add(one);
   full.add(three);
   assertEquals(3, full.lastIndexOf(one));
   assertEquals(-1, full.lastIndexOf(six));
 }
 /** listIterator throws an IndexOutOfBoundsException on a too high index */
 public void testListIterator2_IndexOutOfBoundsException() {
   try {
     List c = emptyArray();
     c.add("adasd");
     c.add("asdasdas");
     c.listIterator(100);
     shouldThrow();
   } catch (IndexOutOfBoundsException e) {
   }
 }
 /** addAll throws an IndexOutOfBoundsException on a too high index */
 public void testAddAll2_IndexOutOfBoundsException() {
   try {
     List c = emptyArray();
     c.add("asdasd");
     c.add("asdasdasd");
     c.addAll(100, new LinkedList());
     shouldThrow();
   } catch (IndexOutOfBoundsException e) {
   }
 }
 /** remove throws an IndexOutOfBoundsException on a too high index */
 public void testRemove2_IndexOutOfBounds() {
   try {
     List c = emptyArray();
     c.add("asdasd");
     c.add("adasdasd");
     c.remove(100);
     shouldThrow();
   } catch (IndexOutOfBoundsException e) {
   }
 }
 /** add throws an IndexOutOfBoundsException on a too high index */
 public void testAdd2_IndexOutOfBoundsException() {
   try {
     List c = emptyArray();
     c.add("asdasd");
     c.add("asdasdasd");
     c.add(100, "qwerty");
     shouldThrow();
   } catch (IndexOutOfBoundsException e) {
   }
 }
 /** 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) {
   }
 }
 /**
  * toArray throws an ArrayStoreException when the given array can not store the objects inside the
  * list
  */
 public void testToArray_ArrayStoreException() {
   try {
     List c = emptyArray();
     c.add("zfasdfsdf");
     c.add("asdadasd");
     c.toArray(new Long[5]);
     shouldThrow();
   } catch (ArrayStoreException e) {
   }
 }
  /** 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));
  }
 /** lists with same elements are equal and have same hashCode */
 public void testEquals() {
   List a = populatedArray(3);
   List b = populatedArray(3);
   assertTrue(a.equals(b));
   assertTrue(b.equals(a));
   assertEquals(a.hashCode(), b.hashCode());
   a.add(m1);
   assertFalse(a.equals(b));
   assertFalse(b.equals(a));
   b.add(m1);
   assertTrue(a.equals(b));
   assertTrue(b.equals(a));
   assertEquals(a.hashCode(), b.hashCode());
 }