-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTwoSumTest.java
More file actions
25 lines (21 loc) · 878 Bytes
/
TwoSumTest.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
import org.example.problems.two_sum.Solution;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.stream.Stream;
public class TwoSumTest {
private static Stream<Arguments> provideCasesForTwoSum() {
return Stream.of(
Arguments.of(new int[]{2, 7, 11, 15}, 9, new int[]{0, 1}),
Arguments.of(new int[]{3, 2, 4}, 6, new int[]{1, 2}),
Arguments.of(new int[]{3, 3}, 6, new int[]{0, 1})
);
}
@ParameterizedTest
@MethodSource("provideCasesForTwoSum")
public void testTwoSum(int[] nums, int target, int[] expected) {
Solution solution = new Solution();
Assertions.assertArrayEquals(expected, solution.twoSum(nums, target));
}
}