fix(io): update GameContextExport to Scala 3 syntax and add importGameContext tests

- Update GameContextExport trait to use Scala 3 syntax (colon-based) to match GameContextImport
- Add test coverage for FenParser.importGameContext method:
  * Valid FEN string returns Right[GameContext] with correct context data
  * Invalid FEN string returns Left[String] with error message

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-05 12:43:25 +02:00
parent f6f05ff2a1
commit 6fcb880b93
2 changed files with 16 additions and 4 deletions
@@ -2,8 +2,6 @@ package de.nowchess.io
import de.nowchess.api.game.GameContext
trait GameContextExport {
trait GameContextExport:
def exportGameContext(context: GameContext): String
}
@@ -131,3 +131,17 @@ class FenParserTest extends AnyFunSuite with Matchers:
board shouldBe empty
test("importGameContext: valid FEN string returns Right[GameContext]"):
val fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
val result = FenParser.importGameContext(fen)
result.isRight shouldBe true
result.fold(_ => fail("Expected Right"), ctx => ctx.turn shouldBe Color.White)
test("importGameContext: invalid FEN string returns Left[String] with error message"):
val invalidFen = "invalid fen string"
val result = FenParser.importGameContext(invalidFen)
result.isLeft shouldBe true
result.fold(msg => msg should include("Invalid FEN"), _ => fail("Expected Left"))