-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPredictiveTest.java
More file actions
116 lines (87 loc) · 2.46 KB
/
PredictiveTest.java
File metadata and controls
116 lines (87 loc) · 2.46 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package predictive;
import static org.junit.Assert.assertEquals;
import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;
import org.junit.jupiter.api.Test;
class PredictiveTest {
@Test
public void ex1Test1() {
assertEquals(PredictivePrototype.wordToSignature("dax"), "329");
assertEquals(PredictivePrototype.wordToSignature("milk"), "6455");
}
@Test
public void ex1Test2() {
Set<String> a = new TreeSet<>();
a.add("dream");
a.add("fream");
Set<String> b = new TreeSet<>();
b.add("flower");
assertEquals(PredictivePrototype.signatureToWords("37326"), a);
assertEquals(PredictivePrototype.signatureToWords("356937"), b);
}
@Test
public void ex1Test3() {
assertEquals(PredictivePrototype.isValidWord("apple"), true);
assertEquals(PredictivePrototype.isValidWord("12dw"), false);
}
@Test
public void ex1Test4() {
ListDictionary dict = new ListDictionary("/usr/share/dict/words");
Set<String> a = new HashSet<String>();
a.add("dream");
a.add("fream");
Set<String> b = new HashSet<String>();
b.add("flower");
Set<String> c = new HashSet<String>();
c.add("zest");
c.add("yest");
c.add("west");
c.add("wert");
c.add("wept");
assertEquals(dict.signatureToWords("37326"), a);
assertEquals(dict.signatureToWords("356937"), b);
assertEquals(dict.signatureToWords("9378"), c);
}
@Test
public void ex1Test5() {
MapDictionary dict = new MapDictionary("/usr/share/dict/words");
Set<String> a = new HashSet<String>();
a.add("dream");
a.add("fream");
Set<String> b = new HashSet<String>();
b.add("flower");
Set<String> c = new HashSet<String>();
c.add("zest");
c.add("yest");
c.add("west");
c.add("wert");
c.add("wept");
assertEquals(dict.signatureToWords("37326"), a);
assertEquals(dict.signatureToWords("356937"), b);
assertEquals(dict.signatureToWords("9378"), c);
}
@Test
public void ex1Test6() {
TreeDictionary dict = new TreeDictionary("/usr/share/dict/words");
Set<String> a = new HashSet<String>();
a.add("dream");
a.add("fream");
Set<String> b = new HashSet<String>();
b.add("flower");
Set<String> c = new HashSet<String>();
c.add("zest");
c.add("yest");
c.add("wept");
c.add("werv");
c.add("yert");
c.add("zeru");
c.add("zequ");
c.add("wert");
c.add("west");
c.add("xeru");
assertEquals(dict.signatureToWords("37326"), a);
assertEquals(dict.signatureToWords("356937"), b);
assertEquals(dict.signatureToWords("9378"), c);
}
}