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

Class Class, % Method, % Line, %
MultisetReadsTester 0% (0/1) 0% (0/13) 0% (0/40)


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.google; 18  19 import static com.google.common.collect.testing.features.CollectionSize.ONE; 20 import static com.google.common.collect.testing.features.CollectionSize.ZERO; 21  22 import com.google.common.annotations.GwtCompatible; 23 import com.google.common.collect.HashMultiset; 24 import com.google.common.collect.Multiset; 25 import com.google.common.collect.Multisets; 26 import com.google.common.collect.testing.features.CollectionSize; 27 import org.junit.Ignore; 28  29 /** 30  * A generic JUnit test which tests multiset-specific read operations. Can't be invoked directly; 31  * please see {@link com.google.common.collect.testing.SetTestSuiteBuilder}. 32  * 33  * @author Jared Levy 34  */ 35 @GwtCompatible 36 @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests. 37 public class MultisetReadsTester<E> extends AbstractMultisetTester<E> { 38  39  @CollectionSize.Require(absent = ZERO) 40  public void testElementSet_contains() { 41  assertTrue( 42  "multiset.elementSet().contains(present) returned false", 43  getMultiset().elementSet().contains(e0())); 44  } 45  46  @CollectionSize.Require(absent = ZERO) 47  public void testEntrySet_contains() { 48  assertTrue( 49  "multiset.entrySet() didn't contain [present, 1]", 50  getMultiset().entrySet().contains(Multisets.immutableEntry(e0(), 1))); 51  } 52  53  public void testEntrySet_contains_count0() { 54  assertFalse( 55  "multiset.entrySet() contains [missing, 0]", 56  getMultiset().entrySet().contains(Multisets.immutableEntry(e3(), 0))); 57  } 58  59  public void testEntrySet_contains_nonentry() { 60  assertFalse( 61  "multiset.entrySet() contains a non-entry", getMultiset().entrySet().contains(e0())); 62  } 63  64  public void testEntrySet_twice() { 65  assertEquals( 66  "calling multiset.entrySet() twice returned unequal sets", 67  getMultiset().entrySet(), 68  getMultiset().entrySet()); 69  } 70  71  @CollectionSize.Require(ZERO) 72  public void testEntrySet_hashCode_size0() { 73  assertEquals( 74  "multiset.entrySet() has incorrect hash code", 0, getMultiset().entrySet().hashCode()); 75  } 76  77  @CollectionSize.Require(ONE) 78  public void testEntrySet_hashCode_size1() { 79  assertEquals( 80  "multiset.entrySet() has incorrect hash code", 81  1 ^ e0().hashCode(), 82  getMultiset().entrySet().hashCode()); 83  } 84  85  public void testEquals_yes() { 86  assertTrue( 87  "multiset doesn't equal a multiset with the same elements", 88  getMultiset().equals(HashMultiset.create(getSampleElements()))); 89  } 90  91  public void testEquals_differentSize() { 92  Multiset<E> other = HashMultiset.create(getSampleElements()); 93  other.add(e0()); 94  assertFalse("multiset equals a multiset with a different size", getMultiset().equals(other)); 95  } 96  97  @CollectionSize.Require(absent = ZERO) 98  public void testEquals_differentElements() { 99  Multiset<E> other = HashMultiset.create(getSampleElements()); 100  other.remove(e0()); 101  other.add(e3()); 102  assertFalse("multiset equals a multiset with different elements", getMultiset().equals(other)); 103  } 104  105  @CollectionSize.Require(ZERO) 106  public void testHashCode_size0() { 107  assertEquals("multiset has incorrect hash code", 0, getMultiset().hashCode()); 108  } 109  110  @CollectionSize.Require(ONE) 111  public void testHashCode_size1() { 112  assertEquals("multiset has incorrect hash code", 1 ^ e0().hashCode(), getMultiset().hashCode()); 113  } 114 }