mirror of
https://gitlab.com/manzerbredes/chess-move-interface.git
synced 2025-05-01 17:27:46 +00:00
Add GotoNextGame() function to skip an entire game
This commit is contained in:
parent
bebbc79824
commit
ef75681956
4 changed files with 78 additions and 2 deletions
|
@ -89,4 +89,32 @@ TEST_CASE("Kramnik PGN", "[combined/kramnik]") {
|
|||
pgn.GetMoves(m);
|
||||
CHECK(m->comment == "E32: Nimzo-Indian: Classical (4 Qc2): 4...0-0");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Goto Next Game Tests", "[combined/hartwig/GotoNextGame]") {
|
||||
// PGN source: https://www.angelfire.com/games3/smartbridge/
|
||||
|
||||
pgnp::PGN pgn;
|
||||
pgn.FromFile("pgn_files/combined/hartwig.pgn");
|
||||
// First goto game 3
|
||||
pgn.GotoNextGame();
|
||||
pgn.GotoNextGame();
|
||||
// Parse game 3
|
||||
pgn.ParseNextGame();
|
||||
CHECK(pgn.GetTagValue("Event") == "Clichy");
|
||||
// Goto game 5
|
||||
pgn.GotoNextGame();
|
||||
// Parse game 5
|
||||
pgn.ParseNextGame();
|
||||
CHECK(pgn.GetTagValue("Event") == "World Open U2200");
|
||||
CHECK(pgn.GetTagValue("Site") == "Philadelphia");
|
||||
CHECK(pgn.GetTagValue("Black") == "Thomas, Rodney");
|
||||
// Goto game 8
|
||||
pgn.GotoNextGame(); // Goto game 7
|
||||
pgn.GotoNextGame(); // Goto game 8
|
||||
// Parse game 8
|
||||
pgn.ParseNextGame();
|
||||
CHECK(pgn.GetTagValue("Event") == "Hastings");
|
||||
CHECK(pgn.GetTagValue("White") == "Plaskett, James");
|
||||
CHECK(pgn.GetTagValue("Black") == "Shipov, Sergei");
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ TEST_CASE("Valid PGN", "[valid/pgn1]") {
|
|||
PGN pgn;
|
||||
REQUIRE_NOTHROW(pgn.FromFile("pgn_files/valid/pgn1.pgn"));
|
||||
REQUIRE_NOTHROW(pgn.ParseNextGame());
|
||||
REQUIRE_THROWS(pgn.STRCheck());
|
||||
REQUIRE_THROWS_AS(pgn.STRCheck(),pgnp::STRCheckFailed);
|
||||
|
||||
HalfMove *m = new HalfMove();
|
||||
pgn.GetMoves(m);
|
||||
|
@ -178,3 +178,9 @@ TEST_CASE("Valid PGN", "[valid/pgn3]") {
|
|||
REQUIRE(m->GetHalfMoveAt(52)->variations[0]->MainLine->variations[0]->MainLine->NAG == "$18");
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Goto Next Game Tests", "[valid/pgn3/GotoNextGame]") {
|
||||
PGN pgn;
|
||||
REQUIRE_NOTHROW(pgn.FromFile("pgn_files/valid/pgn3.pgn"));
|
||||
REQUIRE_THROWS_AS(pgn.GotoNextGame(),pgnp::NoGameFound);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue