-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndexEntryTest.java
More file actions
99 lines (73 loc) · 2.26 KB
/
Copy pathIndexEntryTest.java
File metadata and controls
99 lines (73 loc) · 2.26 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
package proj5;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Test the IndexEntry
*/
public class IndexEntryTest {
@Test
public void test_constructor() {
IndexEntry entry = new IndexEntry("Hello");
assertEquals("Hello {}", entry.toString());
}
@Test
public void test_addPageNum() {
IndexEntry entry = new IndexEntry("Hello");
entry.addPage(10);
assertEquals("Hello {10}", entry.toString());
}
@Test
public void test_addPageNums() {
IndexEntry entry = new IndexEntry("Hello");
entry.addPage(10);
entry.addPage(56);
entry.addPage(12);
entry.addPage(14);
assertEquals("Hello {10, 56, 12, 14}", entry.toString());
}
@Test
public void test_addPageNums_overflow() {
IndexEntry entry = new IndexEntry("Hello");
entry.addPage(10);
entry.addPage(56);
entry.addPage(12);
assertTrue(entry.addPage(14));
assertEquals("Hello {10, 56, 12, 14}", entry.toString());
assertFalse(entry.addPage(100));
assertEquals("Hello {10, 56, 12, 14}", entry.toString());
}
@Test
public void test_compareTo_equals() {
IndexEntry entry1 = new IndexEntry("A");
IndexEntry entry2 = new IndexEntry("A");
assertTrue(entry1.compareTo(entry2) == 0);
assertTrue(entry1.equals(entry2));
}
@Test
public void test_compareTo_1GT2() {
IndexEntry entry1 = new IndexEntry("B");
IndexEntry entry2 = new IndexEntry("A");
assertTrue(entry1.compareTo(entry2) > 0);
assertFalse(entry1.equals(entry2));
}
@Test
public void test_compareTo_1LT2() {
IndexEntry entry1 = new IndexEntry("A");
IndexEntry entry2 = new IndexEntry("B");
assertTrue(entry1.compareTo(entry2) < 0);
assertFalse(entry1.equals(entry2));
}
@Test
public void test_getPages() {
IndexEntry entry1 = new IndexEntry("B");
entry1.addPage(3);
entry1.addPage(10);
assertEquals(2, entry1.getNumPages());
}
@Test
public void test_getWord() {
IndexEntry entry1 = new IndexEntry("Hey");
entry1.addPage(3);
assertEquals("Hey", entry1.getWord());
}
}