-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndexTest.java
More file actions
105 lines (77 loc) · 2.56 KB
/
Copy pathIndexTest.java
File metadata and controls
105 lines (77 loc) · 2.56 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
package proj5;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Test the Index
*/
public class IndexTest {
@Test
public void test_constructor() {
Index index = new Index();
assertEquals("", index.toString());
}
@Test
public void test_handleWord_initialWord() {
Index index = new Index();
index.handleWord("Hello", 1);
assertEquals("( Hello {1} )", index.toString());
}
@Test
public void test_handleWord_initialWord_updateWord() {
Index index = new Index();
index.handleWord("Hello", 1);
index.handleWord("Hello", 4);
index.handleWord("Hello", 12);
assertEquals("( Hello {1, 4, 12} )", index.toString());
}
@Test
public void test_handleWord_initialWord_multipleWords() {
Index index = new Index();
index.handleWord("Hello", 1);
index.handleWord("Hello", 4);
index.handleWord("World", 7);
index.handleWord("Hello", 12);
index.handleWord("World", 19);
assertEquals("( Hello {1, 4, 12} ( World {7, 19} ))", index.toString());
}
@Test
public void test_handleWord_delete_first_word() {
Index index = new Index();
index.handleWord("Hello", 1);
index.handleWord("Hello", 4);
index.handleWord("World", 7);
index.handleWord("Hello", 12);
index.handleWord("World", 19);
index.handleWord("Hello", 21);
index.handleWord("Hello", 23);
assertEquals("( World {7, 19} )", index.toString());
}
@Test
public void test_handleWord_delete_all_words() {
Index index = new Index();
index.handleWord("Hello", 1);
index.handleWord("Hello", 4);
index.handleWord("World", 7);
index.handleWord("Hello", 12);
index.handleWord("World", 19);
index.handleWord("Hello", 21);
index.handleWord("Hello", 23);
index.handleWord("World", 24);
index.handleWord("World", 25);
index.handleWord("World", 26);
assertEquals("", index.toString());
}
@Test
public void test_handleWord_delete_last_inserted() {
Index index = new Index();
index.handleWord("Hello", 1);
index.handleWord("Hello", 4);
index.handleWord("World", 7);
index.handleWord("Hello", 12);
index.handleWord("World", 19);
index.handleWord("World", 24);
index.handleWord("World", 25);
index.handleWord("World", 26);
assertEquals("( Hello {1, 4, 12} )", index.toString());
}
}