refactor: NCS-22 NCS-23 reworked modules and tests #17
@@ -91,18 +91,21 @@ class FenParserTest extends AnyFunSuite with Matchers:
|
||||
val context = FenParser.parseFen(fen)
|
||||
|
||||
context.isLeft shouldBe true
|
||||
context.fold(msg => msg should include("expected 6"), _ => fail("Expected Left"))
|
||||
|
||||
test("parse full FEN - invalid color"):
|
||||
val fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR x KQkq - 0 1"
|
||||
val context = FenParser.parseFen(fen)
|
||||
|
||||
context.isLeft shouldBe true
|
||||
context.fold(msg => msg should include("color"), _ => fail("Expected Left"))
|
||||
|
||||
test("parse full FEN - invalid castling"):
|
||||
val fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w XYZ - 0 1"
|
||||
val context = FenParser.parseFen(fen)
|
||||
|
||||
context.isLeft shouldBe true
|
||||
context.fold(msg => msg should include("castling"), _ => fail("Expected Left"))
|
||||
|
||||
test("parseFen: castling '-' produces no castling rights"):
|
||||
val fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w - - 0 1"
|
||||
@@ -151,3 +154,24 @@ class FenParserTest extends AnyFunSuite with Matchers:
|
||||
result.isLeft shouldBe true
|
||||
result.fold(msg => msg should include("Invalid FEN"), _ => fail("Expected Left"))
|
||||
|
||||
test("parse full FEN - invalid en passant"):
|
||||
val fen = "rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq x5 0 1"
|
||||
val context = FenParser.parseFen(fen)
|
||||
|
||||
context.isLeft shouldBe true
|
||||
context.fold(msg => msg should include("en passant"), _ => fail("Expected Left"))
|
||||
|
||||
test("parse full FEN - invalid half-move clock"):
|
||||
val fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - abc 1"
|
||||
val context = FenParser.parseFen(fen)
|
||||
|
||||
context.isLeft shouldBe true
|
||||
context.fold(msg => msg should include("half-move clock"), _ => fail("Expected Left"))
|
||||
|
||||
test("parse full FEN - invalid full-move number"):
|
||||
val fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 abc"
|
||||
val context = FenParser.parseFen(fen)
|
||||
|
||||
context.isLeft shouldBe true
|
||||
context.fold(msg => msg should include("full move number"), _ => fail("Expected Left"))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user