public static void Test() { WordSearch obj = new WordSearch(); char[][] board = new char[][] { new char[] { 'A', 'B', 'C', 'E' }, new char[] { 'S', 'F', 'C', 'S' }, new char[] { 'A', 'D', 'E', 'E' } }; obj.Exist(board, "ABCC"); }
public void Exist_ShouldReturn_WhetherTheWordExists() { // Arrange var board = new char[][] { new char[] { 'A', 'B', 'C', 'E' }, new char[] { 'S', 'F', 'C', 'S' }, new char[] { 'A', 'D', 'E', 'E' }, }; var word = "ABCCED"; var expectedResult = true; var wordSearch = new WordSearch(); // Act var result = wordSearch.Exist(board, word); // Assert result.Should().Be(expectedResult); // Arrange board = new char[][] { new char[] { 'A', 'B', 'C', 'E' }, new char[] { 'S', 'F', 'C', 'S' }, new char[] { 'A', 'D', 'E', 'E' }, }; word = "SEE"; expectedResult = true; wordSearch = new WordSearch(); // Act result = wordSearch.Exist(board, word); // Assert result.Should().Be(expectedResult); // Arrange board = new char[][] { new char[] { 'A', 'B', 'C', 'E' }, new char[] { 'S', 'F', 'C', 'S' }, new char[] { 'A', 'D', 'E', 'E' }, }; word = "ABCB"; expectedResult = false; wordSearch = new WordSearch(); // Act result = wordSearch.Exist(board, word); // Assert result.Should().Be(expectedResult); }
public void ComplexTest() { var board = new char[, ] { { 'A', 'B', 'C', 'E' }, { 'S', 'F', 'E', 'S' }, { 'A', 'D', 'E', 'E' } }; Assert.IsTrue(WordSearch.Exist(board, "ABCEFSADEESE")); }
public void Test1() { var input = new char[][] { new char[] { 'A', 'B', 'C', 'E' }, new char[] { 'S', 'F', 'C', 'S' }, new char[] { 'A', 'D', 'E', 'E' } }; var wordSearch = new WordSearch(); Assert.True(wordSearch.Exist(input, "SEE")); Assert.True(wordSearch.Exist(input, "ABCCED")); Assert.False(wordSearch.Exist(input, "ABCB")); var input2 = new char[][] { new char[] { 'A', 'B', 'C', 'E' }, new char[] { 'S', 'F', 'E', 'S' }, new char[] { 'A', 'D', 'E', 'E' } }; Assert.True(wordSearch.Exist(input2, "ABCESEEEFS")); }
public void FindsWordInMatrixTest() { var board = new char[, ] { { 'A', 'B', 'C', 'E' }, { 'S', 'F', 'C', 'S' }, { 'A', 'D', 'E', 'E' } }; Assert.IsTrue(WordSearch.Exist(board, string.Empty)); Assert.IsTrue(WordSearch.Exist(board, "A")); Assert.IsTrue(WordSearch.Exist(board, "C")); Assert.IsTrue(WordSearch.Exist(board, "SEE")); Assert.IsTrue(WordSearch.Exist(board, "ABCCED")); Assert.IsFalse(WordSearch.Exist(board, "ABCB")); }
public void wordSearchTest() { foreach (WordSearchTestData testData in TestDataList) { Console.WriteLine("Test input matrix: "); char[,] matrix = testData.Board; for (int i = 0; i <= matrix.GetUpperBound(0); i++) { for (int j = 0; j <= matrix.GetUpperBound(1); j++) { Console.Write(matrix[i, j] + ", "); } Console.WriteLine(); } Console.WriteLine("Test input word: " + testData.Word); bool result = WordSearch.Exist(testData.Board, testData.Word); Console.WriteLine("Expected output: " + testData.Result); Console.WriteLine("Actual output1: " + result); Assert.AreEqual(testData.Result, result); } }
void InternalTest(char[][] board, string word, bool expected) { bool actual = WordSearch.Exist(board, word); Assert.Equal <bool>(expected, actual); }
public void Test1() { var result = solution.Exist(strToCharArrArr("[['A','B','C','E'],['S','F','C','S'],['A','D','E','E']]"), "ABCCED"); Assert.AreEqual(true, result); }