/* * boardTest.java * JUnit based test * * Created on February 18, 2006, 7:46 PM * * $ID$ * */ //package tictactoe; import junit.framework.*; //import org.junit.*; //import static org.junit.Assert.*; import java.util.*; /** * * @author dgg */ public class boardTest extends TestCase { public boardTest(String name) { super(name); } //private variables for use by multiple tests private board my_board; private String[][] threeByThree = new String[3][3]; private String[][] winBoard = {{"X","O","X"},{"O","X","X"},{"X","O","O"}}; private String myTurn = "X"; protected void setUp() throws Exception { my_board = new board(3); } protected void tearDown() throws Exception { } public static Test suite() { return new TestSuite(boardTest.class); } public static void main(String args[]){ junit.textui.TestRunner.run(suite()); } public void testBoardReturnSize(){ assertEquals(my_board.currentBoard.length,threeByThree.length); } public void testMove(){ my_board.move(1,1,"x"); assertEquals("x",my_board.currentBoard[1][1]); } public void testBoardReturn(){ threeByThree[1][1] = "X"; my_board.move(1,1,"X"); threeByThree[2][0] = "O"; my_board.move(2,0,"O"); threeByThree[0][0] = "O"; my_board.move(0,0,"O"); threeByThree[0][1] = "X"; my_board.move(0,1,"X"); int i; int j; for (i=0;i<3;i++){ for (j=0;j<3;j++){ assertEquals(threeByThree[i][j],my_board.currentBoard[i][j]); } } } public void testPrintBoard(){ my_board.printBoard(); } public void testTurns(){ assertEquals(myTurn,my_board.whosTurn()); } public void testWin(){ } }