forked from examplehub/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemoveNthNodeFromEndOfListTest.java
More file actions
34 lines (26 loc) · 1.13 KB
/
RemoveNthNodeFromEndOfListTest.java
File metadata and controls
34 lines (26 loc) · 1.13 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
package com.examplehub.leetcode.middle;
import static org.junit.jupiter.api.Assertions.assertEquals;
import com.examplehub.leetcode.ListNode;
import com.examplehub.utils.NodeUtils;
import org.junit.jupiter.api.Test;
class RemoveNthNodeFromEndOfListTest {
@Test
void testSolution1() {
ListNode head = NodeUtils.makeList(1, 2, 3, 4, 5);
assertEquals("1->2->3->4->5->NULL", NodeUtils.toString(head));
head = RemoveNthNodeFromEndOfList.solution1(head, 2);
assertEquals("1->2->3->5->NULL", NodeUtils.toString(head));
head = NodeUtils.makeList(1, 2);
assertEquals("1->2->NULL", NodeUtils.toString(head));
head = RemoveNthNodeFromEndOfList.solution1(head, 1);
assertEquals("1->NULL", NodeUtils.toString(head));
head = NodeUtils.makeList(1);
assertEquals("1->NULL", NodeUtils.toString(head));
head = RemoveNthNodeFromEndOfList.solution1(head, 1);
assertEquals("NULL", NodeUtils.toString(head));
head = NodeUtils.makeList(1, 2);
assertEquals("1->2->NULL", NodeUtils.toString(head));
head = RemoveNthNodeFromEndOfList.solution1(head, 2);
assertEquals("2->NULL", NodeUtils.toString(head));
}
}