Debug and new tests:

- Fix HalfMove memory leak
- Fix integer overflow
- Update combined tests
This commit is contained in:
Loic Guegan 2022-01-26 15:02:15 +01:00
parent f4f436870f
commit a1f2467a87
4 changed files with 1367 additions and 1 deletions

View file

@ -40,4 +40,35 @@ TEST_CASE("Hartwig PGN", "[combined/hartwig]") {
"was because things were in such a rut I would only be cheered by "
"winning in crushing style. Thankfully it worked!");
}
}
TEST_CASE("Kramnik PGN", "[combined/kramnik]") {
// PGN source: https://www.angelfire.com/games3/smartbridge/
pgnp::PGN pgn;
pgn.FromFile("pgn_files/combined/kramnik.pgn");
// Count games
REQUIRE_NOTHROW([&]() {
char i = 0;
try {
while (true) {
pgn.ParseNextGame();
i++;
}
} catch (const NoGameFound &e) {
CHECK(i == 40);
}
}());
SECTION("Check comments of a game") {
pgnp::PGN pgn;
pgn.FromFile("pgn_files/combined/kramnik.pgn");
pgn.ParseNextGame(); // Load game 1
HalfMove *m = new HalfMove();
pgn.GetMoves(m);
CHECK(m->comment ==
"E32: Nimzo-Indian: Classical (4 Qc2): 4...0-0");
}
}