diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2022-01-30 10:00:28 +0100 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2022-01-30 10:00:28 +0100 |
| commit | 159d5334128ff0bb90a8e4e85739dc8bc44baad8 (patch) | |
| tree | c6af2ddd2fe5f7b9cc5cc93f3ce46d78e50afeec /tests/chessarbiter.cpp | |
| parent | 851f31e7ae3c090e6769099128e7adae931286d0 (diff) | |
- Add drawing methods to the API
- Improve tests
Diffstat (limited to 'tests/chessarbiter.cpp')
| -rw-r--r-- | tests/chessarbiter.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/chessarbiter.cpp b/tests/chessarbiter.cpp index 7c2bffe..edee7f0 100644 --- a/tests/chessarbiter.cpp +++ b/tests/chessarbiter.cpp @@ -300,3 +300,61 @@ TEST_CASE("IsCheckmate", "[chessarbiter/IsCheckmate]") { CHECK(a.GetFEN() == "r3qbr1/p1p1pkp1/1p2p1p1/8/8/8/PPPPP1PP/RNBQ1RK1 b - - 1 1"); } + +TEST_CASE("IsDrawByFiftyMoveRule", "[chessarbiter/IsDrawByFiftyMoveRule]") { + ChessArbiter a; + a.Setup("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"); + CHECK_FALSE(a.IsDrawByFiftyMoveRule()); + + a.Setup("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 99 1"); + CHECK_FALSE(a.IsDrawByFiftyMoveRule()); + a.Play("b1c3"); + CHECK(a.IsDrawByFiftyMoveRule()); + + a.Setup("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 100 1"); + CHECK(a.IsDrawByFiftyMoveRule()); +} + +TEST_CASE("IsDrawByNoMoves", "[chessarbiter/IsDrawByNoMoves]") { + ChessArbiter a; + + // No move for black + a.Setup("8/8/8/8/8/8/5K1p/7k b - - 0 1"); + CHECK(a.IsDrawByNoMoves()); + + // But move for white + a.Setup("8/8/8/8/8/8/5K1p/7k w - - 0 1"); + CHECK_FALSE(a.IsDrawByNoMoves()); + + // No move for white + a.Setup("8/8/7r/2K5/b7/2k5/6q1/8 w - - 0 1"); + CHECK(a.IsDrawByNoMoves()); + + // But move for black + a.Setup("8/8/7r/2K5/b7/2k5/6q1/8 b - - 0 1"); + CHECK_FALSE(a.IsDrawByNoMoves()); +} + +TEST_CASE("IsDrawByRepetitions", "[chessarbiter/IsDrawByRepetitions]") { + ChessArbiter a; + // One time + a.Setup("8/3kp3/8/8/4P3/3K4/8/8 w - - 0 1"); + + a.Play("d3d4"); + a.Play("d7d6"); + CHECK_FALSE(a.IsDrawByRepetitions()); + + // Two time + a.Play("d4d3"); + a.Play("d6d7"); + CHECK_FALSE(a.IsDrawByRepetitions()); + + a.Play("d3d4"); + a.Play("d7d6"); + CHECK_FALSE(a.IsDrawByRepetitions()); + + // Three time + a.Play("d4d3"); + a.Play("d6d7"); + CHECK(a.IsDrawByRepetitions()); +} |
