--- a/test/test-real-pgn.c Mon Aug 17 12:22:08 2026 +0200 +++ b/test/test-real-pgn.c Fri Aug 21 16:08:50 2026 +0200 @@ -65,6 +65,7 @@ ++index; GameState gamestate; gamestate_init(&gamestate); + char *chkpgn = NULL; CX_TEST_DO { const enum expected_result rs = pgn_data[index-1][0]; const char *pgn = pgn_data[index-1]+1; @@ -74,7 +75,26 @@ index, result, pgn_error_position()); CX_TEST_ASSERTM(result == pgn_no_error, msg); CX_TEST_CALL_SUBROUTINE(verify_expected_result, &gamestate, rs); + + /* check if we get the PGN text back */ + chkpgn = create_pgn(&gamestate, false); + /* find move blocks (ignore the STR) */ + char *chkpgn_moves = strstr(chkpgn, "1. "); + const char *pgn_moves = strstr(pgn, "1. "); + /* revert the formatting (test data is also unformatted) */ + for (size_t i = 0; ; i++) { + if (chkpgn_moves[i] == '\n') chkpgn_moves[i] = ' '; + if (chkpgn_moves[i] == '\0') { + /* do not replace last line break */ + chkpgn_moves[i-1] = '\n'; + break; + } + } + + /* compare */ + CX_TEST_ASSERTM(strcmp(chkpgn_moves, pgn_moves) == 0, "PGN move text mismatch"); } + free(chkpgn); gamestate_cleanup(&gamestate); }