Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
2onefan2 committed Apr 29, 2024
1 parent 8160e13 commit 99c0ed2
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/test/java/uta/cse3310/GridFieldTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,31 @@ public void testAddWord() {
assertEquals(1, gridField.getRemainingWords());
assertTrue(gridField.checkWord("HELLO"));
}

@Test
public void testPlaceRandomWords() {
// Create a word list with some words
ArrayList<String> wordList = new ArrayList<>(Arrays.asList("HELLO", "WORLD", "JAVA", "PROGRAMMING"));

// Create a grid field
GridField gridField = new GridField(wordList);

// Place random words on the grid
gridField.placeRandomWords();

// Get the grid from the grid field
char[][] grid = gridField.getGrid();

// Check if the grid is not null
assertNotNull(grid);

// Check if the grid size is within a reasonable range
assertTrue(grid.length >= 5 && grid.length <= 10);
assertTrue(grid[0].length >= 5 && grid[0].length <= 10);

// Check if all words from the word list are placed on the grid
for (String word : wordList) {
assertTrue(gridField.checkWord(word));
}
}
}

0 comments on commit 99c0ed2

Please sign in to comment.