diff --git a/src/test/java/uta/cse3310/GridFieldTest.java b/src/test/java/uta/cse3310/GridFieldTest.java index aa1bdff..f35c184 100644 --- a/src/test/java/uta/cse3310/GridFieldTest.java +++ b/src/test/java/uta/cse3310/GridFieldTest.java @@ -3,6 +3,7 @@ import org.junit.Test; import java.util.ArrayList; +import java.util.Arrays; import static org.junit.Assert.*; @@ -54,4 +55,26 @@ public void testAddWord() { assertEquals(1, gridField.getRemainingWords()); assertTrue(gridField.checkWord("HELLO")); } + + @Test + public void testPlaceRandomWords() { + // Create a word list with some words + ArrayList 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); + } }