This repository has been archived by the owner on Feb 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes_test.go
56 lines (49 loc) · 1.92 KB
/
types_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
package turfgo
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestGetPoints(t *testing.T) {
Convey("For a given point, should return points array", t, func() {
p := &Point{114.175329, 22.2524}
So(p.getPoints(), ShouldResemble, []*Point{p})
})
Convey("For a given lineString, should return points array", t, func() {
point1 := &Point{35.4691, -97.522259}
point2 := &Point{35.463455, -97.502754}
point3 := &Point{35.463245, -97.508269}
points := []*Point{point1, point2, point3}
lineString := NewLineString(points)
So(lineString.getPoints(), ShouldResemble, points)
})
Convey("For a given multilineString, should return points array", t, func() {
point1 := &Point{35.4691, -97.522259}
point2 := &Point{35.463455, -97.502754}
point3 := &Point{35.463245, -97.508269}
point4 := &Point{22.7, -72.5}
points1 := []*Point{point1, point2}
points2 := []*Point{point3, point4}
lineString1 := NewLineString(points1)
lineString2 := NewLineString(points2)
multiLineString := NewMultiLineString([]*LineString{lineString1, lineString2})
So(multiLineString.getPoints(), ShouldResemble, append(points1, points2...))
})
Convey("For a given polygon, should return points array", t, func() {
point1 := &Point{35.4691, -97.522259}
point2 := &Point{35.463455, -97.502754}
point3 := &Point{35.463245, -97.508269}
point4 := &Point{22.7, -72.5}
points1 := []*Point{point1, point2}
points2 := []*Point{point3, point4}
points3 := []*Point{point1, point3, point4}
lineString1 := NewLineString(points1)
lineString2 := NewLineString(points2)
lineString3 := NewLineString(points3)
polygon1 := NewPolygon([]*LineString{lineString1, lineString2})
polygon2 := NewPolygon([]*LineString{lineString3})
multiPolygon := NewMultiPolygon([]*Polygon{polygon1, polygon2})
result := append(points1, points2...)
result = append(result, points3...)
So(multiPolygon.getPoints(), ShouldResemble, result)
})
}