五子棋落子游戏 (八)

2014-11-24 11:10:37 · 作者: · 浏览: 6
UCCESS);
assertEquals(game.startGame(WHITE, new int[] { 9, 4 }), SUCCESS);
assertEquals(game.startGame(BLACK, new int[] { 7, 4 }), SUCCESS);
assertEquals(game.startGame(WHITE, new int[] { 2, 4 }), SUCCESS);
assertEquals(game.startGame(BLACK, new int[] { 8, 4 }), BLACK_WIN);

assertEquals(game.startGame(BLACK, new int[] { 4, 4 }), SUCCESS);
assertEquals(game.startGame(WHITE, new int[] { 5, 3 }), SUCCESS);
assertEquals(game.startGame(BLACK, new int[] { 4, 5 }), SUCCESS);
assertEquals(game.startGame(WHITE, new int[] { 7, 6 }), SUCCESS);
assertEquals(game.startGame(BLACK, new int[] { 4, 6 }), SUCCESS);
assertEquals(game.startGame(WHITE, new int[] { 9, 4 }), SUCCESS);
assertEquals(game.startGame(BLACK, new int[] { 4, 7 }), SUCCESS);
assertEquals(game.startGame(WHITE, new int[] { 2, 4 }), SUCCESS);
assertEquals(game.startGame(BLACK, new int[] { 4, 8 }), BLACK_WIN);

// 2条对角线
assertEquals(game.startGame(BLACK, new int[] { 6, 6 }), SUCCESS);
assertEquals(game.startGame(WHITE, new int[] { 9, 4 }), SUCCESS);
assertEquals(game.startGame(BLACK, new int[] { 7, 7 }), SUCCESS);
assertEquals(game.startGame(WHITE, new int[] { 2, 4 }), SUCCESS);
assertEquals(game.startGame(BLACK, new int[] { 4, 4 }), SUCCESS);
assertEquals(game.startGame(WHITE, new int[] { 5, 3 }), SUCCESS);
assertEquals(game.startGame(BLACK, new int[] { 5, 5 }), SUCCESS);
assertEquals(game.startGame(WHITE, new int[] { 7, 6 }), SUCCESS);
assertEquals(game.startGame(BLACK, new int[] { 8, 8 }), BLACK_WIN);

assertEquals(game.startGame(BLACK, new int[] { 4, 6 }), SUCCESS);
assertEquals(game.startGame(WHITE, new int[] { 9, 4 }), SUCCESS);
assertEquals(game.startGame(BLACK, new int[] { 6, 4 }), SUCCESS);
assertEquals(game.startGame(WHITE, new int[] { 2, 4 }), SUCCESS);
assertEquals(game.startGame(BLACK, new int[] { 7, 3 }), SUCCESS);
assertEquals(game.startGame(WHITE, new int[] { 5, 3 }), SUCCESS);
assertEquals(game.startGame(BLACK, new int[] { 5, 5 }), SUCCESS);
assertEquals(game.startGame(WHITE, new int[] { 8, 9 }), SUCCESS);
assertEquals(game.startGame(BLACK, new int[] { 8, 2 }), BLACK_WIN);
}

/**
* CASE2:参数非法
*/
@Test
public void testStartGame2()
{
assertEquals(game.startGame(BLACK, new int[] { 4 }), FAIL);
assertEquals(game.startGame(BLACK, new int[] { 4, -1 }), FAIL);
assertEquals(game.startGame(BLACK, new int[] { -1, 4 }), FAIL);
assertEquals(game.startGame(BLACK, new int[] { 7, 15 }), FAIL);
}

/**
* CASE3:重复落子、顺序不对
*/
@Test
public void testStartGame3()
{
assertEquals(game.startGame(BLACK, new int[] { 4, 4 }), SUCCESS);
assertEquals(game.startGame(BLACK, new int[] { 10, 4 }), FAIL);
assertEquals(game.startGame(WHITE, new int[] { 4, 4 }), FAIL);

assertEquals(game.startGame(WHITE, new int[] { 5, 3 }), SUCCESS);
assertEquals(game.startGame(BLACK, new int[] { 4, 5 }), SUCCESS);
assertEquals(game.startGame(WHITE, new int[] { 7, 6 }), SUCCESS);
assertEquals(game.startGame(BLACK, new int[] { 4, 6 }), SUCCESS);
assertEquals(game.startGame(WHITE, new int[] { 9, 4 }), SUCCESS);
assertEquals(game.startGame(BLACK, new int[] { 4, 7 }), SUCCESS);
assertEquals(game.startGame(WHITE, new int[] { 2, 4 }), SUCCESS);
assertEquals(game.startGame(BLACK, new int[] { 4, 8 }), BLACK_WIN);
}
}