Skip to content

Commit 9d38b98

Browse files
committed
Added test for new constructor
1 parent 6518030 commit 9d38b98

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

test/com/skjegstad/utils/BloomFilterTest.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,25 @@
2929
* @author Magnus Skjegstad <magnus@skjegstad.com>
3030
*/
3131
public class BloomFilterTest {
32+
static Random r = new Random();
33+
34+
@Test
35+
public void testConstructorCNK() throws Exception {
36+
System.out.println("BloomFilter(c,n,k)");
37+
38+
for (int i = 0; i < 10000; i++) {
39+
double c = r.nextInt(20) + 1;
40+
int n = r.nextInt(10000) + 1;
41+
int k = r.nextInt(20) + 1;
42+
BloomFilter bf = new BloomFilter(c, n, k);
43+
assertEquals(bf.getK(), k);
44+
assertEquals(bf.getExpectedBitsPerElement(), c, 0);
45+
assertEquals(bf.getExpectedNumberOfElements(), n);
46+
assertEquals(bf.size(), c*n, 0);
47+
}
48+
}
49+
50+
3251
/**
3352
* Test of createHash method, of class BloomFilter.
3453
* @throws Exception
@@ -307,9 +326,9 @@ public void testSize() {
307326
* @throws UnsupportedEncodingException
308327
*/
309328
@Test
310-
public void testFalsePositiveRate() throws UnsupportedEncodingException {
329+
public void testFalsePositiveRate1() throws UnsupportedEncodingException {
311330
// Numbers are from // http://pages.cs.wisc.edu/~cao/papers/summary-cache/node8.html
312-
System.out.println("testFalsePositiveRate");
331+
System.out.println("falsePositiveRate1");
313332

314333
for (int j = 10; j < 21; j++) {
315334
System.out.print(j-9 + "/11");

0 commit comments

Comments
 (0)