From dd4f969d156bbaa546911b3951211bb2245182ad Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 18 Aug 2026 14:02:01 +0200 Subject: fix(tests): making zobrist tests use json --- scripts/tests/zobrist.bash | 7 +++++-- src/main.cpp | 10 +++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/scripts/tests/zobrist.bash b/scripts/tests/zobrist.bash index 7545f6d..bcfc437 100755 --- a/scripts/tests/zobrist.bash +++ b/scripts/tests/zobrist.bash @@ -10,13 +10,16 @@ testZobrist() { echo "" - result=$(./build/mono zobrist "$fen" $moves) + resultRaw=$(./build/mono zobrist "$fen" $moves) + result=$(echo $resultRaw | jq -r '.hash') + took=$(echo $resultRaw | jq -r '.ms') if [ "$result" = "$expected" ]; then - echo "PASS: $name" + echo "PASS: $name, Took: $took" else echo "FAIL: $name" echo " Expected: $expected" echo " Got: $result" + echo " Raw: $resultRaw" status=1 fi } diff --git a/src/main.cpp b/src/main.cpp index dd30306..c3945d3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -58,8 +58,16 @@ static void zobristCmd(int argc, char *argv[]) { MakeMove(move, &game); } + auto start = std::chrono::steady_clock::now(); + uint64_t hash = GenerateZobristKey(&game); - std::cout << hash << "\n"; + auto end = std::chrono::steady_clock::now(); + auto ms = std::chrono::duration_cast(end - start) + .count(); + std::ostringstream oss; + oss << "{\"ms\": " << ms << ", \"hash\": " << hash << "}"; + + std::cout << oss.str() << "\n"; } int main(int argc, char *argv[]) { -- cgit v1.2.3