-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from utastudents/Samuel
some junit tests
- Loading branch information
Showing
1 changed file
with
105 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |