示例#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())));
 }