-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNodeTest.java
58 lines (48 loc) · 1.43 KB
/
NodeTest.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
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.junit.Test;
public class NodeTest {
@Test
public void testGetWeight() {
Node node = new Node('t', 5, null);
assertEquals(5, node.getWeight());
}
@Test
public void testGetChar() {
Node node = new Node('t', 5, null);
assertEquals('t', node.getChar());
}
@Test
public void testSetWeight() {
Node node = new Node('t', 5, null);
node.setWeight(10);
assertEquals(10, node.getWeight());
}
@Test
public void testSetChildren() {
Node node = new Node('t', 5, null);
Node[] children = new Node[26];
Node node1 = new Node('a', 1, node);
children[0] = node1;
assertEquals(node1, children[0]);
assertNull(children[1]);
}
@Test
public void testGetChildren() {
Node node = new Node('t', 5, null);
Node[] children = new Node[26];
Node node1 = new Node('a', 1, node);
children[0] = node1;
node.setChildren(children);
assertEquals(node1, node.getChildren()[0]);
assertNull(node.getChildren()[1]);
}
@Test
public void testGetParent() {
Node node = new Node('t', 5, null);
Node[] children = new Node[26];
Node node1 = new Node('a', 1, node);
children[0] = node1;
assertEquals(node, node1.getParent());
}
}