-
Notifications
You must be signed in to change notification settings - Fork 10
/
cmp_test.go
84 lines (64 loc) · 1.58 KB
/
cmp_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
package gedcom
import "github.com/google/go-cmp/cmp"
// familyXrefComparer is a Comparer that compares FamilyLinkRecords only by Family xref
var familyXrefComparer = cmp.Comparer(func(a, b *FamilyLinkRecord) bool {
if a == nil {
return b == nil
}
if b == nil {
return a == nil
}
if a.Family == nil {
return b.Family == nil
}
if b.Family == nil {
return a.Family == nil
}
return a.Family.Xref == b.Family.Xref
})
// individualXrefComparer is a Comparer that compares IndividualRecords only by xref
var individualXrefComparer = cmp.Comparer(func(a, b *IndividualRecord) bool {
if a == nil {
return b == nil
}
if b == nil {
return a == nil
}
return a.Xref == b.Xref
})
// sourceXrefComparer is a Comparer that compares CitationRecords only by source xref
var sourceXrefComparer = cmp.Comparer(func(a, b *CitationRecord) bool {
if a == nil {
return b == nil
}
if b == nil {
return a == nil
}
if a.Source == nil {
return b.Source == nil
}
if b.Source == nil {
return a.Source == nil
}
return a.Source.Xref == b.Source.Xref
})
// eventIgnoreComparer is a Comparer that ignores event comparisons
var eventIgnoreComparer = cmp.Comparer(func(a, b []*EventRecord) bool {
return true
})
// mediaFileNameCompare is a Comparer that compares MediaRecord only by first file name
var mediaFileNameCompare = cmp.Comparer(func(a, b *MediaRecord) bool {
if a == nil {
return b == nil
}
if b == nil {
return a == nil
}
if len(a.File) == 0 {
return len(b.File) == 0
}
if len(b.File) == 0 {
return len(a.File) == 0
}
return a.File[0].Name == b.File[0].Name
})