-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathdeath_node_test.go
60 lines (46 loc) · 1.51 KB
/
death_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
package gedcom_test
import (
"testing"
"github.com/elliotchance/gedcom/v39"
"github.com/elliotchance/tf"
"github.com/stretchr/testify/assert"
)
func TestNewDeathNode(t *testing.T) {
child := gedcom.NewNameNode("")
node := gedcom.NewDeathNode("foo", child)
assert.Equal(t, gedcom.TagDeath, node.Tag())
assert.Equal(t, gedcom.Nodes{child}, node.Nodes())
assert.Equal(t, "foo", node.Value())
assert.Equal(t, "", node.Pointer())
}
func TestDeathNode_Dates(t *testing.T) {
Dates := tf.Function(t, (*gedcom.DeathNode).Dates)
Dates((*gedcom.DeathNode)(nil)).Returns([]*gedcom.DateNode(nil))
Dates(gedcom.NewDeathNode("")).Returns([]*gedcom.DateNode(nil))
Dates(gedcom.NewDeathNode("",
gedcom.NewDateNode("3 Sep 2001"),
)).Returns([]*gedcom.DateNode{
gedcom.NewDateNode("3 Sep 2001"),
})
Dates(gedcom.NewDeathNode("",
gedcom.NewDateNode("7 Jan 2001"),
gedcom.NewDateNode("3 Sep 2001"),
)).Returns([]*gedcom.DateNode{
gedcom.NewDateNode("7 Jan 2001"),
gedcom.NewDateNode("3 Sep 2001"),
})
}
func TestDeathNode_Equals(t *testing.T) {
Equals := tf.Function(t, (*gedcom.DeathNode).Equals)
n1 := gedcom.NewDeathNode("foo")
n2 := gedcom.NewDeathNode("bar")
// nils
Equals((*gedcom.DeathNode)(nil), (*gedcom.DeathNode)(nil)).Returns(false)
Equals(n1, (*gedcom.DeathNode)(nil)).Returns(false)
Equals((*gedcom.DeathNode)(nil), n1).Returns(false)
// Wrong node type.
Equals(n1, gedcom.NewNameNode("foo")).Returns(false)
// All other cases are success.
Equals(n1, n1).Returns(true)
Equals(n1, n2).Returns(true)
}