Coverage Summary for Class: MultimapSizeTester (com.google.common.collect.testing.google)
| Class | Class, % | Method, % | Line, % |
|---|---|---|---|
| MultimapSizeTester | 0% (0/1) | 0% (0/8) | 0% (0/39) |
1 /* 2 * Copyright (C) 2012 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.google; 18 19 import static com.google.common.collect.testing.Helpers.mapEntry; 20 import static com.google.common.collect.testing.features.CollectionSize.SEVERAL; 21 import static com.google.common.collect.testing.features.CollectionSize.ZERO; 22 import static com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_KEYS; 23 import static com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_VALUES; 24 25 import com.google.common.annotations.GwtCompatible; 26 import com.google.common.collect.Multimap; 27 import com.google.common.collect.testing.features.CollectionSize; 28 import com.google.common.collect.testing.features.MapFeature; 29 import java.util.Collection; 30 import java.util.Map.Entry; 31 import org.junit.Ignore; 32 33 /** 34 * Tester for the {@code size} methods of {@code Multimap} and its views. 35 * 36 * @author Louis Wasserman 37 */ 38 @GwtCompatible 39 @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests. 40 public class MultimapSizeTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> { 41 42 public void testSize() { 43 int expectedSize = getNumElements(); 44 Multimap<K, V> multimap = multimap(); 45 assertEquals(expectedSize, multimap.size()); 46 47 int size = 0; 48 for (Entry<K, V> entry : multimap.entries()) { 49 assertTrue(multimap.containsEntry(entry.getKey(), entry.getValue())); 50 size++; 51 } 52 assertEquals(expectedSize, size); 53 54 int size2 = 0; 55 for (Entry<K, Collection<V>> entry2 : multimap.asMap().entrySet()) { 56 size2 += entry2.getValue().size(); 57 } 58 assertEquals(expectedSize, size2); 59 } 60 61 @CollectionSize.Require(ZERO) 62 public void testIsEmptyYes() { 63 assertTrue(multimap().isEmpty()); 64 } 65 66 @CollectionSize.Require(absent = ZERO) 67 public void testIsEmptyNo() { 68 assertFalse(multimap().isEmpty()); 69 } 70 71 @CollectionSize.Require(absent = ZERO) 72 @MapFeature.Require(ALLOWS_NULL_KEYS) 73 public void testSizeNullKey() { 74 initMultimapWithNullKey(); 75 assertEquals(getNumElements(), multimap().size()); 76 assertFalse(multimap().isEmpty()); 77 } 78 79 @CollectionSize.Require(absent = ZERO) 80 @MapFeature.Require(ALLOWS_NULL_VALUES) 81 public void testSizeNullValue() { 82 initMultimapWithNullValue(); 83 assertEquals(getNumElements(), multimap().size()); 84 assertFalse(multimap().isEmpty()); 85 } 86 87 @CollectionSize.Require(absent = ZERO) 88 @MapFeature.Require({ALLOWS_NULL_KEYS, ALLOWS_NULL_VALUES}) 89 public void testSizeNullKeyAndValue() { 90 initMultimapWithNullKeyAndValue(); 91 assertEquals(getNumElements(), multimap().size()); 92 assertFalse(multimap().isEmpty()); 93 } 94 95 @CollectionSize.Require(SEVERAL) 96 public void testSizeMultipleValues() { 97 resetContainer(mapEntry(k0(), v0()), mapEntry(k0(), v1()), mapEntry(k0(), v2())); 98 99 assertEquals(3, multimap().size()); 100 assertEquals(3, multimap().entries().size()); 101 assertEquals(3, multimap().keys().size()); 102 103 assertEquals(1, multimap().keySet().size()); 104 assertEquals(1, multimap().asMap().size()); 105 } 106 }