Skip to content

Commit

Permalink
testFillerLetter() added
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisEDelRio committed May 1, 2024
1 parent b2bbb18 commit d33200b
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 32 deletions.
5 changes: 5 additions & 0 deletions src/main/java/uta/cse3310/Matrix.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public class Matrix {
public ArrayList<Character> fillerCharachters; //a list of ALL possible filler charachters aka alphabette
public ArrayList<String> wordBankList; //Used to store the chosen words to display onto the word bank

//testing
public ArrayList<Character> fillerCharactersUsed = new ArrayList<Charachter>();

//non-default constructor
Matrix(String filename){
}
Expand Down Expand Up @@ -510,6 +513,8 @@ public int insertFillerChar(){
r = rand.nextInt(fillerCharachters.size());
char ch = fillerCharachters.get(r);
grid[y][x] = ch;
//testing
fillerCharactersUsed.add(ch);
inserts ++;

}
Expand Down
86 changes: 54 additions & 32 deletions src/test/java/uta/cse3310/MatrixTest.java
Original file line number Diff line number Diff line change
@@ -1,92 +1,114 @@
package uta.cse3310;

import junit.framework.TestCase;
import java.util.List;
import java.util.ArrayList;

public class MatrixTest extends TestCase
{
public void testGridHasWords() {
char[][] grid = new char[50][50];
List<String> wordBank = new ArrayList<String>();
wordBank.add("Ant");
wordBank.add("Zebra");
wordBank.add("Baboon");

boolean result = gridHasWords(grid, wordBank);

assertFalse(result); // Add your assertions based on the expected behavior
}
public class MatrixTest extends TestCase {
public void testGridHasWords() {
char[][] grid = new char[30][30];
List<String> wordBank = new ArrayList<String>();
wordBank.add("Ant");
wordBank.add("Zebra");
wordBank.add("Baboon");

boolean result = gridHasWords(grid, wordBank);

//Matrix wordSearch = new Matrix(grid);
assertFalse(result); // Add your assertions based on the expected behavior
}

//wordSearch.horizontalWordInsert(false,null, grid);
// Matrix wordSearch = new Matrix(grid);

//assertTrue(gridHasWords(grid, wordBank));

// wordSearch.horizontalWordInsert(false,null, grid);

boolean gridHasWords(char[][] grid, List<String> wordBank){
// assertTrue(gridHasWords(grid, wordBank));

boolean gridHasWords(char[][] grid, List<String> wordBank) {
return false;
}
public void testingWordLayout(){

public void testingWordLayout() {
boolean insert1 = verticalWordInsert("Test1");
boolean insert2 = horizontalWordInsert("Test2");
boolean insert3 = diagonalWordInsert1("Test3");

if(!insert1){
if (!insert1) {
System.out.println("Word not printed vertically");
}

if(!insert2){
if (!insert2) {
System.out.println("Word not printed horizontally");
}

if(!insert3){
if (!insert3) {
System.out.println("Word not printed diagonally");
}

String expWord = "Test";
StringBuilder actualWord = new StringBuilder();

for(int i = 0; i < expWord.length(); i++){ //tests the diagonal part
for (int i = 0; i < expWord.length(); i++) { // tests the diagonal part
actualWord.append(grid[i][i]);
}

for(int i = 0; i < expWord.length(); i++){ //tests the horizontal part
for (int i = 0; i < expWord.length(); i++) { // tests the horizontal part
actualWord.append(grid[0][i]);
}

for(int i = 0; i < expWord.length(); i++){ //tests the vertical part
for (int i = 0; i < expWord.length(); i++) { // tests the vertical part
actualWord.append(grid[i][0]);
}

if(!expWord.equals(actualWord.toString())){
if (!expWord.equals(actualWord.toString())) {
System.out.println("Word wasn't inserted correctly diagonally");
}

System.out.println("Test Case: PASSED");
}

public void testDensity(){
public void testDensity() {
fillGrid();

float minDens = 0.6f;
float expMinDens = minDens;

assertFalse("The density is below the minimum", calcDensity() >= expMinDens);


System.out.println("Test Case for density: PASSED");

}

public void testSharedLetters(){
public void testSharedLetters() {
boolean testWord = horizontalWordInsert("Testing");
assertTrue("Failed to share two words together", testWord);

boolean testWord2 = horizontalWordInsert("Together");
assertTrue("Failed to share two words together", testWord2);
}


public void testFillerLetter(){
Matrix m = new Matrix();

//for each letter in the alphabete A - Z
System.out.println("We except to see a similar amount of each letter used as a filler");
System.out.println("Char:Count");
for(char C: m.fillerCharachters){
//for all filler charachters inserted into our matrix
int count = 0;
//find how many matches for each letter we get
for(char I: m.fillerCharactersUsed){
if(C == I){
count++;
}
System.out.println(C + " : " + count);
}


}




}
}

0 comments on commit d33200b

Please sign in to comment.