コード例 #1
0
ファイル: SetupBoardTest.java プロジェクト: knhjp/othello
  public void testCalcBlackMinusWhite() {
    SetupBoard board = new SetupBoard();
    board.resetToStart();
    assertEquals(0, board.calcBlackMinusWhite());

    board.makeMove(1, 34);
    assertEquals(3, board.getBlackMinusWhite());
    assertEquals(3, board.calcBlackMinusWhite());

    board.makeMove(-1, 53);
    assertEquals(0, board.getBlackMinusWhite());
    assertEquals(0, board.calcBlackMinusWhite());

    board.makeMove(1, 66);
    assertEquals(3, board.getBlackMinusWhite());
    assertEquals(3, board.calcBlackMinusWhite());
  }
コード例 #2
0
ファイル: SetupBoardTest.java プロジェクト: knhjp/othello
  public void testSetSquare() {
    SetupBoard board = new SetupBoard();
    board.resetToStart();
    assertEquals(0, board.calcBlackMinusWhite());

    assertEquals(-1, board.getSquare(44));
    board.setSquare(1, 44);
    assertEquals(1, board.getSquare(44));
    assertEquals(2, board.getBlackMinusWhite());

    board.setSquare(0, 44);
    assertEquals(0, board.getSquare(44));
    assertEquals(1, board.getBlackMinusWhite());

    // test invalid inputs

    try {
      board.setSquare(1, 8);
      fail("Should have throw an exception for setting the board wtih an invalid location");
    } catch (Exception e) {
      assertTrue(true);
    }

    try {
      board.setSquare(-1, 91);
      fail("Should have throw an exception for setting the board wtih an invalid location");
    } catch (Exception e) {
      assertTrue(true);
    }

    try {
      board.setSquare(1, 30);
      fail("Should have throw an exception for setting the board wtih an invalid location");
    } catch (Exception e) {
      assertTrue(true);
    }

    try {
      board.setSquare(-1, 59);
      fail("Should have throw an exception for setting the board wtih an invalid location");
    } catch (Exception e) {
      assertTrue(true);
    }
  }