Skip to content

Commit

Permalink
Added test case for randomly placing words on the grid in the GridFie…
Browse files Browse the repository at this point in the history
…ldTest class
  • Loading branch information
2onefan2 committed Apr 28, 2024
1 parent 28d2ced commit 30e722d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/test/java/uta/cse3310/GridFieldTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;

import static org.junit.Assert.*;

Expand Down Expand Up @@ -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<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);
}
}

0 comments on commit 30e722d

Please sign in to comment.