final Object elem1 = new Object();
final Object elem2 = new Float(4);
final Object elem3 = "String";
final Object elem4 = Boolean.FALSE;
AttributeSet set1 = new AttributeSet(new Object[] {elem1, elem2, elem3});
if (set1.size() != 3) {
errln("Size is wrong.");
}
if (set1.contains(elem4)){
errln("Set contents are wrong.");
}
if (!set1.contains(elem1)) {
errln("Set contents are wrong.");
}
AttributeSet set2 = new AttributeSet(elem4);
if (set2.size() != 1) {
errln("Size is wrong.");
}
if (!set2.contains(elem4)){
errln("Set contents are wrong.");
}
if (set2.contains(elem1)) {
errln("Set contents are wrong.");
}
Enumeration iter = set2.elements();
if (!iter.nextElement().equals(elem4)) {
errln("Invalid object in iterator.");
}
AttributeSet union = set2.unionWith(set1);
if (!set1.unionWith(set2).equals(union)) {
errln("unionWith is not commutative.");
}
if (!union.contains(elem1) || !union.contains(elem4)) {
errln("Set contents are wrong.");
}
if (!set1.addElement(elem4).equals(union)) {
errln("addElement is wrong.");
}
if (!union.intersectWith(set1).equals(set1)) {
errln("intersectWith is wrong.");
}
if (!union.subtract(set1).equals(set2)) {
errln("subtract is wrong.");
}
}