MCPcopy Create free account
hub / github.com/antonmedv/gitmal / TestBase85Encode

Function TestBase85Encode

pkg/gitdiff/base85_test.go:63–97  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

61}
62
63func TestBase85Encode(t *testing.T) {
64 tests := map[string]struct {
65 Input []byte
66 Output string
67 }{
68 "zeroBytes": {
69 Input: []byte{},
70 Output: "",
71 },
72 "twoBytes": {
73 Input: []byte{0xCA, 0xFE},
74 Output: "%KiWV",
75 },
76 "fourBytes": {
77 Input: []byte{0x0, 0x0, 0xCA, 0xFE},
78 Output: "007GV",
79 },
80 "sixBytes": {
81 Input: []byte{0x0, 0x0, 0xCA, 0xFE, 0xCA, 0xFE},
82 Output: "007GV%KiWV",
83 },
84 }
85
86 for name, test := range tests {
87 t.Run(name, func(t *testing.T) {
88 dst := make([]byte, len(test.Output))
89 base85Encode(dst, test.Input)
90 for i, b := range test.Output {
91 if dst[i] != byte(b) {
92 t.Errorf("incorrect character at index %d: expected '%c', actual '%c'", i, b, dst[i])
93 }
94 }
95 })
96 }
97}
98
99func FuzzBase85Roundtrip(f *testing.F) {
100 f.Add([]byte{0x2b, 0x0d})

Callers

nothing calls this directly

Calls 2

ErrorfMethod · 0.80
base85EncodeFunction · 0.70

Tested by

no test coverage detected