-
-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start rewriting specs2 tests into munit
- Loading branch information
Showing
2 changed files
with
43 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
package chess | ||
|
||
class HistoryTest extends ChessSpecs: | ||
class ThreefoldRepetitionTest extends ChessTest: | ||
|
||
"threefold repetition" should: | ||
def toHash(a: Int) = PositionHash(Array(a.toByte, 0.toByte, 0.toByte)) | ||
def makeHistory(positions: List[Int]) = | ||
(positions map toHash).foldLeft(defaultHistory()) { (history, hash) => | ||
history.copy(positionHashes = hash.combine(history.positionHashes)) | ||
} | ||
"empty history" in: | ||
defaultHistory().threefoldRepetition must_== false | ||
"not 3 same elements" in: | ||
val history = makeHistory(List(1, 2, 3, 4, 5, 2, 5, 6, 23, 55)) | ||
history.threefoldRepetition must_== false | ||
"not 3 elements same to the last one" in: | ||
val history = makeHistory(List(1, 2, 3, 4, 5, 2, 5, 6, 23, 2, 55)) | ||
history.threefoldRepetition must_== false | ||
"positive" in: | ||
val history = makeHistory(List(1, 2, 3, 4, 5, 2, 5, 6, 23, 2)) | ||
history.threefoldRepetition must_== true | ||
def toHash(a: Int) = PositionHash(Array(a.toByte, 0.toByte, 0.toByte)) | ||
def makeHistory(positions: List[Int]) = | ||
(positions map toHash).foldLeft(defaultHistory()): (history, hash) => | ||
history.copy(positionHashes = hash.combine(history.positionHashes)) | ||
|
||
"set half move clock" should: | ||
"set 0" in: | ||
defaultHistory().setHalfMoveClock(HalfMoveClock.initial).halfMoveClock must_== HalfMoveClock(0) | ||
"set 5" in: | ||
defaultHistory().setHalfMoveClock(HalfMoveClock(5)).halfMoveClock must_== HalfMoveClock(5) | ||
test("empty history"): | ||
assert(!defaultHistory().threefoldRepetition) | ||
test("not 3 same elements"): | ||
val history = makeHistory(List(1, 2, 3, 4, 5, 2, 5, 6, 23, 55)) | ||
assert(!history.threefoldRepetition) | ||
test("not 3 elements same to the last one"): | ||
val history = makeHistory(List(1, 2, 3, 4, 5, 2, 5, 6, 23, 2, 55)) | ||
assert(!history.threefoldRepetition) | ||
test("positive"): | ||
val history = makeHistory(List(1, 2, 3, 4, 5, 2, 5, 6, 23, 2)) | ||
assert(!history.threefoldRepetition) | ||
|
||
class HalfMoveClockTest extends ChessTest: | ||
|
||
test("set 0"): | ||
assertEquals(defaultHistory().setHalfMoveClock(HalfMoveClock.initial).halfMoveClock, HalfMoveClock(0)) | ||
test("set 5"): | ||
assertEquals(defaultHistory().setHalfMoveClock(HalfMoveClock(5)).halfMoveClock, HalfMoveClock(5)) |