예제 #1
0
 @CollectionSize.Require(absent = CollectionSize.ZERO)
 public void testEquals_smallerSet() {
   Collection<E> fewerElements = getSampleElements(getNumElements() - 1);
   assertFalse(
       "Sets of different sizes should not be equal.",
       getSet().equals(MinimalSet.from(fewerElements)));
 }
예제 #2
0
  @CollectionSize.Require(absent = CollectionSize.ZERO)
  public void testEquals_otherSetWithDifferentElements() {
    Collection<E> elements = getSampleElements(getNumElements() - 1);
    elements.add(getSubjectGenerator().samples().e3);

    assertFalse(
        "A Set should not equal another Set containing different elements.",
        getSet().equals(MinimalSet.from(elements)));
  }
예제 #3
0
  @CollectionSize.Require(absent = CollectionSize.ZERO)
  public void testEquals_otherContainsNull() {
    Collection<E> elements = getSampleElements(getNumElements() - 1);
    elements.add(null);
    Set<E> other = MinimalSet.from(elements);

    assertFalse(
        "Two Sets should not be equal if exactly one of them contains null.",
        getSet().equals(other));
  }
예제 #4
0
  @CollectionSize.Require(absent = CollectionSize.ZERO)
  @CollectionFeature.Require(ALLOWS_NULL_VALUES)
  public void testEquals_containingNull() {
    Collection<E> elements = getSampleElements(getNumElements() - 1);
    elements.add(null);

    collection = getSubjectGenerator().create(elements.toArray());
    assertTrue(
        "A Set should equal any other Set containing the same elements,"
            + " even if some elements are null.",
        getSet().equals(MinimalSet.from(elements)));
  }
예제 #5
0
    @Override
    protected void assertMoreInvariants(Map<K, V> map) {
      // TODO: can these be moved to MapInterfaceTest?
      for (Entry<K, V> entry : map.entrySet()) {
        assertEquals(entry.getKey() + "=" + entry.getValue(), entry.toString());
      }

      assertEquals("{" + joiner.join(map.entrySet()) + "}", map.toString());
      assertEquals("[" + joiner.join(map.entrySet()) + "]", map.entrySet().toString());
      assertEquals("[" + joiner.join(map.keySet()) + "]", map.keySet().toString());
      assertEquals("[" + joiner.join(map.values()) + "]", map.values().toString());

      assertEquals(MinimalSet.from(map.entrySet()), map.entrySet());
      assertEquals(Sets.newHashSet(map.keySet()), map.keySet());
    }
예제 #6
0
 public void testEquals_largerSet() {
   Collection<E> moreElements = getSampleElements(getNumElements() + 1);
   assertFalse(
       "Sets of different sizes should not be equal.",
       getSet().equals(MinimalSet.from(moreElements)));
 }
예제 #7
0
 public void testEquals_otherSetWithSameElements() {
   assertTrue(
       "A Set should equal any other Set containing the same elements.",
       getSet().equals(MinimalSet.from(getSampleElements())));
 }