|
|
@ -1,6 +1,8 @@
|
|
|
|
package cmd
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
import (
|
|
|
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func TestValidateWwff(t *testing.T) {
|
|
|
|
func TestValidateWwff(t *testing.T) {
|
|
|
|
type args struct {
|
|
|
|
type args struct {
|
|
|
@ -13,41 +15,40 @@ func TestValidateWwff(t *testing.T) {
|
|
|
|
wantErrorMsg string
|
|
|
|
wantErrorMsg string
|
|
|
|
}{
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Good ref (simple)",
|
|
|
|
"Good ref (simple)",
|
|
|
|
args{ inputStr: "onff-0258", },
|
|
|
|
args{inputStr: "onff-0258"},
|
|
|
|
"ONFF-0258", "",
|
|
|
|
"ONFF-0258", "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Good ref (single digit country)",
|
|
|
|
"Good ref (single digit country)",
|
|
|
|
args{ inputStr: "fff-0258", },
|
|
|
|
args{inputStr: "fff-0258"},
|
|
|
|
"FFF-0258", "",
|
|
|
|
"FFF-0258", "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Good ref (Numerical country)",
|
|
|
|
"Good ref (Numerical country)",
|
|
|
|
args{ inputStr: "4xff-0258", },
|
|
|
|
args{inputStr: "4xff-0258"},
|
|
|
|
"4XFF-0258", "",
|
|
|
|
"4XFF-0258", "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Bad ref (no country prefix)",
|
|
|
|
"Bad ref (no country prefix)",
|
|
|
|
args{ inputStr: "ff-0258", },
|
|
|
|
args{inputStr: "ff-0258"},
|
|
|
|
"*FF-0258", "Invalid WWFF reference",
|
|
|
|
"*FF-0258", "Invalid WWFF reference",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Bad ref (wrong separator)",
|
|
|
|
"Bad ref (wrong separator)",
|
|
|
|
args{ inputStr: "gff/0258", },
|
|
|
|
args{inputStr: "gff/0258"},
|
|
|
|
"*GFF/0258", "Invalid WWFF reference",
|
|
|
|
"*GFF/0258", "Invalid WWFF reference",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Bad ref (reference too short)",
|
|
|
|
"Bad ref (reference too short)",
|
|
|
|
args{ inputStr: "onff-258", },
|
|
|
|
args{inputStr: "onff-258"},
|
|
|
|
"*ONFF-258", "Invalid WWFF reference",
|
|
|
|
"*ONFF-258", "Invalid WWFF reference",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Bad ref (no country prefix)",
|
|
|
|
"Bad ref (no country prefix)",
|
|
|
|
args{ inputStr: "onff-02589", },
|
|
|
|
args{inputStr: "onff-02589"},
|
|
|
|
"*ONFF-02589", "Invalid WWFF reference",
|
|
|
|
"*ONFF-02589", "Invalid WWFF reference",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
@ -73,60 +74,60 @@ func TestValidateSota(t *testing.T) {
|
|
|
|
wantErrorMsg string
|
|
|
|
wantErrorMsg string
|
|
|
|
}{
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Good ref (simple)",
|
|
|
|
"Good ref (simple)",
|
|
|
|
args{ inputStr: "on/ON-001", },
|
|
|
|
args{inputStr: "on/ON-001"},
|
|
|
|
"ON/ON-001", "",
|
|
|
|
"ON/ON-001", "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Good ref (single digit prefix)",
|
|
|
|
"Good ref (single digit prefix)",
|
|
|
|
args{ inputStr: "g/ON-001", },
|
|
|
|
args{inputStr: "g/ON-001"},
|
|
|
|
"G/ON-001", "",
|
|
|
|
"G/ON-001", "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Good ref (numerical prefix)",
|
|
|
|
"Good ref (numerical prefix)",
|
|
|
|
args{ inputStr: "4x/ON-001", },
|
|
|
|
args{inputStr: "4x/ON-001"},
|
|
|
|
"4X/ON-001", "",
|
|
|
|
"4X/ON-001", "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Good ref (american style)",
|
|
|
|
"Good ref (american style)",
|
|
|
|
args{ inputStr: "w4z/ON-001", },
|
|
|
|
args{inputStr: "w4z/ON-001"},
|
|
|
|
"W4Z/ON-001", "",
|
|
|
|
"W4Z/ON-001", "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Bad ref (long prefix)",
|
|
|
|
"Bad ref (long prefix)",
|
|
|
|
args{ inputStr: "xxxx/ON-001", },
|
|
|
|
args{inputStr: "xxxx/ON-001"},
|
|
|
|
"*XXXX/ON-001", "Invalid SOTA reference",
|
|
|
|
"*XXXX/ON-001", "Invalid SOTA reference",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Bad ref (missing slash)",
|
|
|
|
"Bad ref (missing slash)",
|
|
|
|
args{ inputStr: "on ON-001", },
|
|
|
|
args{inputStr: "on ON-001"},
|
|
|
|
"*ON ON-001", "Invalid SOTA reference",
|
|
|
|
"*ON ON-001", "Invalid SOTA reference",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Bad ref (numerical region)",
|
|
|
|
"Bad ref (numerical region)",
|
|
|
|
args{ inputStr: "on/9N-001", },
|
|
|
|
args{inputStr: "on/9N-001"},
|
|
|
|
"*ON/9N-001", "Invalid SOTA reference",
|
|
|
|
"*ON/9N-001", "Invalid SOTA reference",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Bad ref (too long region)",
|
|
|
|
"Bad ref (too long region)",
|
|
|
|
args{ inputStr: "on/ONA-001", },
|
|
|
|
args{inputStr: "on/ONA-001"},
|
|
|
|
"*ON/ONA-001", "Invalid SOTA reference",
|
|
|
|
"*ON/ONA-001", "Invalid SOTA reference",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Bad ref (no dash)",
|
|
|
|
"Bad ref (no dash)",
|
|
|
|
args{ inputStr: "on/ON/001", },
|
|
|
|
args{inputStr: "on/ON/001"},
|
|
|
|
"*ON/ON/001", "Invalid SOTA reference",
|
|
|
|
"*ON/ON/001", "Invalid SOTA reference",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Bad ref (number too short)",
|
|
|
|
"Bad ref (number too short)",
|
|
|
|
args{ inputStr: "on/ON-01", },
|
|
|
|
args{inputStr: "on/ON-01"},
|
|
|
|
"*ON/ON-01", "Invalid SOTA reference",
|
|
|
|
"*ON/ON-01", "Invalid SOTA reference",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Bad ref (Number too long)",
|
|
|
|
"Bad ref (Number too long)",
|
|
|
|
args{ inputStr: "on/ON-9001", },
|
|
|
|
args{inputStr: "on/ON-9001"},
|
|
|
|
"*ON/ON-9001", "Invalid SOTA reference",
|
|
|
|
"*ON/ON-9001", "Invalid SOTA reference",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
@ -147,69 +148,69 @@ func TestValidateCall(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
name string
|
|
|
|
args args
|
|
|
|
args args
|
|
|
|
wantCall string
|
|
|
|
wantCall string
|
|
|
|
wantErrorMsg string
|
|
|
|
wantErrorMsg string
|
|
|
|
}{
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Good call (simple)",
|
|
|
|
"Good call (simple)",
|
|
|
|
args{ sign: "on4kjm", },
|
|
|
|
args{sign: "on4kjm"},
|
|
|
|
"ON4KJM", "",
|
|
|
|
"ON4KJM", "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Good call (suffix)",
|
|
|
|
"Good call (suffix)",
|
|
|
|
args{ sign: "on4kjm/p", },
|
|
|
|
args{sign: "on4kjm/p"},
|
|
|
|
"ON4KJM/P", "",
|
|
|
|
"ON4KJM/P", "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Good call (prefix only)",
|
|
|
|
"Good call (prefix only)",
|
|
|
|
args{ sign: "DL/on4KJm", },
|
|
|
|
args{sign: "DL/on4KJm"},
|
|
|
|
"DL/ON4KJM", "",
|
|
|
|
"DL/ON4KJM", "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Good call (prefix and suffix)",
|
|
|
|
"Good call (prefix and suffix)",
|
|
|
|
args{ sign: "DL/on4KJm/p", },
|
|
|
|
args{sign: "DL/on4KJm/p"},
|
|
|
|
"DL/ON4KJM/P", "",
|
|
|
|
"DL/ON4KJM/P", "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Good call (Numerical prefix)",
|
|
|
|
"Good call (Numerical prefix)",
|
|
|
|
args{ sign: "4x/on4KJm/p", },
|
|
|
|
args{sign: "4x/on4KJm/p"},
|
|
|
|
"4X/ON4KJM/P", "",
|
|
|
|
"4X/ON4KJM/P", "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Good call (prefix and long suffix)",
|
|
|
|
"Good call (prefix and long suffix)",
|
|
|
|
args{ sign: "DL/on4KJm/qrpp ", },
|
|
|
|
args{sign: "DL/on4KJm/qrpp "},
|
|
|
|
"DL/ON4KJM/QRPP", "",
|
|
|
|
"DL/ON4KJM/QRPP", "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
//Error cases
|
|
|
|
//Error cases
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Pure junk passed",
|
|
|
|
"Pure junk passed",
|
|
|
|
args{ sign: "aaaaaa", },
|
|
|
|
args{sign: "aaaaaa"},
|
|
|
|
"*AAAAAA", "Invalid call",
|
|
|
|
"*AAAAAA", "Invalid call",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"empty string",
|
|
|
|
"empty string",
|
|
|
|
args{ sign: "", },
|
|
|
|
args{sign: ""},
|
|
|
|
"*", "Invalid call",
|
|
|
|
"*", "Invalid call",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"string with spaces",
|
|
|
|
"string with spaces",
|
|
|
|
args{ sign: " ", },
|
|
|
|
args{sign: " "},
|
|
|
|
"*", "Invalid call",
|
|
|
|
"*", "Invalid call",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"invalid prefix",
|
|
|
|
"invalid prefix",
|
|
|
|
args{ sign: "xyz/on4kjm", },
|
|
|
|
args{sign: "xyz/on4kjm"},
|
|
|
|
"*XYZ/ON4KJM", "Invalid prefix",
|
|
|
|
"*XYZ/ON4KJM", "Invalid prefix",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Too many /",
|
|
|
|
"Too many /",
|
|
|
|
args{ sign: "F/on4kjm/p/x", },
|
|
|
|
args{sign: "F/on4kjm/p/x"},
|
|
|
|
"*F/ON4KJM/P/X", "Too many '/'",
|
|
|
|
"*F/ON4KJM/P/X", "Too many '/'",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"signe /",
|
|
|
|
"signe /",
|
|
|
|
args{ sign: "/", },
|
|
|
|
args{sign: "/"},
|
|
|
|
"*/", "Invalid call",
|
|
|
|
"*/", "Invalid call",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -237,21 +238,20 @@ func TestValidateDate(t *testing.T) {
|
|
|
|
wantErrorMsg string
|
|
|
|
wantErrorMsg string
|
|
|
|
}{
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Good date (simple)",
|
|
|
|
"Good date (simple)",
|
|
|
|
args{ inputStr: "2020-06-10", },
|
|
|
|
args{inputStr: "2020-06-10"},
|
|
|
|
"2020-06-10", "",
|
|
|
|
"2020-06-10", "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// {
|
|
|
|
// {
|
|
|
|
// "Good date (extrapolate, different delimiter)",
|
|
|
|
// "Good date (extrapolate, different delimiter)",
|
|
|
|
// args{ inputStr: "16-2-1", },
|
|
|
|
// args{ inputStr: "16-2-1", },
|
|
|
|
// "2020-06-10", "",
|
|
|
|
// "2020-06-10", "",
|
|
|
|
// },
|
|
|
|
// },
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Bad date (simple)",
|
|
|
|
"Bad date (simple)",
|
|
|
|
args{ inputStr: "2020-13-10", },
|
|
|
|
args{inputStr: "2020-13-10"},
|
|
|
|
"*2020-13-10", "parsing time \"2020-13-10\": month out of range",
|
|
|
|
"*2020-13-10", "parsing time \"2020-13-10\": month out of range",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
@ -265,3 +265,46 @@ func TestValidateDate(t *testing.T) {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func TestIsBand(t *testing.T) {
|
|
|
|
|
|
|
|
type args struct {
|
|
|
|
|
|
|
|
inputStr string
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
tests := []struct {
|
|
|
|
|
|
|
|
name string
|
|
|
|
|
|
|
|
args args
|
|
|
|
|
|
|
|
wantResult bool
|
|
|
|
|
|
|
|
wantLowerLimit float32
|
|
|
|
|
|
|
|
wantUpperLimit float32
|
|
|
|
|
|
|
|
}{
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"invalid band",
|
|
|
|
|
|
|
|
args{inputStr: "zzzz"},
|
|
|
|
|
|
|
|
false, 0, 0,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"valid band",
|
|
|
|
|
|
|
|
args{inputStr: "40m"},
|
|
|
|
|
|
|
|
true, 7.0, 7.3,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"valid band but uppercase",
|
|
|
|
|
|
|
|
args{inputStr: "40M"},
|
|
|
|
|
|
|
|
true, 7.0, 7.3,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, tt := range tests {
|
|
|
|
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
|
|
|
|
gotResult, gotLowerLimit, gotUpperLimit := IsBand(tt.args.inputStr)
|
|
|
|
|
|
|
|
if gotResult != tt.wantResult {
|
|
|
|
|
|
|
|
t.Errorf("IsBand() gotResult = %v, want %v", gotResult, tt.wantResult)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if gotLowerLimit != tt.wantLowerLimit {
|
|
|
|
|
|
|
|
t.Errorf("IsBand() gotLowerLimit = %v, want %v", gotLowerLimit, tt.wantLowerLimit)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if gotUpperLimit != tt.wantUpperLimit {
|
|
|
|
|
|
|
|
t.Errorf("IsBand() gotUpperLimit = %v, want %v", gotUpperLimit, tt.wantUpperLimit)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|