methods and contracts.
| Method from org.apache.commons.collections.set.AbstractTestSet Detail: |
public Set getConfirmedSet() {
return (Set)confirmed;
}
|
public Set getSet() {
return (Set)collection;
}
|
public boolean isEqualsCheckable() {
return true;
}
Set equals method is defined. |
public final Collection makeCollection() {
return makeEmptySet();
}
|
public Collection makeConfirmedCollection() {
return new HashSet();
}
Returns an empty Set for use in modification testing. |
public Collection makeConfirmedFullCollection() {
Collection set = makeConfirmedCollection();
set.addAll(Arrays.asList(getFullElements()));
return set;
}
Returns a full Set for use in modification testing. |
abstract public Set makeEmptySet()
Makes an empty set. The returned set should have no elements. |
public final Collection makeFullCollection() {
return makeFullSet();
}
|
public Set makeFullSet() {
Set set = makeEmptySet();
set.addAll(Arrays.asList(getFullElements()));
return set;
}
Makes a full set by first creating an empty set and then adding
all the elements returned by #getFullElements() .
Override if your set does not support the add operation. |
public void testSetEquals() {
resetEmpty();
assertEquals("Empty sets should be equal",
getSet(), getConfirmedSet());
verify();
Collection set2 = makeConfirmedCollection();
set2.add("foo");
assertTrue("Empty set shouldn't equal nonempty set",
!getSet().equals(set2));
resetFull();
assertEquals("Full sets should be equal", getSet(), getConfirmedSet());
verify();
set2.clear();
set2.addAll(Arrays.asList(getOtherElements()));
assertTrue("Sets with different contents shouldn't be equal",
!getSet().equals(set2));
}
|
public void testSetHashCode() {
resetEmpty();
assertEquals("Empty sets have equal hashCodes",
getSet().hashCode(), getConfirmedSet().hashCode());
resetFull();
assertEquals("Equal sets have equal hashCodes",
getSet().hashCode(), getConfirmedSet().hashCode());
}
|
public void verify() {
super.verify();
assertEquals("Sets should be equal", confirmed, collection);
assertEquals("Sets should have equal hashCodes",
confirmed.hashCode(), collection.hashCode());
Collection set = makeConfirmedCollection();
Iterator iterator = collection.iterator();
while (iterator.hasNext()) {
assertTrue("Set.iterator should only return unique elements",
set.add(iterator.next()));
}
}
Provides additional verifications for sets. |