forked from go-spatial/geom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
line_stringzms_test.go
61 lines (57 loc) · 1.56 KB
/
line_stringzms_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
package geom_test
import (
"reflect"
"strconv"
"testing"
"github.com/go-spatial/geom"
)
func TestLineStringZMSSetter(t *testing.T) {
type tcase struct {
srid uint32
linestringzm geom.LineStringZM
setter geom.LineStringZMSSetter
expected geom.LineStringZMSSetter
err error
}
fn := func(t *testing.T, tc tcase) {
err := tc.setter.SetSRID(tc.srid, tc.linestringzm)
if tc.err == nil && err != nil {
t.Errorf("error, expected nil got %v", err)
return
}
if tc.err != nil {
if tc.err.Error() != err.Error() {
t.Errorf("error, expected %v got %v", tc.err, err)
}
return
}
// compare the results
if !reflect.DeepEqual(tc.expected, tc.setter) {
t.Errorf("setter, expected %v got %v", tc.expected, tc.setter)
}
lszms := tc.setter.Vertices()
tc_lszms := struct {
Srid uint32
Lszm geom.LineStringZM
}{tc.srid, tc.linestringzm}
if !reflect.DeepEqual(tc_lszms, lszms) {
t.Errorf("Referenced LineString, expected %v got %v", tc_lszms, lszms)
}
}
tests := []tcase{
{
srid: 4326,
linestringzm: geom.LineStringZM{{10, 20, 50, 0.5}, {30, 40, 90, 0.9}},
setter: &geom.LineStringZMS{Srid: 4326, Lszm: geom.LineStringZM{{15, 20, 50, 0.5}, {35, 40, 90, 0.9}}},
expected: &geom.LineStringZMS{Srid: 4326, Lszm: geom.LineStringZM{{10, 20, 50, 0.5}, {30, 40, 90, 0.9}}},
},
{
setter: (*geom.LineStringZMS)(nil),
err: geom.ErrNilLineStringZMS,
},
}
for i, tc := range tests {
tc := tc
t.Run(strconv.FormatInt(int64(i), 10), func(t *testing.T) { fn(t, tc) })
}
}