-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommons_test.go
40 lines (36 loc) · 1005 Bytes
/
commons_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
package conval
import (
"testing"
"github.com/ftl/hamradio/callsign"
"github.com/stretchr/testify/assert"
)
func TestValidateNoMember(t *testing.T) {
validator := commonPropertyValidators[NoMemberProperty]
assert.NoError(t, validator.ValidateProperty("nm", nil), "nm")
assert.NoError(t, validator.ValidateProperty("NM", nil), "NM")
assert.Error(t, validator.ValidateProperty("", nil), "empty")
assert.Error(t, validator.ValidateProperty(" ", nil), "whitespace")
assert.Error(t, validator.ValidateProperty("12345", nil), "number")
}
func TestWPXPrefix(t *testing.T) {
tt := []struct {
call string
expected string
}{
{"DL1ABC", "DL1"},
{"9A1A", "9A1"},
{"LY1000A", "LY1000"},
{"DL/9A1A", "DL0"},
{"N8BJQ/KH9", "KH9"},
{"N8BJQ/9", "N8"},
{"DL1ABC/P", "DL1"},
{"ON2ABC", "ON2"},
{"OT0ABC", "OT0"},
}
for _, tc := range tt {
t.Run(tc.call, func(t *testing.T) {
actual := WPXPrefix(callsign.MustParse(tc.call))
assert.Equal(t, tc.expected, actual)
})
}
}