/** * Tests to make sure clearCell returns null if bad arguments are given, and that it returns the * right cell if valid arguments are given. */ public void testClearCell() { Exception caughtEx = null; try { board.clearCell(-1, -1); } catch (Exception ex) { caughtEx = ex; } assertTrue(caughtEx instanceof IllegalStateException); caughtEx = null; try { board.clearCell(9, 9); } catch (Exception ex) { caughtEx = ex; } assertTrue(caughtEx instanceof IllegalStateException); assertNotNull(board.getCell(0, 0).getPieceOnSquare()); assertNotNull(board.getCell(7, 7).getPieceOnSquare()); assertNull(board.getCell(2, 3).getPieceOnSquare()); board.clearCell(0, 0); board.clearCell(7, 7); board.clearCell(2, 3); assertNull(board.getCell(0, 0).getPieceOnSquare()); assertNull(board.getCell(7, 7).getPieceOnSquare()); assertNull(board.getCell(2, 3).getPieceOnSquare()); }