Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some junit tests #49

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}

}