Skip to content

Commit aa9f09f

Browse files
refactor 40
1 parent f533be9 commit aa9f09f

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed
+27-20
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,39 @@
11
package com.fishercoder;
22

33
import com.fishercoder.solutions._40;
4-
import java.util.ArrayList;
4+
55
import java.util.Arrays;
66
import java.util.List;
7+
78
import org.junit.BeforeClass;
89
import org.junit.Test;
910

1011
import static org.junit.Assert.assertEquals;
1112

1213
public class _40Test {
13-
private static _40.Solution1 solution1;
14-
private static int[] candidates;
15-
private static List<List<Integer>> expected;
16-
17-
@BeforeClass
18-
public static void setup() {
19-
solution1 = new _40.Solution1();
20-
}
21-
22-
@Test
23-
public void test1() {
24-
candidates = new int[] {10, 1, 2, 7, 6, 1, 5};
25-
expected = new ArrayList<>();
26-
expected.add(Arrays.asList(1, 1, 6));
27-
expected.add(Arrays.asList(1, 2, 5));
28-
expected.add(Arrays.asList(1, 7));
29-
expected.add(Arrays.asList(2, 6));
30-
assertEquals(expected, solution1.combinationSum2(candidates, 8));
31-
}
14+
private static _40.Solution1 solution1;
15+
private static int[] candidates;
16+
private static int target;
17+
private static List<List<Integer>> expected;
18+
19+
@BeforeClass
20+
public static void setup() {
21+
solution1 = new _40.Solution1();
22+
}
23+
24+
@Test
25+
public void test1() {
26+
candidates = new int[]{10, 1, 2, 7, 6, 1, 5};
27+
expected = Arrays.asList((Arrays.asList(1, 1, 6)), Arrays.asList(1, 2, 5), Arrays.asList(1, 7), Arrays.asList(2, 6));
28+
target = 8;
29+
assertEquals(expected, solution1.combinationSum2(candidates, target));
30+
}
31+
32+
@Test
33+
public void test2() {
34+
candidates = new int[]{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
35+
expected = Arrays.asList(Arrays.asList(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1));
36+
target = 30;
37+
assertEquals(expected, solution1.combinationSum2(candidates, target));
38+
}
3239
}

0 commit comments

Comments
 (0)