blob: b9d18d43bf4bd95cf033c577a04dae29b049cf90 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#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!");
}
}
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");
}
}
|