From a1f2467a87f5ce6b0841b2f0d9dc80a26b689147 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Wed, 26 Jan 2022 15:02:15 +0100 Subject: Debug and new tests: - Fix HalfMove memory leak - Fix integer overflow - Update combined tests --- tests/combined.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tests/combined.cpp') diff --git a/tests/combined.cpp b/tests/combined.cpp index 4f1db7d..b9d18d4 100644 --- a/tests/combined.cpp +++ b/tests/combined.cpp @@ -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"); + } } \ No newline at end of file -- cgit v1.2.3