-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsource_test.go
67 lines (55 loc) · 1.17 KB
/
source_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
package main
import (
"os"
"reflect"
"testing"
)
func TestSource(t *testing.T) {
s := source{}
b, err := os.ReadFile("etc/VGT2_e.json")
if err != nil {
t.Error(err)
}
err = s.unmarshall(b)
if err != nil {
t.Errorf("unmarshalling etc/VGT2_e.json %s", err)
}
o := source{}
o.Type = "Point"
o.Coordinates = make([]float64, 2)
o.Coordinates[0] = 175.673170826
o.Coordinates[1] = -39.108617051
o.Properties.SiteID = "VGT2"
o.Properties.Height = -999.9
o.Properties.GroundRelationship = -999.9
o.Properties.Name = "Te Maari 2"
o.Properties.TypeID = "e"
o.Properties.MethodID = "bernese5"
o.Properties.SystemID = "none"
o.Properties.SampleID = "none"
if !reflect.DeepEqual(o, s) {
t.Error("source o and s are not equal")
}
if s.longitude() != 175.673170826 {
t.Error("wrong longitude")
}
if s.latitude() != -39.108617051 {
t.Error("wrong latitude")
}
}
func TestSourceValid(t *testing.T) {
setup()
defer teardown()
s := source{}
b, err := os.ReadFile("etc/VGT2_e.json")
if err != nil {
t.Error(err)
}
err = s.unmarshall(b)
if err != nil {
t.Errorf("unmarshalling etc/VGT2_e.json %s", err)
}
if err := s.valid(); err != nil {
t.Error(err)
}
}