Remove BCD.Int, add BCD.Major/Minor. Remove USB spec versions

- I don't expect them to get much use, and reuse of BCD for USB spec
version and device revision makes it somewhat confusing.
This commit is contained in:
Sebastian Zagrodzki
2017-04-09 20:25:16 +02:00
parent a5c4de3a29
commit 56162d0105
6 changed files with 45 additions and 32 deletions

View File

@@ -21,19 +21,22 @@ import (
func TestBCD(t *testing.T) {
tests := []struct {
BCD
Int int
Str string
major, minor uint8
bcd BCD
str string
}{
{0x1234, 1234, "12.34"},
{1, 1, 0x0101, "1.01"},
{12, 34, 0x1234, "12.34"},
}
for _, test := range tests {
if got, want := test.BCD.Int(), test.Int; got != want {
t.Errorf("Int(%x) = %d, want %d", test.BCD, got, want)
bcd := Version(test.major, test.minor)
if bcd != test.bcd {
t.Errorf("Version(%d, %d): got BCD %04x, want %04x", test.major, test.minor, uint16(bcd), uint16(test.bcd))
continue
}
if got, want := test.BCD.String(), test.Str; got != want {
t.Errorf("String(%x) = %q, want %q", test.BCD, got, want)
if got, want := bcd.String(), test.str; got != want {
t.Errorf("String(%04x) = %q, want %q", uint16(test.bcd), got, want)
}
}
}