package main import "testing" // The width follows the mode, and an unrecognised mode must land on the widest // of the three: a 50 kHz window is readable for everything, where 25 kHz shows // one eighth of an FT8 sub-band. func TestFlexZoomGroup(t *testing.T) { for mode, want := range map[string]string{ "CW": "cw", "cw": "cw", "CWR": "cw", "SSB": "ssb", "USB": "ssb", "LSB": "ssb", "FM": "ssb", "AM": "ssb", "FT8": "digi", "FT4": "digi", "RTTY": "digi", "JS8": "digi", "PSK31": "digi", "": "digi", "something new": "digi", } { if got := flexZoomGroup(mode); got != want { t.Errorf("flexZoomGroup(%q) = %q, want %q", mode, got, want) } } } // A width of zero would command "bandwidth=0.000000" and take the panadapter // somewhere the operator cannot get back from by eye. func TestNormFlexZoomClamps(t *testing.T) { got := normFlexZoom(FlexZoomSettings{CWkHz: 0, SSBkHz: -5, DigikHz: 99999}) if got.CWkHz != defaultFlexZoom.CWkHz || got.SSBkHz != defaultFlexZoom.SSBkHz || got.DigikHz != defaultFlexZoom.DigikHz { t.Errorf("out-of-range widths not replaced by the defaults: %+v", got) } ok := normFlexZoom(FlexZoomSettings{CWkHz: 10, SSBkHz: 150, DigikHz: 40}) if ok.CWkHz != 10 || ok.SSBkHz != 150 || ok.DigikHz != 40 { t.Errorf("valid widths must be kept as they are: %+v", ok) } }