Coverage Summary for Class: ListRetainAllTester (com.google.common.collect.testing.testers)
| Class | Class, % | Method, % | Line, % |
|---|---|---|---|
| ListRetainAllTester | 100% (1/1) | 100% (4/4) | 100% (19/19) |
1 /* 2 * Copyright (C) 2008 The Guava Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.common.collect.testing.testers; 18 19 import static com.google.common.collect.testing.Helpers.assertContentsInOrder; 20 import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_REMOVE; 21 import static com.google.common.collect.testing.features.CollectionSize.ONE; 22 import static com.google.common.collect.testing.features.CollectionSize.SEVERAL; 23 import static com.google.common.collect.testing.features.CollectionSize.ZERO; 24 25 import com.google.common.annotations.GwtCompatible; 26 import com.google.common.collect.testing.MinimalCollection; 27 import com.google.common.collect.testing.features.CollectionFeature; 28 import com.google.common.collect.testing.features.CollectionSize; 29 import java.util.Arrays; 30 import org.junit.Ignore; 31 32 /** 33 * A generic JUnit test which tests {@code retainAll} operations on a list. Can't be invoked 34 * directly; please see {@link com.google.common.collect.testing.ListTestSuiteBuilder}. 35 * 36 * @author Chris Povirk 37 */ 38 @GwtCompatible 39 @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests. 40 public class ListRetainAllTester<E> extends AbstractListTester<E> { 41 @CollectionFeature.Require(SUPPORTS_REMOVE) 42 @CollectionSize.Require(absent = {ZERO, ONE}) 43 public void testRetainAll_duplicatesKept() { 44 E[] array = createSamplesArray(); 45 array[1] = e0(); 46 collection = getSubjectGenerator().create(array); 47 assertFalse( 48 "containsDuplicates.retainAll(superset) should return false", 49 collection.retainAll(MinimalCollection.of(createSamplesArray()))); 50 expectContents(array); 51 } 52 53 @SuppressWarnings("unchecked") 54 @CollectionFeature.Require(SUPPORTS_REMOVE) 55 @CollectionSize.Require(SEVERAL) 56 public void testRetainAll_duplicatesRemoved() { 57 E[] array = createSamplesArray(); 58 array[1] = e0(); 59 collection = getSubjectGenerator().create(array); 60 assertTrue( 61 "containsDuplicates.retainAll(subset) should return true", 62 collection.retainAll(MinimalCollection.of(e2()))); 63 expectContents(e2()); 64 } 65 66 @SuppressWarnings("unchecked") 67 @CollectionFeature.Require(SUPPORTS_REMOVE) 68 @CollectionSize.Require(SEVERAL) 69 public void testRetainAll_countIgnored() { 70 resetContainer(getSubjectGenerator().create(e0(), e2(), e1(), e0())); 71 assertTrue(getList().retainAll(Arrays.asList(e0(), e1()))); 72 assertContentsInOrder(getList(), e0(), e1(), e0()); 73 } 74 }