-
Notifications
You must be signed in to change notification settings - Fork 1
/
conval_test.go
65 lines (62 loc) · 1.97 KB
/
conval_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
package conval
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestParseExchange(t *testing.T) {
tt := []struct {
desc string
fields []ExchangeField
values []string
expected QSOExchange
}{
{
desc: "only rst",
fields: []ExchangeField{[]Property{RSTProperty}},
values: []string{"123"},
expected: QSOExchange{RSTProperty: "123"},
},
{
desc: "rst and member number",
fields: []ExchangeField{[]Property{RSTProperty}, []Property{MemberNumberProperty, NoMemberProperty}},
values: []string{"59", "123"},
expected: QSOExchange{RSTProperty: "59", MemberNumberProperty: "123"},
},
{
desc: "rst and no member",
fields: []ExchangeField{[]Property{RSTProperty}, []Property{MemberNumberProperty, NoMemberProperty}},
values: []string{"59", "nm"},
expected: QSOExchange{RSTProperty: "59", NoMemberProperty: "NM"},
},
{
desc: "rst and empty no member",
fields: []ExchangeField{[]Property{RSTProperty}, []Property{MemberNumberProperty, NoMemberProperty}},
values: []string{"59", ""},
expected: QSOExchange{RSTProperty: "59"},
},
{
desc: "rst and serial",
fields: []ExchangeField{[]Property{RSTProperty}, []Property{SerialNumberProperty}},
values: []string{"59", "123"},
expected: QSOExchange{RSTProperty: "59", SerialNumberProperty: "123"},
},
{
desc: "rst and empty serial",
fields: []ExchangeField{[]Property{RSTProperty}, []Property{SerialNumberProperty}},
values: []string{"59", ""},
expected: QSOExchange{RSTProperty: "59"},
},
{
desc: "rst and no serial",
fields: []ExchangeField{[]Property{RSTProperty}, []Property{SerialNumberProperty}},
values: []string{"59"},
expected: QSOExchange{RSTProperty: "59"},
},
}
for _, tc := range tt {
t.Run(tc.desc, func(t *testing.T) {
actual := ParseExchange(tc.fields, tc.values, nil, PropertyValidatorsFunc(CommonPropertyValidator))
assert.Equal(t, tc.expected, actual)
})
}
}