fix OpenBitSet.equals typecheck

git-svn-id: https://svn.apache.org/repos/asf/incubator/solr/trunk@431076 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2006-08-12 19:14:44 +00:00
parent 95639bc526
commit ed7ab7baec
2 changed files with 23 additions and 1 deletions

View File

@ -655,7 +655,7 @@ public class OpenBitSet implements Cloneable, Serializable {
/** returns true if both sets have the same bits set */
public boolean equals(Object o) {
if (this == o) return true;
if (!(this instanceof OpenBitSet)) return false;
if (!(o instanceof OpenBitSet)) return false;
OpenBitSet a;
OpenBitSet b = (OpenBitSet)o;
// make a the larger set.

View File

@ -137,6 +137,28 @@ public class TestOpenBitSet extends TestCase {
// doRandomSets(2000,200000);
}
public void testEquals() {
OpenBitSet b1 = new OpenBitSet(1111);
OpenBitSet b2 = new OpenBitSet(2222);
assertTrue(b1.equals(b2));
assertTrue(b2.equals(b1));
b1.set(10);
assertFalse(b1.equals(b2));
assertFalse(b2.equals(b1));
b2.set(10);
assertTrue(b1.equals(b2));
assertTrue(b2.equals(b1));
b2.set(2221);
assertFalse(b1.equals(b2));
assertFalse(b2.equals(b1));
b1.set(2221);
assertTrue(b1.equals(b2));
assertTrue(b2.equals(b1));
// try different type of object
assertFalse(b1.equals(1));
}
}