-
Notifications
You must be signed in to change notification settings - Fork 16
/
geom_test.go
48 lines (42 loc) · 926 Bytes
/
geom_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
package geom
import (
"reflect"
"testing"
)
func TestBounds(t *testing.T) {
var testCases = []struct {
g Geom
bounds *Bounds
}{
{
Point{1, 2},
&Bounds{Point{1, 2}, Point{1, 2}},
},
{
LineString([]Point{{1, 2}, {3, 4}}),
&Bounds{Point{1, 2}, Point{3, 4}},
},
{
Polygon([]Path{{{1, 2}, {3, 4}, {5, 6}}}),
&Bounds{Point{1, 2}, Point{5, 6}},
},
{
MultiPoint([]Point{{1, 2}, {3, 4}}),
&Bounds{Point{1, 2}, Point{3, 4}},
},
{
MultiLineString([]LineString{[]Point{{1, 2}, {3, 4}}, []Point{{5, 6}, {7, 8}}}),
&Bounds{Point{1, 2}, Point{7, 8}},
},
}
for _, tc := range testCases {
if got := tc.g.Bounds(); !reflect.DeepEqual(got, tc.bounds) {
t.Errorf("%#v.Bounds() == %#v, want %#v", tc.g, got, tc.bounds)
}
}
}
func TestBoundsEmpty(t *testing.T) {
if got := NewBounds().Empty(); got != true {
t.Errorf("NewBounds.Empty() == %#v, want true", got)
}
}