1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 package org.archive.util.fingerprint;
27
28 import junit.framework.Test;
29 import junit.framework.TestSuite;
30
31 /***
32 * JUnit test suite for LongFPSetCache
33 *
34 * @author <a href="mailto:me@jamesc.net">James Casey</a>
35 * @version $ Id:$
36 */
37 public class LongFPSetCacheTest extends LongFPSetTestCase {
38 /***
39 * Create a new LongFPSetCacheTest object
40 *
41 * @param testName the name of the test
42 */
43 public LongFPSetCacheTest(final String testName) {
44 super(testName);
45 }
46
47 /***
48 * run all the tests for LongFPSetCacheTest
49 *
50 * @param argv the command line arguments
51 */
52 public static void main(String argv[]) {
53 junit.textui.TestRunner.run(suite());
54 }
55
56 /***
57 * return the suite of tests for LongFPSetCacheTest
58 *
59 * @return the suite of test
60 */
61 public static Test suite() {
62 return new TestSuite(LongFPSetCacheTest.class);
63 }
64
65 LongFPSet makeLongFPSet() {
66 return new LongFPSetCache();
67 }
68
69 /***
70 * This is a cache buffer, which does not grow,
71 * but chucks out old values. Therefore it has a different behaviour
72 * from all the other LongFPSets. We do a different test here.
73 */
74
75 public void testCount() {
76 LongFPSet fpSet = new LongFPSetCache();
77
78
79
80
81
82 final int NUM = 800;
83 final int MAX_ENTRIES = 768;
84
85 assertEquals("empty set to start", 0, fpSet.count());
86
87 for (int i = 1; i < NUM; ++i) {
88 fpSet.add((long) i);
89 assertEquals("correct num on add",
90 i<MAX_ENTRIES?i:MAX_ENTRIES, fpSet.count());
91 }
92 }
93
94
95 }
96