-
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
a9b9647
commit 3c06703
Showing
2 changed files
with
21 additions
and
38 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
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 |
---|---|---|
@@ -1,47 +1,35 @@ | ||
package uta.cse3310; | ||
import junit.framework.TestCase; | ||
|
||
import java.io.IOException; | ||
import java.util.Arrays; | ||
import java.util.Random; | ||
|
||
public class GameTest extends TestCase { | ||
private Game game; | ||
|
||
public Game game; | ||
private int max=50; | ||
public void setUp() { | ||
Random fixedRandom = new Random(42); | ||
game = new Game("testWords.txt" ,5, 10, fixedRandom); | ||
game.fillWithwords(); | ||
|
||
game = new Game("src/test/java/uta/cse3310/testWords.txt", 5, max); | ||
} | ||
|
||
|
||
public void testMatrixInitialization() { | ||
game.initializwithdots(); | ||
char[][] matrix = game.getMatrix(); | ||
for (int i = 0; i < matrix.length; i++) { | ||
for (int j = 0; j < matrix[i].length; j++) { | ||
assertEquals("Matrix should be initialized with dots.", '.', matrix[i][j]); | ||
for (int i = 0; i < max; i++) { | ||
for (int j = 0; j < max; j++) { | ||
|
||
assertEquals('.',matrix[i][j]); | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
public void testWordPlacement() { | ||
|
||
game.fillWithwords(); | ||
assertTrue("Expected at least one word to be placed", game.getNumofWords() > 0); | ||
} | ||
|
||
public void testFillRandom() { | ||
game.fillWithrandom(); | ||
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); | ||
} | ||
|
||
|
||
|
||
} |