@@ -6,8 +6,10 @@ import (
66 "fmt"
77 "io"
88 "strings"
9+ "testing"
910
1011 "github.com/go-git/go-git/v5/plumbing/format/pktline"
12+ "github.com/stretchr/testify/assert"
1113
1214 . "gopkg.in/check.v1"
1315)
@@ -21,6 +23,7 @@ func (s *SuiteScanner) TestInvalid(c *C) {
2123 "0001" , "0002" , "0003" , "0004" ,
2224 "0001asdfsadf" , "0004foo" ,
2325 "fff5" , "ffff" ,
26+ "FFF5" , "FFFF" ,
2427 "gorka" ,
2528 "0" , "003" ,
2629 " 5a" , "5 a" , "5 \n " ,
@@ -48,6 +51,24 @@ func (s *SuiteScanner) TestDecodeOversizePktLines(c *C) {
4851 }
4952}
5053
54+ func TestValidPktSizes (t * testing.T ) {
55+ for _ , test := range [... ]string {
56+ "01fe" + strings .Repeat ("a" , 0x01fe - 4 ),
57+ "01FE" + strings .Repeat ("a" , 0x01fe - 4 ),
58+ "00b5" + strings .Repeat ("a" , 0x00b5 - 4 ),
59+ "00B5" + strings .Repeat ("a" , 0x00b5 - 4 ),
60+ } {
61+ r := strings .NewReader (test )
62+ sc := pktline .NewScanner (r )
63+ hasPayload := sc .Scan ()
64+ obtained := sc .Bytes ()
65+
66+ assert .True (t , hasPayload )
67+ assert .NoError (t , sc .Err ())
68+ assert .Equal (t , []byte (test [4 :]), obtained )
69+ }
70+ }
71+
5172func (s * SuiteScanner ) TestEmptyReader (c * C ) {
5273 r := strings .NewReader ("" )
5374 sc := pktline .NewScanner (r )
0 commit comments