protected DoubleList makeDoubleList() {
   DoubleList list = new ArrayDoubleList();
   for (double i = 0; i < 10; i++) {
     list.add(i);
   }
   return list;
 }
 public final void testListIteratorNotModifiable() throws Exception {
   DoubleList list = makeUnmodifiableDoubleList();
   assertListIteratorNotModifiable(list.listIterator());
   assertListIteratorNotModifiable(list.subList(0, list.size() - 2).listIterator());
   assertListIteratorNotModifiable(list.listIterator(1));
   assertListIteratorNotModifiable(list.subList(0, list.size() - 2).listIterator(1));
 }
 public final void testSublistNotModifiable() throws Exception {
   DoubleList list = makeUnmodifiableDoubleList();
   assertListNotModifiable(list.subList(0, list.size() - 2));
 }
  private void assertListNotModifiable(DoubleList list) throws Exception {
    try {
      list.add((double) 1);
      fail("Expected UnsupportedOperationException");
    } catch (UnsupportedOperationException e) {
      // expected
    }

    try {
      list.add(1, (double) 2);
      fail("Expected UnsupportedOperationException");
    } catch (UnsupportedOperationException e) {
      // expected
    }

    try {
      list.addAll(makeDoubleList());
      fail("Expected UnsupportedOperationException");
    } catch (UnsupportedOperationException e) {
      // expected
    }

    try {
      list.addAll(1, makeDoubleList());
      fail("Expected UnsupportedOperationException");
    } catch (UnsupportedOperationException e) {
      // expected
    }

    try {
      list.removeElementAt(1);
      fail("Expected UnsupportedOperationException");
    } catch (UnsupportedOperationException e) {
      // expected
    }

    try {
      list.removeElement((double) 1);
      fail("Expected UnsupportedOperationException");
    } catch (UnsupportedOperationException e) {
      // expected
    }

    try {
      list.removeAll(makeDoubleList());
      fail("Expected UnsupportedOperationException");
    } catch (UnsupportedOperationException e) {
      // expected
    }

    try {
      list.retainAll(makeDoubleList());
      fail("Expected UnsupportedOperationException");
    } catch (UnsupportedOperationException e) {
      // expected
    }

    try {
      list.clear();
      fail("Expected UnsupportedOperationException");
    } catch (UnsupportedOperationException e) {
      // expected
    }

    try {
      list.set(1, (double) 2);
      fail("Expected UnsupportedOperationException");
    } catch (UnsupportedOperationException e) {
      // expected
    }
  }