aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2022-01-27 10:34:05 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2022-01-27 10:34:05 +0100
commit2ec4942cc0928d80b7313a4a8844e11708bfc7ac (patch)
tree187f09b49140ea91a0cf95070f92f4826c0a358b /tests
parent57c3437e6330df04eab2e076d9bbebfd10ea3f3e (diff)
Improve tests
Diffstat (limited to 'tests')
-rw-r--r--tests/pgn_files/valid/pgn3.pgn40
-rw-r--r--tests/valid.cpp95
2 files changed, 133 insertions, 2 deletions
diff --git a/tests/pgn_files/valid/pgn3.pgn b/tests/pgn_files/valid/pgn3.pgn
new file mode 100644
index 0000000..3eb8255
--- /dev/null
+++ b/tests/pgn_files/valid/pgn3.pgn
@@ -0,0 +1,40 @@
+[Event "Hastings"]
+[Site "?"]
+[Date "1999.01.??"]
+[Round "8"]
+[White "Plaskett, James"]
+[Black "Shipov, Sergei"]
+[Result "1-0"]
+[ECO "B23"]
+[Annotator "Hartwig,Th"]
+[PlyCount "53"]
+
+{This week I have to apologise for not providing the sort of in-depth annotations you may be used to on this site. My excuse is that I'm very busy playing chess at the U.S. Open! However, hopefully I have made up for it by choosing an excellent game, so it will still be worth your time to take a look. }
+1. e4 c5 ; blkejglkjg
+2. Nc3 $1
+{Certainly an annoying move order against Najdorf junkies.}
+2... d6 3. f4 Nc6 4. Nf3 g6 5. Bb5 $5
+(5. Bc4 $14)
+5... Bd7 6. O-O Bg7 7. d3 a6 8. Bxc6 Bxc6 9. Kh1 Qd7 10. Qe2 f5 $2
+ {10... Nh6 was probably better. Far from stopping white's kingside play, this weakens e6, forming the basis for some nice knight maneuvers in the next few moves.}
+11. Nd5 Rd8 12. Ng5 $1
+{The knights are homing in on the weak e6 and b6 squares.}
+12... Nf6
+(12... h6 $4 13. Ne6 Rb8 14. exf5 $1 Bxd5 15. Qg4 Bxe6 16. fxe6 Qa4 17. Qxg6+ $18)
+13. Nb6 ;fklzaflkj
+$1
+ (13. Ne6 Bxd5 14. exd5 Nxd5 15. Nxg7+ Kf7 $13)
+13... Qc7 14. Nc4 fxe4 15. Ne6 Qc8 16. f5 $1 Rg8
+(16... gxf5 $2 17. Nxg7+ Kf7 18. Nxf5 $18)
+17. Nb6 $1 exd3 18. cxd3 Qb8 19. fxg6 Bh8
+(19... hxg6 20. Nxg7+ Rxg7 21. Rxf6 $18)
+20. g7 $1 Bxg7 21. Bg5 Bh8
+(21... Qa7 22. Qh5+ $18)
+22. Rae1 Rd7 23. Rxf6 $1
+(23. Bxf6 $4 {Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. } Rxg2 $13)
+23... exf6
+(23... Bxf6 24. Qh5+ Rg6 25. Qxh7 $18)
+24. Nxc5+ Kd8 25. Ncxd7 Bxd7 26. Qe7+ Kc7 27. Nd5+
+{A very nice game. Black was made to look like a complete beginner.}
+(27. Nd5+ Kc8 (27... Kc6 28. Rc1+ $18) 28. Rc1+ Bc6 29. Nb6#)
+1-0
diff --git a/tests/valid.cpp b/tests/valid.cpp
index 517f7eb..24e546d 100644
--- a/tests/valid.cpp
+++ b/tests/valid.cpp
@@ -61,7 +61,7 @@ TEST_CASE("Valid PGN", "[valid/pgn1]") {
CHECK(m_backup->GetHalfMoveAt(4)->move == "c4");
CHECK(pgn.GetResult() == "*");
- REQUIRE_THROWS_AS(pgn.ParseNextGame(),NoGameFound);
+ REQUIRE_THROWS_AS(pgn.ParseNextGame(), NoGameFound);
}
TEST_CASE("Valid PGN", "[valid/pgn2]") {
@@ -85,5 +85,96 @@ TEST_CASE("Valid PGN", "[valid/pgn2]") {
CHECK(var->move == "dxc4");
CHECK(var->GetHalfMoveAt(1)->move == "O-O");
}
- REQUIRE_THROWS_AS(pgn.ParseNextGame(),NoGameFound);
+ REQUIRE_THROWS_AS(pgn.ParseNextGame(), NoGameFound);
+}
+
+TEST_CASE("Valid PGN", "[valid/pgn3]") {
+ PGN pgn;
+ REQUIRE_NOTHROW(pgn.FromFile("pgn_files/valid/pgn3.pgn"));
+ REQUIRE_NOTHROW(pgn.ParseNextGame());
+ REQUIRE_NOTHROW(pgn.STRCheck());
+
+ REQUIRE(pgn.HasTag("Event"));
+ REQUIRE(pgn.HasTag("Site"));
+ REQUIRE(pgn.HasTag("Date"));
+ REQUIRE(pgn.HasTag("Round"));
+ REQUIRE(pgn.HasTag("White"));
+ REQUIRE(pgn.HasTag("Black"));
+ REQUIRE(pgn.HasTag("Result"));
+ REQUIRE(pgn.HasTag("ECO"));
+ REQUIRE(pgn.HasTag("Annotator"));
+ REQUIRE(pgn.HasTag("PlyCount"));
+
+ REQUIRE(pgn.GetTagValue("Event") == "Hastings");
+ REQUIRE(pgn.GetTagValue("Site") == "?");
+ REQUIRE(pgn.GetTagValue("Date") == "1999.01.??");
+ REQUIRE(pgn.GetTagValue("Round") == "8");
+ REQUIRE(pgn.GetTagValue("White") == "Plaskett, James");
+ REQUIRE(pgn.GetTagValue("Black") == "Shipov, Sergei");
+ REQUIRE(pgn.GetTagValue("Result") == "1-0");
+ REQUIRE(pgn.GetTagValue("ECO") == "B23");
+ REQUIRE(pgn.GetTagValue("Annotator") == "Hartwig,Th");
+ REQUIRE(pgn.GetTagValue("PlyCount") == "53");
+
+ REQUIRE(pgn.GetResult() == "1-0");
+
+ HalfMove *m = new HalfMove();
+ pgn.GetMoves(m);
+
+ REQUIRE(m->GetLength() == 53);
+
+ SECTION("Comments") {
+ REQUIRE(m->comment ==
+ "This week I have to apologise for not providing the sort of "
+ "in-depth annotations you may be used to on this site. My excuse "
+ "is that I'm very busy playing chess at the U.S. Open! However, "
+ "hopefully I have made up for it by choosing an excellent game, so "
+ "it will still be worth your time to take a look. ");
+ REQUIRE(m->GetHalfMoveAt(2)->comment ==
+ "Certainly an annoying move order against Najdorf junkies.");
+ REQUIRE(m->GetHalfMoveAt(19)->comment ==
+ "10... Nh6 was probably better. Far from stopping white's "
+ "kingside play, this weakens e6, forming the basis for some nice "
+ "knight maneuvers in the next few moves.");
+ REQUIRE(m->GetHalfMoveAt(22)->comment ==
+ "The knights are homing in on the weak e6 and b6 squares.");
+ REQUIRE(
+ m->GetHalfMoveAt(52)->comment ==
+ "A very nice game. Black was made to look like a complete beginner.");
+ REQUIRE(m->GetHalfMoveAt(44)->variations[0]->comment ==
+ "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do "
+ "eiusmod "
+ "tempor incididunt ut labore et dolore magna aliqua. ");
+ }
+
+ SECTION("NAGs") {
+ REQUIRE(m->GetHalfMoveAt(2)->NAG == "$1");
+ REQUIRE(m->GetHalfMoveAt(8)->NAG == "$5");
+ REQUIRE(m->GetHalfMoveAt(8)->variations[0]->NAG == "$14");
+ REQUIRE(m->GetHalfMoveAt(19)->NAG == "$2");
+ REQUIRE(m->GetHalfMoveAt(22)->NAG == "$1");
+ REQUIRE(m->GetHalfMoveAt(23)->variations[0]->NAG == "$4");
+ REQUIRE(m->GetHalfMoveAt(23)->variations[0]->GetHalfMoveAt(3)->NAG == "$1");
+ REQUIRE(m->GetHalfMoveAt(23)->variations[0]->GetHalfMoveAt(9)->NAG ==
+ "$18");
+ REQUIRE(m->GetHalfMoveAt(24)->NAG == "$1");
+ REQUIRE(m->GetHalfMoveAt(24)->variations[0]->GetHalfMoveAt(5)->NAG ==
+ "$13");
+ REQUIRE(m->GetHalfMoveAt(30)->NAG == "$1");
+ REQUIRE(m->GetHalfMoveAt(31)->variations[0]->NAG == "$2");
+ REQUIRE(m->GetHalfMoveAt(31)->variations[0]->GetHalfMoveAt(3)->NAG ==
+ "$18");
+ REQUIRE(m->GetHalfMoveAt(32)->NAG == "$1");
+ REQUIRE(m->GetHalfMoveAt(37)->variations[0]->GetHalfMoveAt(3)->NAG ==
+ "$18");
+ REQUIRE(m->GetHalfMoveAt(38)->NAG == "$1");
+ REQUIRE(m->GetHalfMoveAt(41)->variations[0]->GetHalfMoveAt(1)->NAG ==
+ "$18");
+ REQUIRE(m->GetHalfMoveAt(44)->NAG == "$1");
+ REQUIRE(m->GetHalfMoveAt(44)->variations[0]->NAG == "$4");
+ REQUIRE(m->GetHalfMoveAt(44)->variations[0]->MainLine->NAG == "$13");
+ REQUIRE(m->GetHalfMoveAt(45)->variations[0]->GetHalfMoveAt(3)->NAG ==
+ "$18");
+ REQUIRE(m->GetHalfMoveAt(52)->variations[0]->MainLine->variations[0]->MainLine->NAG == "$18");
+ }
}