Skip to content

Commit

Permalink
Add some more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
gbtami committed Jun 11, 2024
1 parent 0a7f810 commit 8540684
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -975,15 +975,30 @@ def test_is_capture(self):
self.assertFalse(result)

def test_piece_to_partner(self):
# take the rook and promote to queen
result = sf.piece_to_partner("bughouse", "r2qkbnr/1Ppppppp/2n5/8/8/8/1PPPPPPP/RNBQKBNR[] w KQkq - 0 1", ["b7a8q"])
self.assertEqual(result, "r")

# take back the queen (promoted pawn)
result = sf.piece_to_partner("bughouse", "r2qkbnr/1Ppppppp/2n5/8/8/8/1PPPPPPP/RNBQKBNR[] w KQkq - 0 1", ["b7a8q", "d8a8"])
self.assertEqual(result, "P")

# just a simple move (no take)
result = sf.piece_to_partner("bughouse", "r2qkbnr/1Ppppppp/2n5/8/8/8/1PPPPPPP/RNBQKBNR[] w KQkq - 0 1", ["b7a8q", "d8b8"])
self.assertEqual(result, "")

# take the pawn and promote to tokin
result = sf.piece_to_partner("shogi", "lnsgkgsnl/1r5b1/ppppppp1p/1P7/9/7p1/P1PPPPPPP/1B5R1/LNSGKGSNL[] w 0 1", ["b6b7+"])
self.assertEqual(result, "p")

# take back the promoted pawn
result = sf.piece_to_partner("shogi", "lnsgkgsnl/1r5b1/ppppppp1p/1P7/9/7p1/P1PPPPPPP/1B5R1/LNSGKGSNL[] w 0 1", ["b6b7+", "b8b7"])
self.assertEqual(result, "P")

# take an unpromoted pawn
result = sf.piece_to_partner("shogi", "lnsgkgsnl/1r5b1/ppppppp1p/1P7/9/7p1/P1PPPPPPP/1B5R1/LNSGKGSNL[] w 0 1", ["b6b7+", "h4h3+"])
self.assertEqual(result, "P")

def test_game_result(self):
result = sf.game_result("chess", CHESS, ["f2f3", "e7e5", "g2g4", "d8h4"])
self.assertEqual(result, -sf.VALUE_MATE)
Expand Down

0 comments on commit 8540684

Please sign in to comment.