public void testSet() {
PSet<String> a = HashTreePSet.empty(), b = HashTreePSet.empty();
assertEqualsAndHash("empty sets not equal",a,b);
assertTrue("adding element should change empty set",!a.equals(a.plus("one")));
a = a.plus("one");
assertEqualsAndHash("adding duplicate should not change set",a,a.plus("one"));
a = a.plus("two").plus("");
b = b.plus("two").plus("").plus("one").plus("two");
assertEqualsAndHash(a,b);
b = b.plus("three");
assertTrue(!a.equals(b));
int n = b.size();
for(@SuppressWarnings("unused") String s : b) n--;
assertTrue("iterator() should return size() elements", n==0);
assertEqualsAndHash("adding a set to itself should do nothing",b,b.plusAll(b));
assertEqualsAndHash("adding a set to the empty set should be identity",
b, MapPSet.from(HashTreePMap.<String,Object>empty(), b));
assertEqualsAndHash(HashTreePSet.from(Arrays.asList(2)),
HashTreePSet.empty().plus(1).plus(2).minus(1));
}