| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- package leetcode.p53;
- import org.junit.Test;
- import org.junit.runner.RunWith;
- import org.junit.runners.Parameterized;
- import java.util.Arrays;
- import java.util.Collection;
- import static org.junit.Assert.assertEquals;
- /**
- * @ProjectName: LeetCode
- * @FileName: SolutionTest
- * @Author: 杨逸
- * @Data:2026/3/23 22:40
- * @Description:
- */
- @RunWith(Parameterized.class)
- public class SolutionTest {
- public static final Solution solution = new Solution();
- private int[] nums;
- private int expected;
- public SolutionTest(int[] nums, int expected) {
- this.nums = nums;
- this.expected = expected;
- }
- @Parameterized.Parameters
- public static Collection<Object[]> data() {
- return Arrays.asList(new Object[][]{
- {new int[]{-2,1,-3,4,-1,2,1,-5,4},6},
- {new int[]{1},1},
- {new int[]{5,4,-1,7,8},23},
- });
- }
- @Test
- public void maxSubArray() {
- assertEquals(expected,solution.maxSubArray(nums));
- }
- }
|