Skip to content

Commit

Permalink
Parameterize testCopy()
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Oct 5, 2024
1 parent 1f7cff8 commit 730d972
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,23 +202,6 @@ public void testClear() {
assertEquals(0, bf1.cardinality());
}

@Test
public void testCopy() {
final BloomFilter bf1 = createFilter(getTestShape(), TestingHashers.FROM1);
assertNotEquals(0, bf1.cardinality());
final BloomFilter copy = bf1.copy();
assertNotSame(bf1, copy);
assertArrayEquals(bf1.asBitMapArray(), copy.asBitMapArray());
assertArrayEquals(bf1.asIndexArray(), copy.asIndexArray());
assertEquals(bf1.cardinality(), copy.cardinality());
assertEquals(bf1.characteristics(), copy.characteristics());
assertEquals(bf1.estimateN(), copy.estimateN());
assertEquals(bf1.getClass(), copy.getClass());
assertEquals(bf1.getShape(), copy.getShape());
assertEquals(bf1.isEmpty(), copy.isEmpty());
assertEquals(bf1.isFull(), copy.isFull());
}

@Test
public final void testContains() {
BloomFilter bf1 = createFilter(getTestShape(), TestingHashers.FROM1);
Expand Down Expand Up @@ -256,6 +239,29 @@ public final void testContains() {
assertTrue(bf4.contains(bf1));
}

@Test
public void testCopy() {
testCopy(true);
}

protected void testCopy(final boolean assertClass) {
final BloomFilter bf1 = createFilter(getTestShape(), TestingHashers.FROM1);
assertNotEquals(0, bf1.cardinality());
final BloomFilter copy = bf1.copy();
assertNotSame(bf1, copy);
assertArrayEquals(bf1.asBitMapArray(), copy.asBitMapArray());
assertArrayEquals(bf1.asIndexArray(), copy.asIndexArray());
assertEquals(bf1.cardinality(), copy.cardinality());
assertEquals(bf1.characteristics(), copy.characteristics());
assertEquals(bf1.estimateN(), copy.estimateN());
if (assertClass) {
assertEquals(bf1.getClass(), copy.getClass());
}
assertEquals(bf1.getShape(), copy.getShape());
assertEquals(bf1.isEmpty(), copy.isEmpty());
assertEquals(bf1.isFull(), copy.isFull());
}

@Test
public void testEmptyAfterMergeWithNothing() {
// test the case where is empty after merge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@ public BloomFilter copy() {
};
assertEquals(characteristics, underTest.characteristics());
}

@Override
public void testCopy() {
testCopy(false);
}

}

0 comments on commit 730d972

Please sign in to comment.