Title
unit.cpp
- Author
- Lior Bragilevsky
Related
chess.h
Project
chessCAMO
- Version
- 2.1
- Date
- July 9th, 2020
This implementation file is meant to be used as a test case checker to improve efficiency in debugging. The algorithm reads in text files that outline a given board position and feeds in the moves presented in these files one-by-one until the end of each file. At the end, the algorithm compares the expected FEN string value to the one obtained by making the corresponding moves. If these FEN strings are identical then the algorithm increments the number of test cases passed, otherwise it increments the number of test cases failed. These results are summarized at the end, when all the files are read and processed, and if a "Failed Test Case" Summary is provided for each test case that failed.
Simply run mingw32-make all_unit && unit –gtest_color=yes on a Windows machine to start the test checking script.
Include Addition Tests
- A user can set-up a position in common chess sites like lichess and extract the FEN at the bottom of the board;
- The user then makes a text file and pastes this FEN at the top, making sure to remove the last 6 characters. E.g. rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1, becomes rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq;
- On the next line, the user enters the corresponding source ('src') and destination ('dest') coordinates for a given move. E.g. 52 36 (note the space) means moving from square 52 to 36;
- Rinse and repeat step 3 until the position provided in step 1 is met. Make sure to not end on a blank line to avoid unnecessary warnings from the algorithm;
- Name the file a meaningful name according to what is being tested. E.g. to check if a given piece (Queen) delivers a checkmate → queenCheckmate.txt;
- Place test case files in a folder named ./tests/ (used by the algorithm).
- Note
- There is no draw or resign functionality here since this is meant for quick testing.
- If an invalid move is made, the board is printed to allow debugging of the board state.
- Test cases 12 to 14 require user input to decide the promotion. To avoid errors please enter 'q' (or 'Q'), 'n' (or 'N'), and 'b' (or 'B'), respectively. The algorithm will promote to appropriate piece color based on player's current move, regardless of the input's case.