mirror of
https://github.com/MSWS/Chess.git
synced 2025-12-05 21:30:23 -08:00
1177bfa6bff780d627017f9910593fafef0ed92d
1 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
1177bfa6bf |
test: Add JSON test cases and integration tests for chess moves
``` Add comprehensive test cases for chess scenarios and validate JSON parsing in integration tests - Add `integration_test.go` to handle JSON test cases, parse data, and validate chess move generation against expected results. - Add `checkmates.json` with test cases for various checkmate scenarios, including mirrors and edge cases. - Add `famous.json` detailing positions and test sequences from historical chess games for validation. - Add `standard.json` to test and verify early-game chess positions and standard move transitions. - Add `promotions.json` with detailed cases for pawn promotions, including edge scenarios and forced moves. - Add additional JSON files (`castling.json`, `taxing.json`, `pawns.json`, `stalemates.json`) with test data for specific chess rule validations and edge cases like castling, stalemates, and en passant captures. ``` [testdata/integration_test.go] - Adds a new test file to validate JSON-defined chess scenarios against board states and expected moves. - Defines structs for handling test data, including descriptions, starting positions, and expected outcomes. - Implements a test function to read JSON files in the directory, parse them, and execute tests on the data. - Introduces helper functions to parse JSON data and iterate through test cases. - Adds logic to compare expected moves from JSON with generated moves from the chess board state. - Includes error handling for file reading, JSON unmarshalling, and position validation from the chess board. [testdata/checkmates.json] - Added a new JSON file containing test cases for checkmate scenarios. - Each test case includes a FEN description and an expected output. - Descriptions and tests cover specific checkmate types: ladder mate, smothered mate, en passant situations, and minimal-piece mates. - Added transposed positions for each checkmate scenario to validate mirrored setups. [testdata/famous.json] - Added new JSON file containing chess positions and test cases. - Included a "description" field specifying the context of the chess problems. - Each test case specifies a starting position (given by a FEN string) and a list of moves along with their corresponding resulting positions (also as FEN strings). - Added detailed test cases for two famous chess games: "The Game of the Century" and "The Gold Coins Game". - For "The Game of the Century", provided multiple legal move sequences and their outcomes from a specific mid-game position. - For "The Gold Coins Game", included potential moves and their resulting positions leading to the iconic "Gold Coin move". - Enriched some moves with descriptive comments for historical or tactical significance. - Added various chess scenarios to thoroughly test a move generator's capability to handle diverse situations. [testdata/standard.json] - Added a new JSON file containing test cases for specific chess board positions. - The JSON includes: - Definitions of starting positions using FEN strings. - Descriptions of the starting positions, such as "Standard starting position" and "Ruy Lopez opening". - Expected potential moves with resulting FEN states after each move. These moves explore various legal possibilities from the starting positions. - The file contains test cases primarily for validating early-game configurations and various move transitions in chess. [testdata/promotions.json] - Added a new file containing JSON data describing chess test cases focused on pawn promotions. - Included multiple scenarios covering basic promotion, transposed positions, and edge cases such as forced promotion to escape check or mate. - Detailed expected moves and resulting board configurations in FEN format for each scenario. - Descriptions accompanied each test case to clarify the situations being tested, like promoting via capture, forced promotions, or specific checks on the king. - Covered scenarios where multiple promotion options exist, including promotions resulting in check or checkmate. [testdata/castling.json] - Added a new JSON file for castling test cases. - Created test cases for all possible castling scenarios, including: - Normal castling for both sides. - Castling when prohibited due to an attacking piece (rook, bishop, knight, queen, king, and pawn). - Castling into or through check. - Castling when the king or rooks have moved. - Implemented edge cases, including en passant and pawn-promotion interference with castling rights. - Included transposed positions to test symmetry and equivalence in board states. - Supported scenarios where attacks on rooks do not affect castling ability. - Verified that castling remains allowed despite irrelevant pawn attacks or unoccupied intermediate squares. [testdata/taxing.json] - Added a large JSON file containing test cases and expected results for chess positions. - Introduced different scenarios to analyze edge cases: - Positions with pieces in maximal quantity for a specific type (e.g., maximum knights, maximum queens, maximum bishops). - Transposed positions to verify symmetric behavior. - Special rules scenarios like prohibited en passant captures due to check. - Organized data with a `description` for each scenario, `start` positions in FEN format, and corresponding `expected` moves with their resulting positions. - Ensured diverse test coverage, including: - Positions designed to stress test move generation. - Positions covering intricate rules interactions like pawn structure scenarios (en passant). - Positions with multiple complexity levels (low-mobility vs high-mobility positions). [testdata/pawns.json] - Added a new JSON file defining test cases involving pawn positions in chess. - The test cases cover various scenarios with en passant possibilities, moves without en passant, and full pawn setups. - Each test scenario details the starting board position (FEN), a description, and expected moves along with the resulting FEN after each move. - Includes mirrored or transposed versions of positions to test symmetry and edge cases. - Scenarios test both legal and illegal moves, focusing on edge cases like restricted en passant and pawn movement logic. - Ensures test coverage for complex pawn interactions, including rows with dense pawn positions and potential captures. - Scenarios also evaluate king movements in relation to pawns. - Emphasizes positions where rule-specific mechanics, like en passant, are critical to validate correctness. [testdata/stalemates.json] - Added a new JSON test data file for stalemate cases in chess. - Included multiple test cases with starting positions (FEN notation) and expected results. - Each test case represents a specific stalemate scenario or its transpose (mirrored version). - Some descriptions provide details about positions, such as the shortest stalemate possible. - Empty arrays are used for expected outputs, implying no further data is expected from these stalemate setups. |