- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCombinationSumTest.java
More file actions
Latest commit
32 lines (28 loc) · 1.38 KB
/
Copy pathCombinationSumTest.java
File metadata and controls
32 lines (28 loc) · 1.38 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
31
32
importorg.example.problems.combination_sum.Solution;
importorg.junit.jupiter.api.Assertions;
importorg.junit.jupiter.params.ParameterizedTest;
importorg.junit.jupiter.params.provider.Arguments;
importorg.junit.jupiter.params.provider.MethodSource;
importjava.util.ArrayList;
importjava.util.Arrays;
importjava.util.List;
importjava.util.stream.Stream;
publicclassCombinationSumTest {
privatestaticStream<Arguments> provideCases() {
returnStream.of(
Arguments.of(newint[]{2, 3, 6, 7}, 7, Arrays.asList(newList[]{Arrays.asList(newInteger[]{3, 2, 2}), Arrays.asList(newInteger[]{7})})),
Arguments.of(newint[]{2, 3, 5}, 8, Arrays.asList(newList[]{Arrays.asList(newInteger[]{2, 2, 2, 2}), Arrays.asList(newInteger[]{3, 3, 2}), Arrays.asList(newInteger[]{5, 3})})),
Arguments.of(newint[]{2}, 1, newArrayList<>())
);
}
@ParameterizedTest
@MethodSource("provideCases")
publicvoidtest(int[] candidates, inttarget, List<List<Integer>> expected) {
Solutions = newSolution();
List<List<Integer>> result = s.combinationSum(candidates, target);
Assertions.assertSame(expected.size(), result.size());
for (inti = 0; i < result.size(); i++) {
Assertions.assertTrue(Arrays.equals(expected.get(i).toArray(newInteger[0]), result.get(i).toArray(newInteger[0])));
}
}
}