File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -316,6 +316,31 @@ func TestDecodeIncomplete(t *testing.T) {
316
316
}
317
317
}
318
318
319
+ var unexpectedDelimiter = []struct {
320
+ name string
321
+ data []byte
322
+ }{
323
+ {
324
+ name : "Missing byte before delimiter" ,
325
+ data : []byte {0x02 , 0x00 },
326
+ },
327
+ {
328
+ name : "Unexpected embedded zero" ,
329
+ data : []byte ("\x06 1234\x00 5\x05 6789" ),
330
+ },
331
+ }
332
+
333
+ func TestDecodeUnexpectedEOD (t * testing.T ) {
334
+ for _ , tc := range unexpectedDelimiter {
335
+ t .Run (tc .name , func (t * testing.T ) {
336
+ _ , err := Decode (tc .data )
337
+ if err != ErrUnexpectedEOD {
338
+ t .Errorf ("Unexpected decode EOD error: %v" , err )
339
+ }
340
+ })
341
+ }
342
+ }
343
+
319
344
// https://github.com/golang/go/issues/54111
320
345
type LimitedWriter struct {
321
346
W io.Writer // underlying writer
You can’t perform that action at this time.
0 commit comments