(t *testing.T)
| 23 | } |
| 24 | |
| 25 | func TestParseSerialBytes(t *testing.T) { |
| 26 | testcases := []parseSerialBytesTestcase{ |
| 27 | { |
| 28 | input: []byte(""), |
| 29 | output: []byte{}, |
| 30 | }, |
| 31 | { |
| 32 | input: []byte("01:02:03"), |
| 33 | output: []byte{1, 2, 3}, |
| 34 | }, |
| 35 | { |
| 36 | input: []byte("ff"), |
| 37 | output: []byte{255}, |
| 38 | }, |
| 39 | { |
| 40 | input: []byte("ff:f"), |
| 41 | error: true, |
| 42 | }, |
| 43 | { |
| 44 | input: []byte("f"), |
| 45 | error: true, |
| 46 | }, |
| 47 | { |
| 48 | input: []byte("fff"), |
| 49 | error: true, |
| 50 | }, |
| 51 | { |
| 52 | input: []byte("---"), |
| 53 | error: true, |
| 54 | }, |
| 55 | } |
| 56 | for i, testcase := range testcases { |
| 57 | t.Run(fmt.Sprintf("Testcase[%d]", i), func(t *testing.T) { |
| 58 | out, err := parseSerialBytes(testcase.input) |
| 59 | if (err != nil) != testcase.error { |
| 60 | t.Fatalf("unexpected error: %v", err) |
| 61 | } |
| 62 | if bytes.Compare(out, testcase.output) != 0 { |
| 63 | t.Fatalf("expected %v, got %v", testcase.output, out) |
| 64 | } |
| 65 | }) |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | type serialNumberSetTestcase struct { |
| 70 | input *big.Int |
nothing calls this directly
no test coverage detected