Skip to content

Commit 253ad89

Browse files
committed
added test
1 parent 8cf9fd3 commit 253ad89

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.fishercoder;
2+
3+
import com.fishercoder.common.classes.ListNode;
4+
import com.fishercoder.solutions._1;
5+
import org.junit.BeforeClass;
6+
import org.junit.Test;
7+
8+
import static org.junit.Assert.assertArrayEquals;
9+
10+
public class _1Test {
11+
private static _1.Solution1 solution1;
12+
private static _1.Solution2 solution2;
13+
private static ListNode l1;
14+
private static ListNode l2;
15+
16+
private static int[] expected;
17+
18+
@BeforeClass
19+
public static void setup() {
20+
solution1 = new _1.Solution1();
21+
solution2 = new _1.Solution2();
22+
}
23+
24+
@Test
25+
public void test1() {
26+
int[] array = new int[] {2, 7, 11, 16};
27+
expected = new int[]{0, 1};
28+
assertArrayEquals(expected, solution1.twoSum(array, 9));
29+
}
30+
31+
@Test
32+
public void test2() {
33+
int[] array = new int[] {2, 7, 11, 16};
34+
expected = new int[]{-1, -1};
35+
assertArrayEquals(expected, solution1.twoSum(array, 8));
36+
}
37+
38+
@Test
39+
public void test3() {
40+
int[] array = new int[] {2, 7, 11, 16};
41+
expected = new int[]{0, 1};
42+
assertArrayEquals(expected, solution2.twoSum(array, 9));
43+
}
44+
45+
@Test
46+
public void test4() {
47+
int[] array = new int[] {2, 7, 11, 16};
48+
expected = new int[]{-1, -1};
49+
assertArrayEquals(expected, solution2.twoSum(array, 8));
50+
}
51+
}

0 commit comments

Comments
 (0)