- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTwoSumTest.java
More file actions
Latest commit
25 lines (21 loc) · 878 Bytes
/
Copy pathTwoSumTest.java
File metadata and controls
25 lines (21 loc) · 878 Bytes
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
importorg.example.problems.two_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.stream.Stream;
publicclassTwoSumTest {
privatestaticStream<Arguments> provideCasesForTwoSum() {
returnStream.of(
Arguments.of(newint[]{2, 7, 11, 15}, 9, newint[]{0, 1}),
Arguments.of(newint[]{3, 2, 4}, 6, newint[]{1, 2}),
Arguments.of(newint[]{3, 3}, 6, newint[]{0, 1})
);
}
@ParameterizedTest
@MethodSource("provideCasesForTwoSum")
publicvoidtestTwoSum(int[] nums, inttarget, int[] expected) {
Solutionsolution = newSolution();
Assertions.assertArrayEquals(expected, solution.twoSum(nums, target));
}
}