Add tests
This commit is contained in:
@@ -48,7 +48,7 @@ class NeighbourClueTest : ClueTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `ensure grid with one neighbour not set is considered valid`() {
|
||||
fun `ensure grid with one neighbour not set is considered valid if a neighbour is in the options`() {
|
||||
val grid = createGrid()
|
||||
for (ia in 0 until size) {
|
||||
for (ib in 0 until size) {
|
||||
@@ -57,7 +57,9 @@ class NeighbourClueTest : ClueTest() {
|
||||
val b = grid[ib][j]
|
||||
|
||||
a.selection = null
|
||||
a.options.add(a.solution)
|
||||
b.selection = b.solution
|
||||
b.options.clear()
|
||||
|
||||
expect(NeighbourClue(a.solution, b.solution).isRuleViolated(grid))
|
||||
.toEqual(false)
|
||||
@@ -65,12 +67,29 @@ class NeighbourClueTest : ClueTest() {
|
||||
.toEqual(false)
|
||||
|
||||
a.selection = a.solution
|
||||
a.options.clear()
|
||||
b.selection = null
|
||||
b.options.add(b.solution)
|
||||
|
||||
expect(NeighbourClue(a.solution, b.solution).isRuleViolated(grid))
|
||||
.toEqual(false)
|
||||
expect(NeighbourClue(b.solution, a.solution).isRuleViolated(grid))
|
||||
.toEqual(false)
|
||||
|
||||
if (j < size-1) {
|
||||
val notA = grid[ia][j + 1]
|
||||
|
||||
a.selection = null
|
||||
a.options.clear()
|
||||
notA.options.add(a.solution)
|
||||
b.selection = b.solution
|
||||
b.options.clear()
|
||||
|
||||
expect(NeighbourClue(a.solution, b.solution).isRuleViolated(grid))
|
||||
.toEqual(false)
|
||||
expect(NeighbourClue(b.solution, a.solution).isRuleViolated(grid))
|
||||
.toEqual(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user