@@ -6,8 +6,10 @@ import (
6
6
"fmt"
7
7
"io"
8
8
"strings"
9
+ "testing"
9
10
10
11
"github.com/go-git/go-git/v5/plumbing/format/pktline"
12
+ "github.com/stretchr/testify/assert"
11
13
12
14
. "gopkg.in/check.v1"
13
15
)
@@ -21,6 +23,7 @@ func (s *SuiteScanner) TestInvalid(c *C) {
21
23
"0001" , "0002" , "0003" , "0004" ,
22
24
"0001asdfsadf" , "0004foo" ,
23
25
"fff5" , "ffff" ,
26
+ "FFF5" , "FFFF" ,
24
27
"gorka" ,
25
28
"0" , "003" ,
26
29
" 5a" , "5 a" , "5 \n " ,
@@ -48,6 +51,24 @@ func (s *SuiteScanner) TestDecodeOversizePktLines(c *C) {
48
51
}
49
52
}
50
53
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
+
51
72
func (s * SuiteScanner ) TestEmptyReader (c * C ) {
52
73
r := strings .NewReader ("" )
53
74
sc := pktline .NewScanner (r )
0 commit comments