Skip to content

Commit

Permalink
Merge pull request #49 from utastudents/Samuel
Browse files Browse the repository at this point in the history
some junit tests
  • Loading branch information
sammuelksanchez authored Apr 30, 2024
2 parents c5d4913 + a288f36 commit ce3c9bc
Showing 1 changed file with 105 additions and 5 deletions.
110 changes: 105 additions & 5 deletions src/test/java/com/cse3310/AppTest.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,120 @@
package com.cse3310;
//import static org.junit.Assert.assertArrayEquals;

import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertArrayEquals;

import org.junit.Test;
import java.util.ArrayList;
import java.util.Random;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Rigorous Test :-)
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}

/**
* @return the suite of tests being tested
*/
@Test
public void shouldAnswerWithTrue()
public static Test suite()
{
return new TestSuite( AppTest.class );
}

/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}

public void testGame()
{
assertTrue( true );
}

public void EndIdCase(Game G)
{
ArrayList<Integer> array = new ArrayList<>();
for (int i = 0; i < 47; i++) {
array.add(1);
}

G.endIds = array;

assertTrue(G.isEnd(1) == 0);
}

public void testEndIdCase()
{
ArrayList<String> stringList = new ArrayList<>();

// Add elements to the ArrayList
stringList.add("Apple");
stringList.add("Banana");
stringList.add("Orange");

Game B = new Game(stringList, 1);

EndIdCase(B);
}


public void getCompletedButtonsCase(Game G)
{
ArrayList<Integer> array = new ArrayList<>();
array.add(6);
array.add(7);
array.add(8);
array.add(9);
array.add(10);
array.add(11);

ArrayList<Integer> result = G.getCompletedButtons(6, 11);


assertTrue(result.containsAll(array) == array.containsAll(result));
}

public void testGetCompletedButtons()
{
ArrayList<String> stringList = new ArrayList<>();
stringList.add("Apple");
Game B = new Game(stringList, 1);

getCompletedButtonsCase(B);
}

public void GenerateGrid(Game G) {
// Create a Game object
ArrayList<String> stringList = new ArrayList<>();

// Add elements to the ArrayList
stringList.add("CAT");
char[][] result = G.generateGrid(stringList, new ArrayList<>());
assertEquals(20, result.length);
}

public void testGenerateGrid()
{
ArrayList<String> stringList = new ArrayList<>();
stringList.add("App");
Game B = new Game(stringList, 1);
GenerateGrid(B);
}

}

0 comments on commit ce3c9bc

Please sign in to comment.