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

Function TestParseBinaryChunk

pkg/gitdiff/binary_test.go:124–204  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

122}
123
124func TestParseBinaryChunk(t *testing.T) {
125 tests := map[string]struct {
126 Input string
127 Fragment BinaryFragment
128 Output []byte
129 Err string
130 }{
131 "singleline": {
132 Input: "TcmZQzU|?i`U?w2V48*Je09XJG\n\n",
133 Fragment: BinaryFragment{
134 Size: 20,
135 },
136 Output: fib(5, binary.BigEndian),
137 },
138 "multiline": {
139 Input: "zcmZQzU|?i`U?w2V48*KJ%mKu_Kr9NxN<eH5#F0Qe0f=7$l~*z_FeL$%-)3N7vt?l5\n" +
140 "zl3-vE2xVZ9%4J~CI>f->s?WfX|B-=Vs{#X~svra7Ekg#T|4s}nH;WnAZ)|1Y*`&cB\n" +
141 "s(sh?X(Uz6L^!Ou&aF*u`J!eibJifSrv0z>$Q%Hd(^HIJ<Y?5`S0gT5UE&u=k\n\n",
142 Fragment: BinaryFragment{
143 Size: 160,
144 },
145 Output: fib(40, binary.BigEndian),
146 },
147 "shortLine": {
148 Input: "A00\n\n",
149 Err: "corrupt data line",
150 },
151 "underpaddedLine": {
152 Input: "H00000000\n\n",
153 Err: "corrupt data line",
154 },
155 "invalidLengthByte": {
156 Input: "!00000\n\n",
157 Err: "invalid length byte",
158 },
159 "miscountedLine": {
160 Input: "H00000\n\n",
161 Err: "incorrect byte count",
162 },
163 "invalidEncoding": {
164 Input: "TcmZQzU|?i'U?w2V48*Je09XJG\n",
165 Err: "invalid base85 byte",
166 },
167 "noTrailingEmptyLine": {
168 Input: "TcmZQzU|?i`U?w2V48*Je09XJG\n",
169 Err: "unexpected EOF",
170 },
171 "invalidCompression": {
172 Input: "F007GV%KiWV\n\n",
173 Err: "zlib",
174 },
175 "incorrectSize": {
176 Input: "TcmZQzU|?i`U?w2V48*Je09XJG\n\n",
177 Fragment: BinaryFragment{
178 Size: 16,
179 },
180 Err: "16 byte fragment inflated to 20",
181 },

Callers

nothing calls this directly

Calls 5

fibFunction · 0.85
newTestParserFunction · 0.85
ParseBinaryChunkMethod · 0.80
ErrorfMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected