(t *testing.T)
| 61 | } |
| 62 | |
| 63 | func 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 | |
| 99 | func FuzzBase85Roundtrip(f *testing.F) { |
| 100 | f.Add([]byte{0x2b, 0x0d}) |
nothing calls this directly
no test coverage detected