-
Notifications
You must be signed in to change notification settings - Fork 22
/
map_node_test.go
114 lines (106 loc) · 2.13 KB
/
map_node_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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package gedcom_test
import (
"testing"
"github.com/elliotchance/gedcom/v39"
"github.com/stretchr/testify/assert"
)
func TestNewMapNode(t *testing.T) {
child := gedcom.NewNameNode("")
node := gedcom.NewMapNode("foo", child)
assert.NotNil(t, node)
assert.IsType(t, node, (*gedcom.MapNode)(nil))
assert.Equal(t, gedcom.TagMap, node.Tag())
assert.Equal(t, gedcom.Nodes{child}, node.Nodes())
assert.Equal(t, "foo", node.Value())
assert.Equal(t, "", node.Pointer())
}
func TestPlaceNode_Latitude(t *testing.T) {
// ghost:ignore
var tests = []struct {
node *gedcom.MapNode
expected *gedcom.LatitudeNode
}{
{
node: nil,
expected: nil,
},
{
node: gedcom.NewMapNode(""),
expected: nil,
},
{
node: gedcom.NewMapNode(""),
expected: nil,
},
{
node: gedcom.NewMapNode("",
gedcom.NewLatitudeNode(""),
),
expected: gedcom.NewLatitudeNode(""),
},
{
node: gedcom.NewMapNode("",
gedcom.NewNameNode(""),
),
expected: nil,
},
{
node: gedcom.NewMapNode("",
gedcom.NewNameNode(""),
gedcom.NewLatitudeNode("1"),
gedcom.NewLatitudeNode("2"),
),
expected: gedcom.NewLatitudeNode("1"),
},
}
for _, test := range tests {
t.Run("", func(t *testing.T) {
assert.Equal(t, test.node.Latitude(), test.expected)
})
}
}
func TestPlaceNode_Longitude(t *testing.T) {
// ghost:ignore
var tests = []struct {
node *gedcom.MapNode
expected *gedcom.LongitudeNode
}{
{
node: nil,
expected: nil,
},
{
node: gedcom.NewMapNode(""),
expected: nil,
},
{
node: gedcom.NewMapNode(""),
expected: nil,
},
{
node: gedcom.NewMapNode("",
gedcom.NewLongitudeNode(""),
),
expected: gedcom.NewLongitudeNode(""),
},
{
node: gedcom.NewMapNode("",
gedcom.NewNameNode(""),
),
expected: nil,
},
{
node: gedcom.NewMapNode("",
gedcom.NewNameNode(""),
gedcom.NewLongitudeNode("1"),
gedcom.NewLongitudeNode("2"),
),
expected: gedcom.NewLongitudeNode("1"),
},
}
for _, test := range tests {
t.Run("", func(t *testing.T) {
assert.Equal(t, test.node.Longitude(), test.expected)
})
}
}