|
|
@@ -0,0 +1,46 @@
|
|
|
+package leetcode.p79;
|
|
|
+
|
|
|
+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 20:15
|
|
|
+ * @Description:
|
|
|
+ */
|
|
|
+@RunWith(Parameterized.class)
|
|
|
+public class SolutionTest {
|
|
|
+ public static final Solution solution = new Solution();
|
|
|
+ private char[][] board;
|
|
|
+ private String word;
|
|
|
+ private boolean expected;
|
|
|
+
|
|
|
+ public SolutionTest(char[][] board, String word, boolean expected) {
|
|
|
+ this.board = board;
|
|
|
+ this.word = word;
|
|
|
+ this.expected = expected;
|
|
|
+ }
|
|
|
+ @Parameterized.Parameters
|
|
|
+ public static Collection<Object[]> data() {
|
|
|
+ return Arrays.asList(new Object[][]{
|
|
|
+ {new char[][]{{'A','B','C','E'},{'S','F','C','S'},{'A','D','E','E'}}, "ABCCED", true},
|
|
|
+ {new char[][]{{'A','B','C','E'},{'S','F','C','S'},{'A','D','E','E'}}, "SEE", true},
|
|
|
+ {new char[][]{{'A','B','C','E'},{'S','F','C','S'},{'A','D','E','E'}}, "ABCB", false},
|
|
|
+ {new char[][]{{'A'}}, "A", true},
|
|
|
+ {new char[][]{{'a','b'},{'c','d'}}, "acdb", true},
|
|
|
+ });
|
|
|
+ }
|
|
|
+ @Test(timeout = 1000L)
|
|
|
+ public void exist() {
|
|
|
+ boolean result = solution.exist(board, word);
|
|
|
+ assertEquals(expected, result);
|
|
|
+ }
|
|
|
+}
|