|
29 | 29 | * @author Magnus Skjegstad <magnus@skjegstad.com> |
30 | 30 | */ |
31 | 31 | 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 | + |
32 | 51 | /** |
33 | 52 | * Test of createHash method, of class BloomFilter. |
34 | 53 | * @throws Exception |
@@ -307,9 +326,9 @@ public void testSize() { |
307 | 326 | * @throws UnsupportedEncodingException |
308 | 327 | */ |
309 | 328 | @Test |
310 | | - public void testFalsePositiveRate() throws UnsupportedEncodingException { |
| 329 | + public void testFalsePositiveRate1() throws UnsupportedEncodingException { |
311 | 330 | // Numbers are from // http://pages.cs.wisc.edu/~cao/papers/summary-cache/node8.html |
312 | | - System.out.println("testFalsePositiveRate"); |
| 331 | + System.out.println("falsePositiveRate1"); |
313 | 332 |
|
314 | 333 | for (int j = 10; j < 21; j++) { |
315 | 334 | System.out.print(j-9 + "/11"); |
|
0 commit comments