aboutsummaryrefslogtreecommitdiff
path: root/guava-testlib/src/com/google/common/collect/testing/testers/ListAddAllAtIndexTester.java
diff options
context:
space:
mode:
Diffstat (limited to 'guava-testlib/src/com/google/common/collect/testing/testers/ListAddAllAtIndexTester.java')
-rw-r--r--guava-testlib/src/com/google/common/collect/testing/testers/ListAddAllAtIndexTester.java59
1 files changed, 29 insertions, 30 deletions
diff --git a/guava-testlib/src/com/google/common/collect/testing/testers/ListAddAllAtIndexTester.java b/guava-testlib/src/com/google/common/collect/testing/testers/ListAddAllAtIndexTester.java
index c3e338f1a..c1e03fd72 100644
--- a/guava-testlib/src/com/google/common/collect/testing/testers/ListAddAllAtIndexTester.java
+++ b/guava-testlib/src/com/google/common/collect/testing/testers/ListAddAllAtIndexTester.java
@@ -27,33 +27,32 @@ import com.google.common.collect.testing.MinimalCollection;
import com.google.common.collect.testing.features.CollectionFeature;
import com.google.common.collect.testing.features.CollectionSize;
import com.google.common.collect.testing.features.ListFeature;
+
import java.util.List;
-import org.junit.Ignore;
/**
- * A generic JUnit test which tests {@code addAll(int, Collection)} operations on a list. Can't be
- * invoked directly; please see {@link com.google.common.collect.testing.ListTestSuiteBuilder}.
+ * A generic JUnit test which tests {@code addAll(int, Collection)} operations
+ * on a list. Can't be invoked directly; please see
+ * {@link com.google.common.collect.testing.ListTestSuiteBuilder}.
*
* @author Chris Povirk
*/
@SuppressWarnings("unchecked") // too many "unchecked generic array creations"
@GwtCompatible
-@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListAddAllAtIndexTester<E> extends AbstractListTester<E> {
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
@CollectionSize.Require(absent = ZERO)
public void testAddAllAtIndex_supportedAllPresent() {
- assertTrue(
- "addAll(n, allPresent) should return true",
- getList().addAll(0, MinimalCollection.of(e0())));
- expectAdded(0, e0());
+ assertTrue("addAll(n, allPresent) should return true",
+ getList().addAll(0, MinimalCollection.of(samples.e0)));
+ expectAdded(0, samples.e0);
}
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
@CollectionSize.Require(absent = ZERO)
public void testAddAllAtIndex_unsupportedAllPresent() {
try {
- getList().addAll(0, MinimalCollection.of(e0()));
+ getList().addAll(0, MinimalCollection.of(samples.e0));
fail("addAll(n, allPresent) should throw");
} catch (UnsupportedOperationException expected) {
}
@@ -63,35 +62,34 @@ public class ListAddAllAtIndexTester<E> extends AbstractListTester<E> {
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
@CollectionSize.Require(absent = ZERO)
public void testAddAllAtIndex_supportedSomePresent() {
- assertTrue(
- "addAll(n, allPresent) should return true",
- getList().addAll(0, MinimalCollection.of(e0(), e3())));
- expectAdded(0, e0(), e3());
+ assertTrue("addAll(n, allPresent) should return true",
+ getList().addAll(0, MinimalCollection.of(samples.e0, samples.e3)));
+ expectAdded(0, samples.e0, samples.e3);
}
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
@CollectionSize.Require(absent = ZERO)
public void testAddAllAtIndex_unsupportedSomePresent() {
try {
- getList().addAll(0, MinimalCollection.of(e0(), e3()));
+ getList().addAll(0, MinimalCollection.of(samples.e0, samples.e3));
fail("addAll(n, allPresent) should throw");
} catch (UnsupportedOperationException expected) {
}
expectUnchanged();
- expectMissing(e3());
+ expectMissing(samples.e3);
}
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
public void testAddAllAtIndex_supportedNothing() {
- assertFalse("addAll(n, nothing) should return false", getList().addAll(0, emptyCollection()));
+ assertFalse("addAll(n, nothing) should return false",
+ getList().addAll(0, emptyCollection()));
expectUnchanged();
}
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
public void testAddAllAtIndex_unsupportedNothing() {
try {
- assertFalse(
- "addAll(n, nothing) should return false or throw",
+ assertFalse("addAll(n, nothing) should return false or throw",
getList().addAll(0, emptyCollection()));
} catch (UnsupportedOperationException tolerated) {
}
@@ -100,16 +98,19 @@ public class ListAddAllAtIndexTester<E> extends AbstractListTester<E> {
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
public void testAddAllAtIndex_withDuplicates() {
- MinimalCollection<E> elementsToAdd = MinimalCollection.of(e0(), e1(), e0(), e1());
- assertTrue("addAll(n, hasDuplicates) should return true", getList().addAll(0, elementsToAdd));
- expectAdded(0, e0(), e1(), e0(), e1());
+ MinimalCollection<E> elementsToAdd
+ = MinimalCollection.of(samples.e0, samples.e1, samples.e0, samples.e1);
+ assertTrue("addAll(n, hasDuplicates) should return true",
+ getList().addAll(0, elementsToAdd));
+ expectAdded(0, samples.e0, samples.e1, samples.e0, samples.e1);
}
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
@CollectionFeature.Require(ALLOWS_NULL_VALUES)
public void testAddAllAtIndex_nullSupported() {
List<E> containsNull = singletonList(null);
- assertTrue("addAll(n, containsNull) should return true", getList().addAll(0, containsNull));
+ assertTrue("addAll(n, containsNull) should return true",
+ getList().addAll(0, containsNull));
/*
* We need (E) to force interpretation of null as the single element of a
* varargs array, not the array itself
@@ -134,8 +135,7 @@ public class ListAddAllAtIndexTester<E> extends AbstractListTester<E> {
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
@CollectionSize.Require(absent = {ZERO, ONE})
public void testAddAllAtIndex_middle() {
- assertTrue(
- "addAll(middle, disjoint) should return true",
+ assertTrue("addAll(middle, disjoint) should return true",
getList().addAll(getNumElements() / 2, createDisjointCollection()));
expectAdded(getNumElements() / 2, createDisjointCollection());
}
@@ -143,8 +143,7 @@ public class ListAddAllAtIndexTester<E> extends AbstractListTester<E> {
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
@CollectionSize.Require(absent = ZERO)
public void testAddAllAtIndex_end() {
- assertTrue(
- "addAll(end, disjoint) should return true",
+ assertTrue("addAll(end, disjoint) should return true",
getList().addAll(getNumElements(), createDisjointCollection()));
expectAdded(getNumElements(), createDisjointCollection());
}
@@ -162,22 +161,22 @@ public class ListAddAllAtIndexTester<E> extends AbstractListTester<E> {
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
public void testAddAllAtIndex_negative() {
try {
- getList().addAll(-1, MinimalCollection.of(e3()));
+ getList().addAll(-1, MinimalCollection.of(samples.e3));
fail("addAll(-1, e) should throw");
} catch (IndexOutOfBoundsException expected) {
}
expectUnchanged();
- expectMissing(e3());
+ expectMissing(samples.e3);
}
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
public void testAddAllAtIndex_tooLarge() {
try {
- getList().addAll(getNumElements() + 1, MinimalCollection.of(e3()));
+ getList().addAll(getNumElements() + 1, MinimalCollection.of(samples.e3));
fail("addAll(size + 1, e) should throw");
} catch (IndexOutOfBoundsException expected) {
}
expectUnchanged();
- expectMissing(e3());
+ expectMissing(samples.e3);
}
}