-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kenil
committed
Apr 23, 2024
1 parent
088364d
commit 4aa88e3
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import static org.junit.Assert.*; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import java.util.Arrays; | ||
|
||
public class GameTest { | ||
private Game game; | ||
|
||
@Before | ||
public void setUp() { | ||
game = new Game("testWords.txt", 5, 10); | ||
} | ||
|
||
@Test | ||
public void testMatrixInitialization() { | ||
char[][] matrix = game.getMatrix(); | ||
for (char[] row : matrix) { | ||
for (char cell : row) { | ||
assertEquals('.', cell); | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
public void testWordPlacement() { | ||
game.placeWords(); | ||
assertTrue("Expected at least one word placed", game.getNumofWords() > 0); | ||
} | ||
|
||
@Test | ||
public void testFillRandom() { | ||
game.fillRandom(); | ||
char[][] matrix = game.getMatrix(); | ||
boolean hasRandomLetters = false; | ||
for (int i = 0; i < matrix.length; i++) { | ||
for (int j = 0; j < matrix[i].length; j++) { | ||
if (matrix[i][j] != '.') { | ||
hasRandomLetters = true; | ||
assertTrue("Character must be a letter", Character.isLetter(matrix[i][j])); | ||
} | ||
} | ||
} | ||
assertTrue("Matrix should contain random letters", hasRandomLetters); | ||
} | ||
|
||
@Test | ||
public void testCheckAnswer() { | ||
assertTrue("Word should be found", game.check_ans(0, 0, 0, 3)); | ||
assertFalse("Word should not be found", game.check_ans(0, 0, 5, 5)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apple | ||
grape | ||
computer | ||
mobile | ||
javac | ||
bottle | ||
speaker | ||
monitor | ||
lightbulb | ||
markers | ||
cables | ||
chargers |