|
@@ -0,0 +1,44 @@
|
|
|
|
|
+package leetcode.p74;
|
|
|
|
|
+
|
|
|
|
|
+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/9 18:01
|
|
|
|
|
+ * @Description:
|
|
|
|
|
+ */
|
|
|
|
|
+@RunWith(Parameterized.class)
|
|
|
|
|
+public class SolutionTest {
|
|
|
|
|
+ public static final Solution solution = new Solution();
|
|
|
|
|
+ private final int[][] matrix;
|
|
|
|
|
+ private final int target;
|
|
|
|
|
+ private final boolean expected;
|
|
|
|
|
+
|
|
|
|
|
+ public SolutionTest(int[][] matrix, int target, boolean expected) {
|
|
|
|
|
+ this.matrix = matrix;
|
|
|
|
|
+ this.target = target;
|
|
|
|
|
+ this.expected = expected;
|
|
|
|
|
+ }
|
|
|
|
|
+ @Parameterized.Parameters
|
|
|
|
|
+ public static Collection<Object[]> data(){
|
|
|
|
|
+ return Arrays.asList(new Object[][]{
|
|
|
|
|
+ {new int[][]{{1,3,5,7},{10,11,16,20},{23,30,34,60}},3,true},
|
|
|
|
|
+ {new int[][]{{1,3,5,7},{10,11,16,20},{23,30,34,60}},13,false},
|
|
|
|
|
+ {new int[][]{{1}},1,true},
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void searchMatrix() {
|
|
|
|
|
+ assertEquals(expected,solution.searchMatrix(matrix,target));
|
|
|
|
|
+ }
|
|
|
|
|
+}
|