forked from fishercoder1534/Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_2Test.java
45 lines (38 loc) · 1.43 KB
/
_2Test.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
package com.fishercoder;
import com.fishercoder.common.classes.ListNode;
import com.fishercoder.common.utils.LinkedListUtils;
import com.fishercoder.solutions._2;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class _2Test {
private static _2.Solution2 solution2;
private static ListNode l1;
private static ListNode l2;
private static ListNode expected;
@BeforeClass
public static void setup(){
solution2 = new _2.Solution2();
}
@Test
public void test1(){
l1 = LinkedListUtils.contructLinkedList(new int[]{2, 4, 3});
l2 = LinkedListUtils.contructLinkedList(new int[]{5, 6, 4});
expected = LinkedListUtils.contructLinkedList(new int[]{7, 0, 8});
assertEquals(expected, solution2.addTwoNumbers(l1, l2));
}
@Test
public void test2(){
l1 = LinkedListUtils.contructLinkedList(new int[]{1, 8});
l2 = LinkedListUtils.contructLinkedList(new int[]{0});
expected = LinkedListUtils.contructLinkedList(new int[]{1, 8});
assertEquals(expected, solution2.addTwoNumbers(l1, l2));
}
@Test
public void test3(){
l1 = LinkedListUtils.contructLinkedList(new int[]{5});
l2 = LinkedListUtils.contructLinkedList(new int[]{5});
expected = LinkedListUtils.contructLinkedList(new int[]{0, 1});
assertEquals(expected, solution2.addTwoNumbers(l1, l2));
}
}