add initial tests - chess-puzzles - chess puzzle book generator | |
git clone git://git.codemadness.org/chess-puzzles | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 53bf056699cba0e1bd1b06260600385ac5ad0780 | |
parent aaac499d48085948814415956d3eb4ded33eb704 | |
Author: Hiltjo Posthuma <[email protected]> | |
Date: Wed, 20 Dec 2023 19:29:59 +0100 | |
add initial tests | |
To make it easier to test the parser and moves | |
Diffstat: | |
A tests.sh | 25 +++++++++++++++++++++++++ | |
1 file changed, 25 insertions(+), 0 deletions(-) | |
--- | |
diff --git a/tests.sh b/tests.sh | |
@@ -0,0 +1,25 @@ | |
+#!/bin/sh | |
+ | |
+# testfen(expect, fen, moves) | |
+testfen() { | |
+ expect="$1" | |
+ fen="$2" | |
+ moves="$3" | |
+ | |
+ output=$(./fen_to_fen "$fen" "$moves") | |
+ if test "$output" = "$expect"; then | |
+ echo "OK" | |
+ else | |
+ printf 'Fail: expected %s, got: %s\n' "$expect" "$output" | |
+ fi | |
+} | |
+ | |
+testfen 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1' \ | |
+ "startpos" "" | |
+# white castling | |
+testfen 'rnbqkb1r/p4ppp/1pp1pn2/3p4/3P1B2/3BPN2/PPP2PPP/RN1Q1RK1 b kq - 1 6' \ | |
+ 'rnbqkb1r/p4ppp/1pp1pn2/3p4/3P1B2/3BPN2/PPP2PPP/RN1QK2R w KQkq - 0 6' … | |
+# black castling | |
+testfen 'rnbq1rk1/p3bppp/1pp1pn2/3p4/3P1B2/3BPN2/PPPN1PPP/R2Q1RK1 w - - 4 8' \ | |
+ 'rnbqk2r/p3bppp/1pp1pn2/3p4/3P1B2/3BPN2/PPPN1PPP/R2Q1RK1 b kq - 3 7' '… | |
+ |