import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.util.Iterator;
try {
list.get(-1);
+ fail("accepted out-of-bounds index");
} catch (IndexOutOfBoundsException badIndex) {
assertEquals(String.valueOf(-1), badIndex.getMessage());
}
try {
list.get(0);
+ fail("accepted out-of-bounds index");
} catch (IndexOutOfBoundsException badIndex) {
assertEquals(String.valueOf(0), badIndex.getMessage());
}
try {
list.get(4);
+ fail("accepted out-of-bounds index");
} catch (IndexOutOfBoundsException badIndex) {
assertEquals(String.valueOf(4), badIndex.getMessage());
}
try {
list.get(3);
+ fail("accepted out-of-bounds index");
} catch (IndexOutOfBoundsException badIndex) {
assertEquals(String.valueOf(3), badIndex.getMessage());
}
try {
list.set(-1, "foo");
+ fail("accepted out-of-bounds index");
} catch (IndexOutOfBoundsException badIndex) {
assertEquals(String.valueOf(-1), badIndex.getMessage());
}
try {
list.set(0, "foo");
+ fail("accepted out-of-bounds index");
} catch (IndexOutOfBoundsException badIndex) {
assertEquals(String.valueOf(0), badIndex.getMessage());
}
try {
list.set(4, "foo");
+ fail("accepted out-of-bounds index");
} catch (IndexOutOfBoundsException badIndex) {
assertEquals(String.valueOf(4), badIndex.getMessage());
}
try {
list.set(3, "bar");
+ fail("accepted out-of-bounds index");
} catch (IndexOutOfBoundsException badIndex) {
assertEquals(String.valueOf(3), badIndex.getMessage());
}
try {
list.add(-1, Integer.valueOf(42));
+ fail("accepted out-of-bounds index");
} catch (IndexOutOfBoundsException badIndex) {
assertEquals(String.valueOf(-1), badIndex.getMessage());
}
try {
list.add(4, Integer.valueOf(42));
+ fail("accepted out-of-bounds index");
} catch (IndexOutOfBoundsException badIndex) {
assertEquals(String.valueOf(4), badIndex.getMessage());
}
try {
list.remove(-1);
+ fail("accepted out-of-bounds index");
} catch (IndexOutOfBoundsException badIndex) {
assertEquals(String.valueOf(-1), badIndex.getMessage());
}
try {
list.remove(4);
+ fail("accepted out-of-bounds index");
} catch (IndexOutOfBoundsException badIndex) {
assertEquals(String.valueOf(4), badIndex.getMessage());
}