|
|
|
@@ -126,3 +126,31 @@ func TestLimiterPreventsClipping(t *testing.T) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func TestParsePI(t *testing.T) { |
|
|
|
tests := []struct { |
|
|
|
name string |
|
|
|
in string |
|
|
|
want uint16 |
|
|
|
}{ |
|
|
|
{name: "plain hex", in: "1234", want: 0x1234}, |
|
|
|
{name: "0x prefix", in: "0xBEEF", want: 0xBEEF}, |
|
|
|
{name: "uppercase prefix", in: "0XCAFE", want: 0xCAFE}, |
|
|
|
{name: "whitespace", in: " 0x2345 ", want: 0x2345}, |
|
|
|
{name: "empty fallback", in: "", want: 0x1234}, |
|
|
|
{name: "invalid fallback", in: "nope", want: 0x1234}, |
|
|
|
} |
|
|
|
for _, tt := range tests { |
|
|
|
if got := parsePI(tt.in); got != tt.want { |
|
|
|
t.Fatalf("%s: got 0x%04X want 0x%04X", tt.name, got, tt.want) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func TestGeneratorUsesConfiguredPI(t *testing.T) { |
|
|
|
cfg := cfgpkg.Default() |
|
|
|
cfg.RDS.PI = "BEEF" |
|
|
|
if got := parsePI(cfg.RDS.PI); got != 0xBEEF { |
|
|
|
t.Fatalf("configured PI was not parsed as expected: got 0x%04X", got) |
|
|
|
} |
|
|
|
} |