-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReverseLinkedListTest.java
More file actions
30 lines (27 loc) · 1.05 KB
/
Copy pathReverseLinkedListTest.java
File metadata and controls
30 lines (27 loc) · 1.05 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
import org.example.helpers.ListNode;
import org.example.problems.reverse_linked_list.Solution;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.stream.Stream;
public class ReverseLinkedListTest {
private static Stream<Arguments> provideCases() {
return Stream.of(
Arguments.of(
new ListNode(1, new ListNode(2, new ListNode(3, new ListNode(4, new ListNode(5))))),
new ListNode(5, new ListNode(4, new ListNode(3, new ListNode(2, new ListNode(1)))))
),
Arguments.of(
new ListNode(1, new ListNode(2)),
new ListNode(2, new ListNode(1))
)
);
}
@ParameterizedTest
@MethodSource("provideCases")
public void test(ListNode list, ListNode expected) {
Solution s = new Solution();
Assertions.assertTrue(expected.equals(s.reverseList(list)));
}
}