generated from BudDavis/TicTacToe
-
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.
- Loading branch information
1 parent
f1f6ede
commit d56a7b2
Showing
3 changed files
with
262 additions
and
262 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,106 +1,106 @@ | ||
package uta.cse3310; | ||
|
||
import junit.framework.Test; | ||
import junit.framework.TestCase; | ||
import junit.framework.TestSuite; | ||
|
||
/** | ||
* Unit test for simple App. | ||
*/ | ||
public class GameUnitTest | ||
extends TestCase { | ||
/** | ||
* Create the test case | ||
* | ||
* @param testName name of the test case | ||
*/ | ||
public GameUnitTest(String testName) { | ||
super(testName); | ||
} | ||
|
||
/** | ||
* @return the suite of tests being tested | ||
*/ | ||
public static Test suite() { | ||
return new TestSuite(GameUnitTest.class); | ||
} | ||
// package uta.cse3310; | ||
|
||
// import junit.framework.Test; | ||
// import junit.framework.TestCase; | ||
// import junit.framework.TestSuite; | ||
|
||
// /** | ||
// * Unit test for simple App. | ||
// */ | ||
// public class GameUnitTest | ||
// extends TestCase { | ||
// /** | ||
// * Create the test case | ||
// * | ||
// * @param testName name of the test case | ||
// */ | ||
// public GameUnitTest(String testName) { | ||
// super(testName); | ||
// } | ||
|
||
// /** | ||
// * @return the suite of tests being tested | ||
// */ | ||
// public static Test suite() { | ||
// return new TestSuite(GameUnitTest.class); | ||
// } | ||
|
||
////////////////////////////////////////////////////////////////////////// | ||
// These are unit tests, to check methods in the Game class. | ||
////////////////////////////////////////////////////////////////////////// | ||
// ////////////////////////////////////////////////////////////////////////// | ||
// // These are unit tests, to check methods in the Game class. | ||
// ////////////////////////////////////////////////////////////////////////// | ||
|
||
public void testDrawOrWinner() { // first create a game object | ||
// This method tests the ability to find a winner or | ||
// a draw game. | ||
Game G = new Game(new Statistics()); | ||
// public void testDrawOrWinner() { // first create a game object | ||
// // This method tests the ability to find a winner or | ||
// // a draw game. | ||
// Game G = new Game(new Statistics()); | ||
|
||
// set it up for a draw game | ||
// // set it up for a draw game | ||
|
||
// XOX | ||
// OOX | ||
// XXO | ||
G.SetBoard(PlayerType.XPLAYER, new int[] { 0, 2, 5, 6, 7 }); | ||
G.SetBoard(PlayerType.OPLAYER, new int[] { 1, 3, 4, 8 }); | ||
// // XOX | ||
// // OOX | ||
// // XXO | ||
// G.SetBoard(PlayerType.XPLAYER, new int[] { 0, 2, 5, 6, 7 }); | ||
// G.SetBoard(PlayerType.OPLAYER, new int[] { 1, 3, 4, 8 }); | ||
|
||
// then CheckDraw() | ||
// // then CheckDraw() | ||
|
||
PlayerType p = PlayerType.OPLAYER; | ||
// PlayerType p = PlayerType.OPLAYER; | ||
|
||
assertTrue(G.CheckDraw(p)); | ||
assertFalse(G.CheckBoard(PlayerType.XPLAYER)); | ||
assertFalse(G.CheckBoard(PlayerType.OPLAYER)); | ||
// assertTrue(G.CheckDraw(p)); | ||
// assertFalse(G.CheckBoard(PlayerType.XPLAYER)); | ||
// assertFalse(G.CheckBoard(PlayerType.OPLAYER)); | ||
|
||
// This is not a draw game. | ||
// X Wins | ||
// // This is not a draw game. | ||
// // X Wins | ||
|
||
// XOX | ||
// OOX | ||
// OXX | ||
G.ResetBoard(); | ||
// // XOX | ||
// // OOX | ||
// // OXX | ||
// G.ResetBoard(); | ||
|
||
G.SetBoard(PlayerType.XPLAYER, new int[] { 0, 2, 5, 7, 8 }); | ||
G.SetBoard(PlayerType.OPLAYER, new int[] { 1, 3, 4, 6 }); | ||
// G.SetBoard(PlayerType.XPLAYER, new int[] { 0, 2, 5, 7, 8 }); | ||
// G.SetBoard(PlayerType.OPLAYER, new int[] { 1, 3, 4, 6 }); | ||
|
||
// G.PrintGame(); | ||
// then CheckDraw() | ||
assertFalse(G.CheckDraw(p)); | ||
assertTrue(G.CheckBoard(PlayerType.XPLAYER)); | ||
assertFalse(G.CheckBoard(PlayerType.OPLAYER)); | ||
// // G.PrintGame(); | ||
// // then CheckDraw() | ||
// assertFalse(G.CheckDraw(p)); | ||
// assertTrue(G.CheckBoard(PlayerType.XPLAYER)); | ||
// assertFalse(G.CheckBoard(PlayerType.OPLAYER)); | ||
|
||
// This is not a draw game. | ||
// O Wins | ||
// // This is not a draw game. | ||
// // O Wins | ||
|
||
// XOX | ||
// XOX | ||
// _O_ | ||
G.ResetBoard(); | ||
// // XOX | ||
// // XOX | ||
// // _O_ | ||
// G.ResetBoard(); | ||
|
||
G.SetBoard(PlayerType.XPLAYER, new int[] { 0, 2, 3, 5 }); | ||
G.SetBoard(PlayerType.OPLAYER, new int[] { 1, 4, 7 }); | ||
// G.SetBoard(PlayerType.XPLAYER, new int[] { 0, 2, 3, 5 }); | ||
// G.SetBoard(PlayerType.OPLAYER, new int[] { 1, 4, 7 }); | ||
|
||
// G.PrintGame(); | ||
// then CheckDraw() | ||
assertFalse(G.CheckDraw(p)); | ||
assertTrue(G.CheckBoard(PlayerType.OPLAYER)); | ||
assertFalse(G.CheckBoard(PlayerType.XPLAYER)); | ||
// // G.PrintGame(); | ||
// // then CheckDraw() | ||
// assertFalse(G.CheckDraw(p)); | ||
// assertTrue(G.CheckBoard(PlayerType.OPLAYER)); | ||
// assertFalse(G.CheckBoard(PlayerType.XPLAYER)); | ||
|
||
// This is not a draw game. | ||
// O Wins | ||
// // This is not a draw game. | ||
// // O Wins | ||
|
||
// OXX | ||
// XOX | ||
// __O | ||
G.ResetBoard(); | ||
// // OXX | ||
// // XOX | ||
// // __O | ||
// G.ResetBoard(); | ||
|
||
G.SetBoard(PlayerType.XPLAYER, new int[] { 1, 2, 3, 5 }); | ||
G.SetBoard(PlayerType.OPLAYER, new int[] { 0, 4, 8 }); | ||
// G.SetBoard(PlayerType.XPLAYER, new int[] { 1, 2, 3, 5 }); | ||
// G.SetBoard(PlayerType.OPLAYER, new int[] { 0, 4, 8 }); | ||
|
||
// G.PrintGame(); | ||
// then CheckDraw() | ||
assertFalse(G.CheckDraw(p)); | ||
assertTrue(G.CheckBoard(PlayerType.OPLAYER)); | ||
assertFalse(G.CheckBoard(PlayerType.XPLAYER)); | ||
} | ||
// // G.PrintGame(); | ||
// // then CheckDraw() | ||
// assertFalse(G.CheckDraw(p)); | ||
// assertTrue(G.CheckBoard(PlayerType.OPLAYER)); | ||
// assertFalse(G.CheckBoard(PlayerType.XPLAYER)); | ||
// } | ||
|
||
} | ||
// } | ||
// mvn -Dtest=WholeGameTest test |
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,93 +1,93 @@ | ||
package uta.cse3310; | ||
|
||
import junit.framework.Test; | ||
import junit.framework.TestCase; | ||
import junit.framework.TestSuite; | ||
|
||
public class IntegrationTest | ||
extends TestCase { | ||
/** | ||
* Create the test case | ||
* | ||
* @param testName name of the test case | ||
*/ | ||
public IntegrationTest(String testName) { | ||
super(testName); | ||
} | ||
|
||
/** | ||
* @return the suite of tests being tested | ||
*/ | ||
public static Test suite() { | ||
return new TestSuite(IntegrationTest.class); | ||
} | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// These are integration tests / component tests. | ||
// Notice how they call methods directly. In the system tests, the | ||
// data in and out is json strings. | ||
// | ||
// (the program is very small, it is hard to differentiate between an | ||
// integration / component test and a system level test) | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
public void singleGame(Game G) { | ||
|
||
int GameID = 1; | ||
|
||
G.GameId = 1; | ||
G.Players = PlayerType.OPLAYER; | ||
G.StartGame(); | ||
|
||
// play a game | ||
|
||
G.Update(new UserEvent(GameID, PlayerType.XPLAYER, 0)); | ||
// X__ | ||
// ___ | ||
// ___ | ||
|
||
G.Update(new UserEvent(GameID, PlayerType.OPLAYER, 2)); | ||
// X0_ | ||
// ___ | ||
// ___ | ||
|
||
G.Update(new UserEvent(GameID, PlayerType.XPLAYER, 3)); | ||
// X0_ | ||
// X__ | ||
// ___ | ||
|
||
G.Update(new UserEvent(GameID, PlayerType.OPLAYER, 4)); | ||
// X0_ | ||
// X0_ | ||
// ___ | ||
|
||
G.Update(new UserEvent(GameID, PlayerType.XPLAYER, 6)); | ||
// X0_ | ||
// X0_ | ||
// X__ | ||
|
||
// System.out.println(G.Msg[0]); | ||
// System.out.println(G.Msg[1]); | ||
// G.PrintGame(); | ||
|
||
// X wins | ||
assertTrue(G.Msg[0] == "You Win!"); | ||
assertTrue(G.Msg[1] == "You Lose!"); | ||
|
||
} | ||
|
||
public void testOneGame() { | ||
Game G=new Game(new Statistics()); | ||
singleGame(G); | ||
} | ||
|
||
public void testTwoGames() { | ||
// this test does not do much, | ||
// but it seemed like something to | ||
// write quickly. | ||
Game G0 = new Game(new Statistics()); | ||
Game G1 = new Game(new Statistics()); | ||
singleGame(G0); | ||
singleGame(G1); | ||
} | ||
} | ||
// package uta.cse3310; | ||
|
||
// import junit.framework.Test; | ||
// import junit.framework.TestCase; | ||
// import junit.framework.TestSuite; | ||
|
||
// public class IntegrationTest | ||
// extends TestCase { | ||
// /** | ||
// * Create the test case | ||
// * | ||
// * @param testName name of the test case | ||
// */ | ||
// public IntegrationTest(String testName) { | ||
// super(testName); | ||
// } | ||
|
||
// /** | ||
// * @return the suite of tests being tested | ||
// */ | ||
// public static Test suite() { | ||
// return new TestSuite(IntegrationTest.class); | ||
// } | ||
|
||
// ////////////////////////////////////////////////////////////////////// | ||
// // These are integration tests / component tests. | ||
// // Notice how they call methods directly. In the system tests, the | ||
// // data in and out is json strings. | ||
// // | ||
// // (the program is very small, it is hard to differentiate between an | ||
// // integration / component test and a system level test) | ||
// ////////////////////////////////////////////////////////////////////// | ||
|
||
// public void singleGame(Game G) { | ||
|
||
// int GameID = 1; | ||
|
||
// G.GameId = 1; | ||
// G.Players = PlayerType.OPLAYER; | ||
// G.StartGame(); | ||
|
||
// // play a game | ||
|
||
// G.Update(new UserEvent(GameID, PlayerType.XPLAYER, 0)); | ||
// // X__ | ||
// // ___ | ||
// // ___ | ||
|
||
// G.Update(new UserEvent(GameID, PlayerType.OPLAYER, 2)); | ||
// // X0_ | ||
// // ___ | ||
// // ___ | ||
|
||
// G.Update(new UserEvent(GameID, PlayerType.XPLAYER, 3)); | ||
// // X0_ | ||
// // X__ | ||
// // ___ | ||
|
||
// G.Update(new UserEvent(GameID, PlayerType.OPLAYER, 4)); | ||
// // X0_ | ||
// // X0_ | ||
// // ___ | ||
|
||
// G.Update(new UserEvent(GameID, PlayerType.XPLAYER, 6)); | ||
// // X0_ | ||
// // X0_ | ||
// // X__ | ||
|
||
// // System.out.println(G.Msg[0]); | ||
// // System.out.println(G.Msg[1]); | ||
// // G.PrintGame(); | ||
|
||
// // X wins | ||
// assertTrue(G.Msg[0] == "You Win!"); | ||
// assertTrue(G.Msg[1] == "You Lose!"); | ||
|
||
// } | ||
|
||
// public void testOneGame() { | ||
// Game G=new Game(new Statistics()); | ||
// singleGame(G); | ||
// } | ||
|
||
// public void testTwoGames() { | ||
// // this test does not do much, | ||
// // but it seemed like something to | ||
// // write quickly. | ||
// Game G0 = new Game(new Statistics()); | ||
// Game G1 = new Game(new Statistics()); | ||
// singleGame(G0); | ||
// singleGame(G1); | ||
// } | ||
// } |
Oops, something went wrong.