-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGeneratorTest.java
110 lines (96 loc) · 3.12 KB
/
GeneratorTest.java
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
import static org.junit.Assert.*;
import java.util.ArrayList;
import org.junit.Test;
public class GeneratorTest {
@Test
public void testGenerator() {
Trie t = new Trie();
t.buildTrie("wiktionary.txt");
WordGuesser w = new WordGuesser(t);
Generator g = new Generator(w);
assertEquals(w, g.getW());
}
@Test
public void testLoadDict() {
Trie t = new Trie();
t.buildTrie("wiktionary.txt");
WordGuesser w = new WordGuesser(t);
Generator g = new Generator(w);
ArrayList<String> wordlist = new ArrayList<>();
wordlist.add("aaaaa");
wordlist.add("abbbb");
wordlist.add("bbbbb");
wordlist.add("abcde");
wordlist.add("ccccc");
wordlist.add("cccde");
wordlist.add("aabcd");
wordlist.add("abccd");
wordlist.add("aabbc");
wordlist.add("abdda");
assertEquals(wordlist.size(), g.loadDict("test.txt").size());
assertEquals(wordlist.get(1), g.loadDict("test.txt").get(1));
}
@Test
public void testGenerateWord() {
Trie t = new Trie();
t.buildTrie("wiktionary.txt");
WordGuesser w = new WordGuesser(t);
Generator g = new Generator(w);
assertEquals(5, g.generateWord(g.loadDict("test.txt")).length());
}
@Test
public void testGetW() {
Trie t = new Trie();
t.buildTrie("wiktionary.txt");
WordGuesser w = new WordGuesser(t);
Generator g = new Generator(w);
assertEquals(w, g.getW());
}
@Test
public void testSetW() {
Trie t1 = new Trie();
WordGuesser w1 = new WordGuesser(t1);
Generator g = new Generator(w1);
assertEquals(w1, g.getW());
Trie t2 = new Trie();
t2.buildTrie("wiktionary.txt");
WordGuesser w2 = new WordGuesser(t2);
g.setW(w2);
assertEquals(w2, g.getW());
}
@Test
public void testGetWordlist() {
Trie t = new Trie();
t.buildTrie("wiktionary.txt");
WordGuesser w = new WordGuesser(t);
Generator g = new Generator(w);
ArrayList<String> wordlist = new ArrayList<>();
wordlist.add("aaaaa");
wordlist.add("abbbb");
wordlist.add("bbbbb");
wordlist.add("abcde");
wordlist.add("ccccc");
wordlist.add("cccde");
wordlist.add("aabcd");
wordlist.add("abccd");
wordlist.add("aabbc");
wordlist.add("abdda");
g.loadDict("test.txt");
assertEquals(wordlist.size(), g.getWordlist().size());
assertEquals(wordlist.get(1), g.getWordlist().get(1));
}
@Test
public void testSetWordlist() {
Trie t = new Trie();
t.buildTrie("wiktionary.txt");
WordGuesser w = new WordGuesser(t);
Generator g = new Generator(w);
g.loadDict("test.txt");
ArrayList<String> wordlist = new ArrayList<>();
wordlist.add("aa");
wordlist.add("bb");
g.setWordlist(wordlist);
assertEquals(wordlist.size(), g.getWordlist().size());
assertEquals(wordlist.get(1), g.getWordlist().get(1));
}
}