-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTests.java
More file actions
104 lines (94 loc) · 2.97 KB
/
Tests.java
File metadata and controls
104 lines (94 loc) · 2.97 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
import org.junit.Assert;
import org.junit.Test;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.PriorityQueue;
public class Tests {
@Test
public void testInsert()
{
Trie x = new Trie();
x.insertMain("hi", 5);
System.out.println(x.starter.value);
System.out.println(x.starter.get('h').value);
System.out.println(x.starter.get('h').get('i').value);
System.out.println(x.starter.get('h').get('i').wF);
System.out.println(x.starter.get('h').get('i').word);
}
@Test
public void test2()
{
Trie x = new Trie();
x.insertMain("hello", 10);
x.insertMain("hell", 10);
x.insertMain("hey", 15);
x.insertMain("hi", 5);
x.findStarter("hi");
x.findStarter("he");
}@Test
public void testGetWords()
{
Trie x = new Trie();
x.insertMain("hello", 10);
x.insertMain("hey", 12);
x.insertMain("hi", 5);
x.insertMain("hat", 20);
x.insertMain("heap", 15);
x.insertMain("all", 5);
// System.out.println(x.starter.get('h').get('e').get('l').get('l').get('o').word);
PriorityQueue<Node> temp = x.findStarter("h");
for(int i = 0; i < temp.size(); i ++)
{
System.out.println(temp.remove().word);
}
Assert.assertEquals(null, x.findStarter("lo"));
Assert.assertEquals("heap", x.findStarter("he").remove().word);
Assert.assertEquals("hat", x.findStarter("h").remove().word);
}
@Test
public void testSort() {
Trie x = new Trie();
x.insertMain("ha", 1);
x.insertMain("he", 2);
x.insertMain("hi", 3);
x.insertMain("hl", 4);
x.insertMain("hz", 5);
x.insertMain("hq", 6);
x.insertMain("hw", 7);
x.insertMain("hy", 8);
x.insertMain("hd", 9);
x.insertMain("hs", 10);
x.insertMain("hsl", 20);
x.insertMain("all", 11);
PriorityQueue<Node> temp = x.findStarter("h");
x.sortAndPrint(temp);
// Should Print
//
// hd
// hw
// hq
// hw
// hy
}
@Test
public void testLarge() throws IOException {
Trie x = new Trie();
BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\cassi\\ATDP\\Porject-2\\count_1w.txt"));
String line;
int i = 0;
while ((line = br.readLine()) != null) {
String[] values = line.split("\t");
long fre = Long.parseLong(values[1]);
x.insertMain(values[0], fre);
i++;
if(i > 10000)
{
break;
}
}
PriorityQueue<Node> temp = x.findStarter("t");
// System.out.println(temp.remove().wF);
System.out.println(x.starter.get('t').get('h').get('e').word);
}
}