test(io): add exportGameContext tests

Add two simple tests for exportGameContext functionality:
1. Test that moves are preserved in PGN output
2. Test that empty game exports headers with proper terminator

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-05 13:45:25 +02:00
parent 16a9632e69
commit 8b5303fdab
@@ -1,8 +1,9 @@
package de.nowchess.io.pgn
import de.nowchess.api.board.{PieceType, *}
import de.nowchess.api.move.PromotionPiece
import de.nowchess.api.game.{GameHistory, HistoryMove}
import de.nowchess.api.move.{PromotionPiece, Move, MoveType}
import de.nowchess.api.game.{GameHistory, HistoryMove, GameContext}
import de.nowchess.io.pgn.PgnParser
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
@@ -113,3 +114,23 @@ class PgnExporterTest extends AnyFunSuite with Matchers:
val pgn = PgnExporter.exportGame(Map.empty, history)
pgn shouldBe "1. e4 *"
test("exportGameContext: moves are preserved in output") {
val moves = List(
Move(Square(File.E, Rank.R2), Square(File.E, Rank.R4), MoveType.Normal),
Move(Square(File.E, Rank.R7), Square(File.E, Rank.R5), MoveType.Normal)
)
val ctx = GameContext.initial.copy(moves = moves)
val exported = PgnExporter.exportGameContext(ctx)
exported.contains("e4") shouldBe true
exported.contains("e5") shouldBe true
}
test("exportGameContext: empty game returns headers only") {
val ctx = GameContext.initial
val exported = PgnExporter.exportGameContext(ctx)
exported.contains("[Event") shouldBe true
exported.contains("*") shouldBe true // Result terminator
}