aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/paulmach/orb/geometry_test.go
blob: 5f9ab46771b97d717234e10254b322e9a785cacf (plain) (blame)
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
package orb

import (
	"fmt"
	"testing"
)

func TestGeometryDimensions(t *testing.T) {
	cases := []struct {
		Geometry   Geometry
		Dimensions int
	}{
		{Point{}, 0},
		{MultiPoint{}, 0},
		{LineString{}, 1},
		{MultiLineString{}, 1},
		{Ring{}, 2},
		{Polygon{}, 2},
		{MultiPolygon{}, 2},
		{Bound{}, 2},
		{Collection{Point{}, LineString{}}, 1},
	}

	for _, tc := range cases {
		t.Run(fmt.Sprintf("type: %T", tc.Geometry), func(t *testing.T) {
			if v := tc.Geometry.Dimensions(); v != tc.Dimensions {
				t.Errorf("incorrect dimensions: %v", v)
			}
		})
	}
}

func TestCollectionBound(t *testing.T) {
	// from the empty Point we get the zero bound.
	expected := Bound{}

	b2 := Collection(AllGeometries).Bound()
	if !b2.Equal(expected) {
		t.Errorf("wrong bound: %v != %v", b2, expected)
	}
}