aboutsummaryrefslogtreecommitdiff
path: root/tests/combined.cpp
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2022-01-26 14:41:38 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2022-01-26 14:41:38 +0100
commitf4f436870f9ce0368d81c504e93b012e3928a851 (patch)
tree61ea2ac873997600ca0aeb29669e9fef6f65bfe0 /tests/combined.cpp
parentbb914f047b0d96464f3e55234907df4e7c416e97 (diff)
- Debug parser (carriage returns)
- Improve test framework
Diffstat (limited to 'tests/combined.cpp')
-rw-r--r--tests/combined.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/combined.cpp b/tests/combined.cpp
new file mode 100644
index 0000000..4f1db7d
--- /dev/null
+++ b/tests/combined.cpp
@@ -0,0 +1,43 @@
+#include "pgnp.hpp"
+#include <catch_amalgamated.hpp>
+
+using namespace pgnp;
+
+TEST_CASE("Hartwig PGN", "[combined/hartwig]") {
+ // PGN source: https://www.angelfire.com/games3/smartbridge/
+
+ pgnp::PGN pgn;
+ pgn.FromFile("pgn_files/combined/hartwig.pgn");
+
+ // Count games
+ REQUIRE_NOTHROW([&]() {
+ char i = 0;
+ try {
+ while (true) {
+ pgn.ParseNextGame();
+ i++;
+ }
+ } catch (const NoGameFound &e) {
+ CHECK(i == 29);
+ }
+ }());
+
+ SECTION("Check comments of a game") {
+ pgnp::PGN pgn;
+ pgn.FromFile("pgn_files/combined/hartwig.pgn");
+ pgn.ParseNextGame();
+ pgn.ParseNextGame();
+ pgn.ParseNextGame();
+ pgn.ParseNextGame();
+ pgn.ParseNextGame(); // Load game 5
+
+ HalfMove *m = new HalfMove();
+ pgn.GetMoves(m);
+ std::cout << m->comment;
+ CHECK(m->comment ==
+ "I had actually prepared 1.d4 for the tournament, but I backed out "
+ "in every (!) game for various different reasons. In this case it "
+ "was because things were in such a rut I would only be cheered by "
+ "winning in crushing style. Thankfully it worked!");
+ }
+} \ No newline at end of file