-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdokugen_test.go
49 lines (44 loc) · 1.13 KB
/
dokugen_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package sudoku
import (
"testing"
)
func TestDokugen(t *testing.T) {
//TODO: test that neighbors are alerted correctly about SetNumbers happening.
grid := NewGrid()
row, col, num := 3, 3, 3
target := grid.Cell(row, col)
target.MutableInGrid(grid).SetNumber(num)
for _, cell := range grid.Col(col) {
if cell == target {
continue
}
if cell.Possible(num) {
t.Log("Neighbors in the same column did not have their possibles updated.")
t.Fail()
}
}
for _, cell := range grid.Row(col) {
if cell == target {
continue
}
if cell.Possible(num) {
t.Log("Neighbors in the same row did not have their possibles updated.")
t.Fail()
}
}
for _, cell := range grid.Block(target.Block()) {
if cell == target {
continue
}
if cell.Possible(num) {
t.Log("Neighbors in the same row did not have their possibles updated.")
t.Fail()
}
}
filledGrid := withSimpleCellsFilled(grid)
if filledGrid.rank() != grid.rank() {
t.Log("We filled more than 0 cells even though there aren't any cells to obviously fill!")
t.Fail()
}
//TODO: test that fillSimpleCells does work for cases where it should be obvious.
}