Coverage Summary for Class: MultimapContainsKeyTester (com.google.common.collect.testing.google)

Class Class, % Method, % Line, %
MultimapContainsKeyTester 0% (0/1) 0% (0/10) 0% (0/31)


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.features.CollectionSize.ZERO; 20 import static com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_KEYS; 21 import static com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_KEY_QUERIES; 22  23 import com.google.common.annotations.GwtCompatible; 24 import com.google.common.collect.Multimap; 25 import com.google.common.collect.testing.features.CollectionSize; 26 import com.google.common.collect.testing.features.MapFeature; 27 import org.junit.Ignore; 28  29 /** 30  * Tester for the {@code containsKey} methods of {@code Multimap} and its {@code asMap()} view. 31  * 32  * @author Louis Wasserman 33  */ 34 @GwtCompatible 35 @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests. 36 public class MultimapContainsKeyTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> { 37  @CollectionSize.Require(absent = ZERO) 38  public void testContainsKeyYes() { 39  assertTrue(multimap().containsKey(k0())); 40  } 41  42  public void testContainsKeyNo() { 43  assertFalse(multimap().containsKey(k3())); 44  } 45  46  public void testContainsKeysFromKeySet() { 47  for (K k : multimap().keySet()) { 48  assertTrue(multimap().containsKey(k)); 49  } 50  } 51  52  public void testContainsKeyAgreesWithGet() { 53  for (K k : sampleKeys()) { 54  assertEquals(!multimap().get(k).isEmpty(), multimap().containsKey(k)); 55  } 56  } 57  58  public void testContainsKeyAgreesWithAsMap() { 59  for (K k : sampleKeys()) { 60  assertEquals(multimap().containsKey(k), multimap().asMap().containsKey(k)); 61  } 62  } 63  64  public void testContainsKeyAgreesWithKeySet() { 65  for (K k : sampleKeys()) { 66  assertEquals(multimap().containsKey(k), multimap().keySet().contains(k)); 67  } 68  } 69  70  @MapFeature.Require(ALLOWS_NULL_KEYS) 71  @CollectionSize.Require(absent = ZERO) 72  public void testContainsKeyNullPresent() { 73  initMultimapWithNullKey(); 74  assertTrue(multimap().containsKey(null)); 75  } 76  77  @MapFeature.Require(ALLOWS_NULL_KEY_QUERIES) 78  public void testContainsKeyNullAbsent() { 79  assertFalse(multimap().containsKey(null)); 80  } 81  82  @MapFeature.Require(absent = ALLOWS_NULL_KEY_QUERIES) 83  public void testContainsKeyNullDisallowed() { 84  try { 85  multimap().containsKey(null); 86  fail("Expected NullPointerException"); 87  } catch (NullPointerException expected) { 88  // success 89  } 90  } 91 }