|
@@ -0,0 +1,47 @@
|
|
|
|
|
+package leetcode.p34;
|
|
|
|
|
+
|
|
|
|
|
+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.assertArrayEquals;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * @ProjectName: LeetCode
|
|
|
|
|
+ * @FileName: SolutionTest
|
|
|
|
|
+ * @Author: 杨逸
|
|
|
|
|
+ * @Data:2026/3/9 18:30
|
|
|
|
|
+ * @Description:
|
|
|
|
|
+ */
|
|
|
|
|
+@RunWith(Parameterized.class)
|
|
|
|
|
+public class SolutionTest {
|
|
|
|
|
+ public static final Solution solution = new Solution();
|
|
|
|
|
+ private int[] nums;
|
|
|
|
|
+ private int target;
|
|
|
|
|
+ private int[] expected;
|
|
|
|
|
+
|
|
|
|
|
+ public SolutionTest(int[] nums, int target, int[] expected) {
|
|
|
|
|
+ this.nums = nums;
|
|
|
|
|
+ this.target = target;
|
|
|
|
|
+ this.expected = expected;
|
|
|
|
|
+ }
|
|
|
|
|
+ @Parameterized.Parameters
|
|
|
|
|
+ public static Collection<Object[]> data(){
|
|
|
|
|
+ return Arrays.asList(new Object[][]{
|
|
|
|
|
+ {new int[]{5,7,7,8,8,10},8,new int[]{3,4}},
|
|
|
|
|
+ {new int[]{5,7,7,8,8,10},6,new int[]{-1,-1}},
|
|
|
|
|
+ {new int[]{},0,new int[]{-1,-1}},
|
|
|
|
|
+ {new int[]{1},1,new int[]{0,0}},
|
|
|
|
|
+ {new int[]{1,1,2},1,new int[]{0,1}},
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void searchRange() {
|
|
|
|
|
+ int[] result = solution.searchRange(nums, target);
|
|
|
|
|
+ assertArrayEquals(expected, result);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|