From 30e722da2d4229e62cc72956cfa0cad68104b367 Mon Sep 17 00:00:00 2001 From: 2onefan2 <159247397+2onefan2@users.noreply.github.com> Date: Sat, 27 Apr 2024 21:11:43 -0500 Subject: [PATCH] Added test case for randomly placing words on the grid in the GridFieldTest class --- src/test/java/uta/cse3310/GridFieldTest.java | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) 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); + } }