MCPcopy Create free account
hub / github.com/Qihoo360/poseidon / FilterFunctionTest

Class FilterFunctionTest

builder/index/src/test/java/FilterFunctionTest.java:17–70  ·  view source on GitHub ↗

Created by i-xuchongpeng on 2016/8/11.

Source from the content-addressed store, hash-verified

15 * Created by i-xuchongpeng on 2016/8/11.
16 */
17@RunWith(Parameterized.class)
18public class FilterFunctionTest {
19
20 @BeforeClass
21 public static void setup() {
22 }
23
24 private FilterFunction Filter;
25 private Set<String> input_set = new HashSet<>();
26 private String input = "token_text1";
27 private int result;
28
29 public FilterFunctionTest(String filter_name, int precision, int result) {
30 this.Filter = new FilterFunction(new TokenFilter(filter_name, precision));
31 this.input_set.add("token_text1");
32 this.input_set.add("token_text2");
33 this.input_set.add("token_text3");
34 this.result = result;
35 //System.out.println(Filter.filter_.blacklist_);
36 }
37
38 @Parameterized.Parameters
39 public static Collection data() {
40 return Arrays.asList(new Object[][]{
41 {"src/test/resources/filter1", 10, 1000},
42 {"src/test/resources/filter1", 100, 100},
43 {"src/test/resources/filter1", 1000, 10},
44 {"src/test/resources/filter2", 10, 10000},
45 {"src/test/resources/filter2", 100, 10000}
46 });
47 }
48
49 @Test
50 public void process() throws Exception {
51 int res = 0;
52
53 for (int i = 1; i < 10001; i++) {
54 res += Filter.Process(input).size();
55 }
56
57 Assert.assertEquals(result, res);
58 }
59
60 @Test
61 public void process1() throws Exception {
62 int res = 0;
63
64 for (int i = 1; i < 10001; i++) {
65 res += Filter.Process(input_set).size();
66 }
67 Assert.assertEquals(result * 3, res);
68 }
69
70}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected