MCPcopy Create free account
hub / github.com/SenseUnit/dumbproxy / TestParseSerialBytes

Function TestParseSerialBytes

auth/cert_test.go:25–67  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23}
24
25func 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
69type serialNumberSetTestcase struct {
70 input *big.Int

Callers

nothing calls this directly

Calls 2

parseSerialBytesFunction · 0.85
FatalfMethod · 0.80

Tested by

no test coverage detected