1 changed files with 0 additions and 45 deletions
@ -1,45 +0,0 @@ |
|||||
import org.junit.jupiter.api.Test; |
|
||||
import static org.junit.jupiter.api.Assertions.*; |
|
||||
|
|
||||
class SolutionTest { |
|
||||
|
|
||||
@Test |
|
||||
void reverseListWithMultipleNodes() { |
|
||||
ListNode head = new ListNode(1, new ListNode(2, new ListNode(3, new ListNode(4, new ListNode(5))))); |
|
||||
Solution solution = new Solution(); |
|
||||
ListNode reversed = solution.reverseList(head); |
|
||||
assertEquals(5, reversed.val); |
|
||||
assertEquals(4, reversed.next.val); |
|
||||
assertEquals(3, reversed.next.next.val); |
|
||||
assertEquals(2, reversed.next.next.next.val); |
|
||||
assertEquals(1, reversed.next.next.next.next.val); |
|
||||
assertNull(reversed.next.next.next.next.next); |
|
||||
} |
|
||||
|
|
||||
@Test |
|
||||
void reverseListWithTwoNodes() { |
|
||||
ListNode head = new ListNode(1, new ListNode(2)); |
|
||||
Solution solution = new Solution(); |
|
||||
ListNode reversed = solution.reverseList(head); |
|
||||
assertEquals(2, reversed.val); |
|
||||
assertEquals(1, reversed.next.val); |
|
||||
assertNull(reversed.next.next); |
|
||||
} |
|
||||
|
|
||||
@Test |
|
||||
void reverseListWithSingleNode() { |
|
||||
ListNode head = new ListNode(1); |
|
||||
Solution solution = new Solution(); |
|
||||
ListNode reversed = solution.reverseList(head); |
|
||||
assertEquals(1, reversed.val); |
|
||||
assertNull(reversed.next); |
|
||||
} |
|
||||
|
|
||||
@Test |
|
||||
void reverseListWithEmptyList() { |
|
||||
ListNode head = null; |
|
||||
Solution solution = new Solution(); |
|
||||
ListNode reversed = solution.reverseList(head); |
|
||||
assertNull(reversed); |
|
||||
} |
|
||||
} |
|
Loading…
Reference in new issue