-
-
Notifications
You must be signed in to change notification settings - Fork 38
/
multi_line_stringzms_test.go
98 lines (91 loc) · 1.98 KB
/
multi_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
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
97
98
package geom_test
import (
"reflect"
"strconv"
"testing"
"github.com/go-spatial/geom"
)
func TestMultiLineStringZMSSetter(t *testing.T) {
type tcase struct {
srid uint32
multilinestringzm geom.MultiLineStringZM
setter geom.MultiLineStringZMSSetter
expected geom.MultiLineStringZMSSetter
err error
}
fn := func(tc tcase) func(*testing.T) {
return func(t *testing.T) {
err := tc.setter.SetSRID(tc.srid, tc.multilinestringzm)
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)
}
mlszms := tc.setter.MultiLineStringZMs()
tc_mlszms := struct {
Srid uint32
Mlszm geom.MultiLineStringZM
}{tc.srid, tc.multilinestringzm}
if !reflect.DeepEqual(tc_mlszms, mlszms) {
t.Errorf("Referenced MultiLineStringZM, expected %v got %v", tc_mlszms, mlszms)
}
}
}
tests := []tcase{
{
srid: 4326,
multilinestringzm: geom.MultiLineStringZM{
{
{10, 20, 30, 5},
{30, 40, 50, 5},
},
{
{50, 60, 70, 5},
{70, 80, 90, 5},
},
},
setter: &geom.MultiLineStringZMS{
Srid: 4326,
Mlszm: geom.MultiLineStringZM{
{
{15, 20, 30, 5},
{35, 40, 50, 5},
},
{
{55, 60, 70, 5},
{75, 80, 90, 5},
},
},
},
expected: &geom.MultiLineStringZMS{
Srid: 4326,
Mlszm: geom.MultiLineStringZM{
{
{10, 20, 30, 5},
{30, 40, 50, 5},
},
{
{50, 60, 70, 5},
{70, 80, 90, 5},
},
},
},
},
{
setter: (*geom.MultiLineStringZMS)(nil),
err: geom.ErrNilMultiLineStringZMS,
},
}
for i := range tests {
t.Run(strconv.FormatInt(int64(i), 10), fn(tests[i]))
}
}