|
@@ -0,0 +1,46 @@
|
|
|
|
|
+package leetcode.p128;
|
|
|
|
|
+
|
|
|
|
|
+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/8 17:27
|
|
|
|
|
+ * @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[]{100,4,200,1,3,2},4},
|
|
|
|
|
+ {new int[]{0,3,7,2,5,8,4,6,0,1},9},
|
|
|
|
|
+ {new int[]{0,3,7,2,5,8,4,6,0,1},9},
|
|
|
|
|
+ {new int[]{1,0,1,2},3},
|
|
|
|
|
+ {new int[]{1,100},1},
|
|
|
|
|
+ {new int[]{0,1,2,4,8,5,6,7,9,3,55,88,77,99,999999999},10},
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test(timeout = 1000L)
|
|
|
|
|
+ public void longestConsecutive() {
|
|
|
|
|
+ int result = solution.longestConsecutive(nums);
|
|
|
|
|
+ assertEquals(expected,result);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|