-
Notifications
You must be signed in to change notification settings - Fork 18
/
fen_test.go
56 lines (49 loc) · 1.78 KB
/
fen_test.go
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
package pgn
import (
. "gopkg.in/check.v1"
)
type FENSuite struct{}
var _ = Suite(&FENSuite{})
func (s *FENSuite) TestParse(c *C) {
fen, err := ParseFEN("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1")
if err != nil {
c.Fatal(err)
}
c.Assert(fen.FOR, Equals, "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR")
c.Assert(fen.ToMove, Equals, White)
c.Assert(fen.WhiteCastleStatus, Equals, Both)
c.Assert(fen.BlackCastleStatus, Equals, Both)
c.Assert(fen.EnPassantVulnerable, Equals, NoPosition)
c.Assert(fen.HalfmoveClock, Equals, 0)
c.Assert(fen.Fullmove, Equals, 1)
}
func (s *FENSuite) TestParseNoWhiteCastle(c *C) {
fen, err := ParseFEN("rn3bnr/pppPkppp/8/4pb2/3P3q/8/PPP1KPPP/RNBQ1BNR b - - 2 6")
if err != nil {
c.Fatal(err)
}
c.Assert(fen.FOR, Equals, "rn3bnr/pppPkppp/8/4pb2/3P3q/8/PPP1KPPP/RNBQ1BNR")
c.Assert(fen.ToMove, Equals, Black)
c.Assert(fen.WhiteCastleStatus, Equals, None)
c.Assert(fen.BlackCastleStatus, Equals, None)
c.Assert(fen.EnPassantVulnerable, Equals, NoPosition)
c.Assert(fen.HalfmoveClock, Equals, 2)
c.Assert(fen.Fullmove, Equals, 6)
}
func (s *FENSuite) TestParseNoBlackCastle(c *C) {
fen, err := ParseFEN("rn3bnr/pppPkppp/8/4pb2/3P3q/8/PPP2PPP/RNBQKBNR w KQ - 1 6")
if err != nil {
c.Fatal(err)
}
c.Assert(fen.FOR, Equals, "rn3bnr/pppPkppp/8/4pb2/3P3q/8/PPP2PPP/RNBQKBNR")
c.Assert(fen.ToMove, Equals, White)
c.Assert(fen.WhiteCastleStatus, Equals, Both)
c.Assert(fen.BlackCastleStatus, Equals, None)
c.Assert(fen.EnPassantVulnerable, Equals, NoPosition)
c.Assert(fen.HalfmoveClock, Equals, 1)
c.Assert(fen.Fullmove, Equals, 6)
}
func (s *FENSuite) TestParseInvalidEnPassant(c *C) {
_, err := ParseFEN("rnbqkbnr/pppp2pp/4p3/4Pp2/8/8/PPPP1PPP/RNBQKBNR w KQkq f5 0 3")
c.Assert(err, ErrorMatches, "pgn: invalid en passant target square")
}