From 99c0ed263e21326be5fba0e6b10a6303777a0cbf Mon Sep 17 00:00:00 2001 From: 2onefan2 <159247397+2onefan2@users.noreply.github.com> Date: Sun, 28 Apr 2024 21:54:06 -0500 Subject: [PATCH] Updated --- src/test/java/uta/cse3310/GridFieldTest.java | 27 ++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/test/java/uta/cse3310/GridFieldTest.java b/src/test/java/uta/cse3310/GridFieldTest.java index abf65d8..8dac998 100644 --- a/src/test/java/uta/cse3310/GridFieldTest.java +++ b/src/test/java/uta/cse3310/GridFieldTest.java @@ -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 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)); + } + } }