MCPcopy Create free account
hub / github.com/dunglas/httpsfv / TestParseBinary

Function TestParseBinary

binary_test.go:20–50  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18}
19
20func TestParseBinary(t *testing.T) {
21 t.Parallel()
22
23 data := []struct {
24 in string
25 out []byte
26 err bool
27 }{
28 {":YWJj:", []byte("abc"), false},
29 {":YW55IGNhcm5hbCBwbGVhc3VyZQ==:", []byte("any carnal pleasure"), false},
30 {":YW55IGNhcm5hbCBwbGVhc3Vy:", []byte("any carnal pleasur"), false},
31 {"", []byte{}, false},
32 {":", []byte{}, false},
33 {":YW55IGNhcm5hbCBwbGVhc3Vy", []byte{}, false},
34 {":YW55IGNhcm5hbCBwbGVhc3Vy~", []byte{}, false},
35 {":YW55IGNhcm5hbCBwbGVhc3VyZQ=:", []byte{}, false},
36 }
37
38 for _, d := range data {
39 s := &scanner{data: d.in}
40
41 i, err := parseBinary(s)
42 if d.err && err == nil {
43 t.Errorf("parseBinary(%s): error expected", d.in)
44 }
45
46 if !d.err && !bytes.Equal(d.out, i) {
47 t.Errorf("parseBinary(%s) = %v, %v; %v, <nil> expected", d.in, i, err, d.out)
48 }
49 }
50}

Callers

nothing calls this directly

Calls 1

parseBinaryFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…