refactor: NCS-22 NCS-23 reworked modules and tests #17

Merged
Janis merged 42 commits from refactor/NCS-22 into main 2026-04-06 09:07:40 +02:00
Showing only changes of commit f0316013fc - Show all commits
@@ -438,3 +438,33 @@ class PgnParserTest extends AnyFunSuite with Matchers:
result shouldBe None
}
test("importGameContext: valid PGN returns Right with GameContext") {
val pgn = """[Event "Test"]
[White "A"]
[Black "B"]
1. e2e4 e7e5
"""
val result = PgnParser.importGameContext(pgn)
result.isRight shouldBe true
val ctx = result.fold(err => fail(s"Got error: $err"), identity)
ctx.moves.length shouldBe 2
ctx.turn shouldBe Color.White
}
test("importGameContext: invalid PGN returns Left") {
val pgn = "[Event \"T\"]\n\n1. d1d4"
val result = PgnParser.importGameContext(pgn)
result.isLeft shouldBe true
result.fold(msg => msg should include("Illegal or impossible move"), _ => fail("Expected Left"))
}
test("importGameContext: PGN with no moves returns Right with initial position") {
val pgn = "[Event \"T\"]\n[White \"A\"]\n[Black \"B\"]\n"
val result = PgnParser.importGameContext(pgn)
result.isRight shouldBe true
val ctx = result.fold(_ => fail(), identity)
ctx.moves.isEmpty shouldBe true
ctx.board shouldBe Board.initial
}