forked from examplehub/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeleteNodeInALinkedListTest.java
More file actions
66 lines (53 loc) · 1.71 KB
/
DeleteNodeInALinkedListTest.java
File metadata and controls
66 lines (53 loc) · 1.71 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
package com.examplehub.leetcode.easy;
import static org.junit.jupiter.api.Assertions.*;
import com.examplehub.leetcode.ListNode;
import org.junit.jupiter.api.Test;
class DeleteNodeInALinkedListTest {
@Test
void testSolution1() {
ListNode head = new ListNode(4);
ListNode node2 = new ListNode(5);
ListNode node3 = new ListNode(1);
ListNode node4 = new ListNode(9);
head.next = node2;
node2.next = node3;
node3.next = node4;
assertEquals("4->5->1->9", head.toString());
DeleteNodeInALinkedList.solution1(node2);
assertEquals("4->1->9", head.toString());
head = new ListNode(4);
node2 = new ListNode(5);
node3 = new ListNode(1);
node4 = new ListNode(9);
head.next = node2;
node2.next = node3;
node3.next = node4;
assertEquals("4->5->1->9", head.toString());
DeleteNodeInALinkedList.solution1(node3);
assertEquals("4->5->9", head.toString());
head = new ListNode(1);
node2 = new ListNode(2);
node3 = new ListNode(3);
node4 = new ListNode(4);
head.next = node2;
node2.next = node3;
node3.next = node4;
assertEquals("1->2->3->4", head.toString());
DeleteNodeInALinkedList.solution1(node3);
assertEquals("1->2->4", head.toString());
head = new ListNode(0);
node2 = new ListNode(1);
head.next = node2;
assertEquals("0->1", head.toString());
DeleteNodeInALinkedList.solution1(head);
assertEquals("1", head.toString());
head = new ListNode(-3);
node2 = new ListNode(-5);
node3 = new ListNode(-99);
head.next = node2;
node2.next = node3;
assertEquals("-3->-5->-99", head.toString());
DeleteNodeInALinkedList.solution1(head);
assertEquals("-5->-99", head.toString());
}
}