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:
@@ -2,8 +2,6 @@ package de.nowchess.io
|
|||||||
|
|
||||||
import de.nowchess.api.game.GameContext
|
import de.nowchess.api.game.GameContext
|
||||||
|
|
||||||
trait GameContextExport {
|
trait GameContextExport:
|
||||||
|
|
||||||
def exportGameContext(context: GameContext): String
|
def exportGameContext(context: GameContext): String
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -131,3 +131,17 @@ class FenParserTest extends AnyFunSuite with Matchers:
|
|||||||
|
|
||||||
board shouldBe empty
|
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"))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user