| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.google.common.collect.testing.testers; |
| 18 |
|
| 19 |
import static com.google.common.collect.testing.features.CollectionFeature.ALLOWS_NULL_QUERIES; |
| 20 |
import static com.google.common.collect.testing.features.CollectionFeature.ALLOWS_NULL_VALUES; |
| 21 |
import static com.google.common.collect.testing.features.CollectionSize.ZERO; |
| 22 |
|
| 23 |
import com.google.common.annotations.GwtCompatible; |
| 24 |
import com.google.common.collect.testing.AbstractCollectionTester; |
| 25 |
import com.google.common.collect.testing.MinimalCollection; |
| 26 |
import com.google.common.collect.testing.WrongType; |
| 27 |
import com.google.common.collect.testing.features.CollectionFeature; |
| 28 |
import com.google.common.collect.testing.features.CollectionSize; |
| 29 |
import java.util.Collection; |
| 30 |
import org.junit.Ignore; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
@SuppressWarnings("unchecked") |
| 41 |
@GwtCompatible |
| 42 |
@Ignore |
| 43 |
public class CollectionContainsAllTester<E> extends AbstractCollectionTester<E> { |
| 44 |
public void testContainsAll_empty() { |
| 45 |
assertTrue( |
| 46 |
"containsAll(empty) should return true", collection.containsAll(MinimalCollection.of())); |
| 47 |
} |
| 48 |
|
| 49 |
@CollectionSize.Require(absent = ZERO) |
| 50 |
public void testContainsAll_subset() { |
| 51 |
assertTrue( |
| 52 |
"containsAll(subset) should return true", |
| 53 |
collection.containsAll(MinimalCollection.of(e0()))); |
| 54 |
} |
| 55 |
|
| 56 |
public void testContainsAll_sameElements() { |
| 57 |
assertTrue( |
| 58 |
"containsAll(sameElements) should return true", |
| 59 |
collection.containsAll(MinimalCollection.of(createSamplesArray()))); |
| 60 |
} |
| 61 |
|
| 62 |
@SuppressWarnings("ModifyingCollectionWithItself") |
| 63 |
public void testContainsAll_self() { |
| 64 |
assertTrue("containsAll(this) should return true", collection.containsAll(collection)); |
| 65 |
} |
| 66 |
|
| 67 |
public void testContainsAll_partialOverlap() { |
| 68 |
assertFalse( |
| 69 |
"containsAll(partialOverlap) should return false", |
| 70 |
collection.containsAll(MinimalCollection.of(e0(), e3()))); |
| 71 |
} |
| 72 |
|
| 73 |
public void testContainsAll_disjoint() { |
| 74 |
assertFalse( |
| 75 |
"containsAll(disjoint) should return false", |
| 76 |
collection.containsAll(MinimalCollection.of(e3()))); |
| 77 |
} |
| 78 |
|
| 79 |
@CollectionFeature.Require(absent = ALLOWS_NULL_QUERIES) |
| 80 |
public void testContainsAll_nullNotAllowed() { |
| 81 |
try { |
| 82 |
assertFalse(collection.containsAll(MinimalCollection.of((E) null))); |
| 83 |
} catch (NullPointerException tolerated) { |
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
@CollectionFeature.Require(ALLOWS_NULL_QUERIES) |
| 88 |
public void testContainsAll_nullAllowed() { |
| 89 |
assertFalse(collection.containsAll(MinimalCollection.of((E) null))); |
| 90 |
} |
| 91 |
|
| 92 |
@CollectionFeature.Require(ALLOWS_NULL_VALUES) |
| 93 |
@CollectionSize.Require(absent = ZERO) |
| 94 |
public void testContainsAll_nullPresent() { |
| 95 |
initCollectionWithNullElement(); |
| 96 |
assertTrue(collection.containsAll(MinimalCollection.of((E) null))); |
| 97 |
} |
| 98 |
|
| 99 |
public void testContainsAll_wrongType() { |
| 100 |
Collection<WrongType> wrong = MinimalCollection.of(WrongType.VALUE); |
| 101 |
try { |
| 102 |
assertFalse( |
| 103 |
"containsAll(wrongType) should return false or throw", collection.containsAll(wrong)); |
| 104 |
} catch (ClassCastException tolerated) { |
| 105 |
} |
| 106 |
} |
| 107 |
} |