38 lines
1.2 KiB
Go
38 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"hamlog/internal/pskr"
|
|
)
|
|
|
|
// The receiver radius is what makes an opening report evidence about the
|
|
// OPERATOR's path rather than someone else's. Both ends of the range destroy
|
|
// that: too small and no receiver is ever near enough, too large and the
|
|
// reports are about a different part of the world. A stored value that would do
|
|
// either has to fall back rather than be honoured.
|
|
func TestBandOpenNearKmClamps(t *testing.T) {
|
|
for _, tc := range []struct {
|
|
name string
|
|
raw string
|
|
want int
|
|
}{
|
|
{"unset falls back", "", pskr.DefaultNearKm},
|
|
{"not a number falls back", "soon", pskr.DefaultNearKm},
|
|
{"zero falls back", "0", pskr.DefaultNearKm},
|
|
{"negative falls back", "-100", pskr.DefaultNearKm},
|
|
{"absurdly tight falls back", "5", pskr.DefaultNearKm},
|
|
{"absurdly wide falls back", "5000", pskr.DefaultNearKm},
|
|
{"a real choice is kept", "100", 100},
|
|
{"the lower bound is kept", "25", 25},
|
|
{"the upper bound is kept", "1000", 1000},
|
|
{"surrounding space is ignored", " 150 ", 150},
|
|
} {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
if got := bandOpenNearKm(tc.raw); got != tc.want {
|
|
t.Errorf("bandOpenNearKm(%q) = %d, want %d", tc.raw, got, tc.want)
|
|
}
|
|
})
|
|
}
|
|
}
|