-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshapepuzzle_test.go
49 lines (41 loc) · 953 Bytes
/
shapepuzzle_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
// -*- tab-width: 4; -*-
package main
import (
"fmt"
"log"
"testing"
"github.com/garyjg/shapepuzzle/board"
"github.com/garyjg/shapepuzzle/shape"
)
func testShapes() []shape.Shape {
grids := [][][]int{{
{1, 1, 1}, {1, 0, 0}, {1, 0, 0}, {1, 0, 0}}, {
{1, 1, 0}, {1, 1, 1}}, {
{1, 1, 1}, {0, 1, 0}}, {
{0, 0, 1, 1}, {1, 1, 1, 0}}, {
{1, 0, 1}, {1, 1, 1}}}
shapes := []shape.Shape{}
for id, grid := range grids {
s := shape.NewShape(id+1, grid)
shapes = append(shapes, s)
}
return shapes
}
func TestSolution(t *testing.T) {
b := board.NewBoard(5, 5)
shapes := testShapes()
bc := b.Solve(shapes)
b, ok := <-bc
if !ok {
t.Errorf("No solution found!")
}
fmt.Println(b)
}
func TestPlacements(t *testing.T) {
tb := board.NewBoard(5, 5)
shapes := testShapes()
log.Printf("Empty board (mask=%v):\n%v", tb.Mask(), tb)
tb = tb.Place(shapes[0].Translate(0, 0))
tb = tb.Place(shapes[1].Translate(1, 1))
log.Println(tb)
}