-
Notifications
You must be signed in to change notification settings - Fork 40
/
main_test.go
63 lines (57 loc) · 1.22 KB
/
main_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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"fmt"
"github.com/bertoort/sugoku/board"
"github.com/bertoort/sugoku/puzzle"
"testing"
)
// Command: go test
func Test_puzzleSetUp(t *testing.T) {
input := board.Basic()
newBoard := puzzle.New(input)
b, _, _ := newBoard.Display()
if b != board.Basic() {
fmt.Println(b)
t.Error("should equal: ", board.Basic())
}
}
func Test_solve(t *testing.T) {
input := board.Basic()
newBoard := puzzle.New(input)
newBoard.Solve()
b, _, _ := newBoard.Display()
if b != board.Solved() {
fmt.Println(b)
t.Error("should equal solved board: ", board.Solved())
}
}
func Test_slowSolve(t *testing.T) {
input := board.Basic()
newBoard := puzzle.New(input)
newBoard.Solve()
b, _, _ := newBoard.Display()
if b != board.Solved() {
fmt.Println(b)
t.Error("should equal solved board: ", board.Solved())
}
}
func Test_validate(t *testing.T) {
input := board.Basic()
// import standard input
newBoard := puzzle.New(input)
newBoard.Solve()
v := newBoard.Validate()
if !v {
fmt.Println(v)
t.Error("should equal true")
}
// import unsolvable input
input = board.Broken()
newBoard.FillPuzzle(input)
newBoard.Solve()
v = newBoard.Validate()
if v {
fmt.Println(v)
t.Error("should equal false")
}
}