-
Notifications
You must be signed in to change notification settings - Fork 0
/
orientation_test.go
96 lines (79 loc) · 2.17 KB
/
orientation_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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package blokus
import (
"reflect"
"testing"
)
func TestRotationNormalize(t *testing.T) {
var rot Rotation
rot = Rot180
if got, want := Normalize(rot), Rot180; got != want {
t.Errorf("Normalize(Rot180): got %v, want %v", got, want)
}
rot = Rot180 + 4
if got, want := Normalize(rot), Rot180; got != want {
t.Errorf("Normalize(Rot180 + 4): got %v, want %v", got, want)
}
}
func TestRotateCoord(t *testing.T) {
var c Coord
c = Coord{0, 0}
if got, want := rotateCoord(c), (Coord{0, 0}); got != want {
t.Errorf("Rotating %v, got %v, want %v", c, got, want)
}
c = Coord{1, 2}
if got, want := rotateCoord(c), (Coord{2, -1}); got != want {
t.Errorf("Rotating %v, got %v, want %v", c, got, want)
}
c = Coord{2, -1}
if got, want := rotateCoord(c), (Coord{-1, -2}); got != want {
t.Errorf("Rotating %v, got %v, want %v", c, got, want)
}
c = Coord{-1, -2}
if got, want := rotateCoord(c), (Coord{-2, 1}); got != want {
t.Errorf("Rotating %v, got %v, want %v", c, got, want)
}
c = Coord{-2, 1}
if got, want := rotateCoord(c), (Coord{1, 2}); got != want {
t.Errorf("Rotating %v, got %v, want %v", c, got, want)
}
}
func TestFlipCoord(t *testing.T) {
var c Coord
c = Coord{0, 0}
if got, want := flipCoord(c), (Coord{0, 0}); got != want {
t.Errorf("Flipping %v, got %v, want %v", c, got, want)
}
c = Coord{1, 2}
if got, want := flipCoord(c), (Coord{1, -2}); got != want {
t.Errorf("Flipping %v, got %v, want %v", c, got, want)
}
c = Coord{1, -2}
if got, want := flipCoord(c), (Coord{1, 2}); got != want {
t.Errorf("Flipping %v, got %v, want %v", c, got, want)
}
c = Coord{-1, -2}
if got, want := flipCoord(c), (Coord{-1, 2}); got != want {
t.Errorf("Flipping %v, got %v, want %v", c, got, want)
}
c = Coord{-1, 2}
if got, want := flipCoord(c), (Coord{-1, -2}); got != want {
t.Errorf("Flipping %v, got %v, want %v", c, got, want)
}
}
func TestTransformCoords(t *testing.T) {
cs := []Coord{
{0, 0},
{1, 0},
{1, 1},
{2, 1},
}
o := Orientation{Rot90, true}
if got, want := o.TransformCoords(cs), []Coord{
{0, 0},
{0, 1},
{1, 1},
{1, 2},
}; !reflect.DeepEqual(got, want) {
t.Errorf("TransformCoords(%v): got %v, want %v", o, got, want)
}
}