Coverage Summary for Class: MultimapKeySetTester (com.google.common.collect.testing.google)
| Class | Class, % | Method, % | Line, % |
|---|---|---|---|
| MultimapKeySetTester | 0% (0/1) | 0% (0/6) | 0% (0/23) |
1 /* 2 * Copyright (C) 2013 The Guava Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 * in compliance with the License. You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software distributed under the License 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 * or implied. See the License for the specific language governing permissions and limitations under 12 * the License. 13 */ 14 15 package com.google.common.collect.testing.google; 16 17 import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_ITERATOR_REMOVE; 18 import static com.google.common.collect.testing.features.CollectionSize.ZERO; 19 import static com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_KEYS; 20 import static com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_KEY_QUERIES; 21 import static com.google.common.collect.testing.features.MapFeature.SUPPORTS_REMOVE; 22 23 import com.google.common.annotations.GwtCompatible; 24 import com.google.common.collect.Multimap; 25 import com.google.common.collect.testing.features.CollectionFeature; 26 import com.google.common.collect.testing.features.CollectionSize; 27 import com.google.common.collect.testing.features.MapFeature; 28 import java.util.Iterator; 29 import java.util.Map.Entry; 30 import org.junit.Ignore; 31 32 /** 33 * Tester for {@code Multimap.keySet}. 34 * 35 * @author Louis Wasserman 36 */ 37 @GwtCompatible 38 @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests. 39 public class MultimapKeySetTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> { 40 public void testKeySet() { 41 for (Entry<K, V> entry : getSampleElements()) { 42 assertTrue(multimap().keySet().contains(entry.getKey())); 43 } 44 } 45 46 @CollectionSize.Require(absent = ZERO) 47 @MapFeature.Require(ALLOWS_NULL_KEYS) 48 public void testKeySetContainsNullKeyPresent() { 49 initMultimapWithNullKey(); 50 assertTrue(multimap().keySet().contains(null)); 51 } 52 53 @MapFeature.Require(ALLOWS_NULL_KEY_QUERIES) 54 public void testKeySetContainsNullKeyAbsent() { 55 assertFalse(multimap().keySet().contains(null)); 56 } 57 58 @MapFeature.Require(SUPPORTS_REMOVE) 59 public void testKeySetRemovePropagatesToMultimap() { 60 int key0Count = multimap().get(k0()).size(); 61 assertEquals(key0Count > 0, multimap().keySet().remove(k0())); 62 assertEquals(getNumElements() - key0Count, multimap().size()); 63 assertGet(k0()); 64 } 65 66 @CollectionSize.Require(absent = ZERO) 67 @CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE) 68 public void testKeySetIteratorRemove() { 69 int key0Count = multimap().get(k0()).size(); 70 Iterator<K> keyItr = multimap().keySet().iterator(); 71 while (keyItr.hasNext()) { 72 if (keyItr.next().equals(k0())) { 73 keyItr.remove(); 74 } 75 } 76 assertEquals(getNumElements() - key0Count, multimap().size()); 77 assertGet(k0()); 78 } 79 }