diff --git a/game.go b/game.go index 5997142..696312b 100644 --- a/game.go +++ b/game.go @@ -378,6 +378,7 @@ func (g *Game) copy(game *Game) { g.pos = game.pos g.outcome = game.outcome g.method = game.method + g.comments = game.Comments() } func (g *Game) Clone() *Game { diff --git a/pgn_test.go b/pgn_test.go index b330ba2..913796d 100644 --- a/pgn_test.go +++ b/pgn_test.go @@ -106,6 +106,20 @@ func TestCommentsDetection(t *testing.T) { } } +func TestNewGameComments(t *testing.T) { + for _, test := range commentTests { + pgn, err := PGN(strings.NewReader(test.PGN)) + if err != nil { + t.Fatal(err) + } + game := NewGame(pgn) + comment := strings.Join(game.Comments()[test.MoveNumber], " ") + if comment != test.CommentText { + t.Fatalf("expected pgn comment to be %s but got %s", test.CommentText, comment) + } + } +} + func TestWriteComments(t *testing.T) { pgn := mustParsePGN("fixtures/pgns/0005.pgn") game, err := decodePGN(pgn)