[gnome-games] chess: Add test for checkmate
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] chess: Add test for checkmate
- Date: Tue, 25 Jan 2011 05:21:26 +0000 (UTC)
commit 5619db4a97b4de47e94c08950b394dfa52ab5d5f
Author: Robert Ancell <robert ancell canonical com>
Date: Tue Jan 25 14:44:51 2011 +1000
chess: Add test for checkmate
glchess/src/test-chess-game.vala | 18 +++++++++++-------
1 files changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/glchess/src/test-chess-game.vala b/glchess/src/test-chess-game.vala
index 5ecf1f0..99552a7 100644
--- a/glchess/src/test-chess-game.vala
+++ b/glchess/src/test-chess-game.vala
@@ -3,7 +3,7 @@ class GlChess
static int test_count = 0;
static int failure_count = 0;
- private static void test_good_move (string fen, string move, string result_fen, CheckState check_state)
+ private static void test_good_move (string fen, string move, string result_fen, CheckState check_state = CheckState.NONE)
{
ChessState state = new ChessState (fen);
test_count++;
@@ -49,29 +49,29 @@ class GlChess
{
/* Pawn move */
test_good_move ("8/8/8/8/8/8/P7/8 w - - 0 1", "a2a3",
- "8/8/8/8/8/P7/8/8 b - - 0 1", CheckState.NONE);
+ "8/8/8/8/8/P7/8/8 b - - 0 1");
/* Pawn march */
test_good_move ("8/8/8/8/8/8/P7/8 w - - 0 1", "a2a4",
- "8/8/8/8/P7/8/8/8 b - a3 0 1", CheckState.NONE);
+ "8/8/8/8/P7/8/8/8 b - a3 0 1");
/* Pawn march only allowed from baseline */
test_bad_move ("8/8/8/8/8/P7/8/8 w - - 0 1", "a2a5");
/* En passant */
test_good_move ("8/8/8/pP6/8/8/8/8 w - a6 0 1", "b5a6",
- "8/8/P7/8/8/8/8/8 b - - 0 1", CheckState.NONE);
+ "8/8/P7/8/8/8/8/8 b - - 0 1");
/* Can't en passant if wasn't allowed */
test_bad_move ("8/8/8/pP6/8/8/8/8 w - - 0 1", "b5a6");
/* Castle kingside */
test_good_move ("8/8/8/8/8/8/8/4K2R w K - 0 1", "O-O",
- "8/8/8/8/8/8/8/5RK1 b - - 0 1", CheckState.NONE);
+ "8/8/8/8/8/8/8/5RK1 b - - 0 1");
/* Castle queenside */
test_good_move ("8/8/8/8/8/8/8/R3K3 w Q - 0 1", "O-O-O",
- "8/8/8/8/8/8/8/2KR4 b - - 0 1", CheckState.NONE);
+ "8/8/8/8/8/8/8/2KR4 b - - 0 1");
/* Can't castle if pieces moved */
test_bad_move ("8/8/8/8/8/8/8/4K2R w - - 0 1", "O-O");
@@ -86,7 +86,11 @@ class GlChess
test_bad_move ("5r2/8/8/8/8/8/8/4K2R w K - 0 1", "O-O");
/* Can't move into check */
- test_bad_move ("4r3/8/8/8/8/8/4R3/4K3 w KQkr - 0 1", "e2f2");
+ test_bad_move ("4r3/8/8/8/8/8/4R3/4K3 w - - 0 1", "e2f2");
+
+ /* Checkmate */
+ test_good_move ("k7/8/8/8/8/8/1R6/1R6 w - - 0 1", "b1a1",
+ "k7/8/8/8/8/8/1R6/R7 b - - 0 1", CheckState.CHECKMATE);
stdout.printf ("%d/%d tests successful\n", test_count - failure_count, test_count);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]