Debian Codegraph @

plumbing/format/pktline/pktline_write_test.go

raw symbols SCIP
1 package pktline_testscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline_test`/
2
3 import (
4 "bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/"
5 "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/"
6 "ioscip-go gomod github.com/golang/go/src go1.25.0 io/"
7 "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/"
8 "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/"
9
10 "github.com/stretchr/testify/suitescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/suite`/"
11
12 "github.com/go-git/go-git/v6/plumbing/format/pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/"
13 )
14
15 type SuiteWriterscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline_test`/SuiteWriter# struct {
16 suitescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/suite`/.Suitescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline_test`/SuiteWriter#Suite.
17 }
18
19 func TestSuiteWriterscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline_test`/TestSuiteWriter().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
20 t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().()
21 suitescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/suite`/.Runscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/suite`/Run().(t, new(SuiteWriterscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline_test`/SuiteWriter#))
22 }
23
24 func (s *SuiteWriterscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline_test`/SuiteWriter#) TestFlushscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline_test`/SuiteWriter#TestFlush().() {
25 var buf bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#
26 err := pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.WriteFlushscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/WriteFlush().(&buf)
27 s.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Assertions#NoError().(err)
28
29 obtained := buf.Bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#Bytes().()
30 s.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Assertions#Equal().([]byte("0000"), obtained)
31 }
32
33 func (s *SuiteWriterscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline_test`/SuiteWriter#) TestNilWriterscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline_test`/SuiteWriter#TestNilWriter().() {
34 for _, test := range []struct {
35 name string
36 write func() error
37 }{
38 {
39 name: "write",
40 write: func() error {
41 _, err := pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.Writescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/Write().(nil, []byte("payload"))
42 return err
43 },
44 },
45 {
46 name: "write string",
47 write: func() error {
48 _, err := pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.WriteStringscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/WriteString().(nil, "payload")
49 return err
50 },
51 },
52 {
53 name: "write line",
54 write: func() error {
55 _, err := pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.Writelnscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/Writeln().(nil, "payload")
56 return err
57 },
58 },
59 {
60 name: "write format",
61 write: func() error {
62 _, err := pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.Writefscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/Writef().(nil, "%s", "payload")
63 return err
64 },
65 },
66 {
67 name: "write error",
68 write: func() error {
69 _, err := pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.WriteErrorscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/WriteError().(nil, ioscip-go gomod github.com/golang/go/src go1.25.0 io/.EOFscip-go gomod github.com/golang/go/src go1.25.0 io/EOF.)
70 return err
71 },
72 },
73 {
74 name: "write flush",
75 write: func() error {
76 return pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.WriteFlushscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/WriteFlush().(nil)
77 },
78 },
79 {
80 name: "write delim",
81 write: func() error {
82 return pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.WriteDelimscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/WriteDelim().(nil)
83 },
84 },
85 {
86 name: "write response end",
87 write: func() error {
88 return pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.WriteResponseEndscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/WriteResponseEnd().(nil)
89 },
90 },
91 } {
92 s.Runscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/suite`/Suite#Run().(test.name, func() {
93 var err error
94 if s.NotPanicsscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Assertions#NotPanics().(func() {
95 err = test.write()
96 }) {
97 s.ErrorIsscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Assertions#ErrorIs().(err, pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.ErrNilWriterscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/ErrNilWriter.)
98 }
99 })
100 }
101 }
102
103 func (s *SuiteWriterscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline_test`/SuiteWriter#) TestWriteErrorInvalidInputscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline_test`/SuiteWriter#TestWriteErrorInvalidInput().() {
104 for _, test := range []struct {
105 name string
106 writer ioscip-go gomod github.com/golang/go/src go1.25.0 io/.Writerscip-go gomod github.com/golang/go/src go1.25.0 io/Writer#
107 err error
108 expected error
109 }{
110 {name: "nil writer", writer: nil, err: nil, expected: pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.ErrNilWriterscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/ErrNilWriter.},
111 {name: "nil error", writer: ioscip-go gomod github.com/golang/go/src go1.25.0 io/.Discardscip-go gomod github.com/golang/go/src go1.25.0 io/Discard., err: nil, expected: pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.ErrNilErrorscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/ErrNilError.},
112 } {
113 s.Runscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/suite`/Suite#Run().(test.name, func() {
114 var (
115 n int
116 err error
117 )
118 if s.NotPanicsscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Assertions#NotPanics().(func() {
119 n, err = pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.WriteErrorscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/WriteError().(test.writer, test.err)
120 }) {
121 s.Zeroscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Assertions#Zero().(n)
122 s.ErrorIsscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Assertions#ErrorIs().(err, test.expected)
123 }
124 })
125 }
126 }
127
128 func (s *SuiteWriterscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline_test`/SuiteWriter#) TestEncodescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline_test`/SuiteWriter#TestEncode().() {
129 for i, test := range [...]struct {
130 input [][]byte
131 expected []byte
132 }{
133 {
134 input: [][]byte{
135 []byte("hello\n"),
136 },
137 expected: []byte("000ahello\n"),
138 }, {
139 input: [][]byte{
140 []byte("hello\n"),
141 {},
142 },
143 expected: []byte("000ahello\n0000"),
144 }, {
145 input: [][]byte{
146 []byte("hello\n"),
147 []byte("world!\n"),
148 []byte("foo"),
149 },
150 expected: []byte("000ahello\n000bworld!\n0007foo"),
151 }, {
152 input: [][]byte{
153 []byte("hello\n"),
154 {},
155 []byte("world!\n"),
156 []byte("foo"),
157 {},
158 },
159 expected: []byte("000ahello\n0000000bworld!\n0007foo0000"),
160 }, {
161 input: [][]byte{
162 []byte(stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("a", pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.MaxPayloadSizescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/MaxPayloadSize.)),
163 },
164 expected: []byte(
165 "fff0" + stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("a", pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.MaxPayloadSizescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/MaxPayloadSize.)),
166 }, {
167 input: [][]byte{
168 []byte(stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("a", pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.MaxPayloadSizescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/MaxPayloadSize.)),
169 []byte(stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("b", pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.MaxPayloadSizescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/MaxPayloadSize.)),
170 },
171 expected: []byte(
172 "fff0" + stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("a", pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.MaxPayloadSizescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/MaxPayloadSize.) +
173 "fff0" + stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("b", pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.MaxPayloadSizescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/MaxPayloadSize.)),
174 },
175 } {
176 comment := fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("input %d = %s\n", i, test.input)
177
178 var buf bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#
179
180 for _, p := range test.input {
181 var err error
182 if len(p) == 0 {
183 err = pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.WriteFlushscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/WriteFlush().(&buf)
184 } else {
185 _, err = pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.Writescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/Write().(&buf, p)
186 }
187 s.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Assertions#NoError().(err, comment)
188 }
189
190 s.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Assertions#Equal().(string(test.expected), buf.Stringscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#String().(), comment)
191 }
192 }
193
194 func (s *SuiteWriterscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline_test`/SuiteWriter#) TestEncodeErrPayloadTooLongscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline_test`/SuiteWriter#TestEncodeErrPayloadTooLong().() {
195 for i, input := range [...][][]byte{
196 {
197 []byte(stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("a", pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.MaxPayloadSizescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/MaxPayloadSize.+1)),
198 },
199 {
200 []byte("hello world!"),
201 []byte(stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("a", pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.MaxPayloadSizescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/MaxPayloadSize.+1)),
202 },
203 {
204 []byte("hello world!"),
205 []byte(stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("a", pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.MaxPayloadSizescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/MaxPayloadSize.+1)),
206 []byte("foo"),
207 },
208 } {
209 comment := fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("input %d = %v\n", i, input)
210
211 var buf bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#
212 _, err := pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.Writescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/Write().(&buf, bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/.Joinscip-go gomod github.com/golang/go/src go1.25.0 bytes/Join().(input, nil))
213 s.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Assertions#Equal().(pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.ErrPayloadTooLongscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/ErrPayloadTooLong., err, comment)
214 }
215 }
216
217 func (s *SuiteWriterscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline_test`/SuiteWriter#) TestWritePacketStringsscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline_test`/SuiteWriter#TestWritePacketStrings().() {
218 for i, test := range [...]struct {
219 input []string
220 expected []byte
221 }{
222 {
223 input: []string{
224 "hello\n",
225 },
226 expected: []byte("000ahello\n"),
227 }, {
228 input: []string{
229 "hello\n",
230 "",
231 },
232 expected: []byte("000ahello\n0000"),
233 }, {
234 input: []string{
235 "hello\n",
236 "world!\n",
237 "foo",
238 },
239 expected: []byte("000ahello\n000bworld!\n0007foo"),
240 }, {
241 input: []string{
242 "hello\n",
243 "",
244 "world!\n",
245 "foo",
246 "",
247 },
248 expected: []byte("000ahello\n0000000bworld!\n0007foo0000"),
249 }, {
250 input: []string{
251 stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("a", pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.MaxPayloadSizescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/MaxPayloadSize.),
252 },
253 expected: []byte(
254 "fff0" + stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("a", pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.MaxPayloadSizescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/MaxPayloadSize.)),
255 }, {
256 input: []string{
257 stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("a", pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.MaxPayloadSizescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/MaxPayloadSize.),
258 stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("b", pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.MaxPayloadSizescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/MaxPayloadSize.),
259 },
260 expected: []byte(
261 "fff0" + stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("a", pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.MaxPayloadSizescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/MaxPayloadSize.) +
262 "fff0" + stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("b", pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.MaxPayloadSizescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/MaxPayloadSize.)),
263 },
264 } {
265 comment := fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("input %d = %v\n", i, test.input)
266
267 var buf bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#
268 for _, p := range test.input {
269 var err error
270 if p == "" {
271 err = pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.WriteFlushscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/WriteFlush().(&buf)
272 } else {
273 _, err = pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.WriteStringscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/WriteString().(&buf, p)
274 }
275 s.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Assertions#NoError().(err, comment)
276 }
277 s.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Assertions#Equal().(string(test.expected), buf.Stringscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#String().(), comment)
278 }
279 }
280
281 func (s *SuiteWriterscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline_test`/SuiteWriter#) TestWritePacketStringErrPayloadTooLongscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline_test`/SuiteWriter#TestWritePacketStringErrPayloadTooLong().() {
282 for i, input := range [...][]string{
283 {
284 stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("a", pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.MaxPayloadSizescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/MaxPayloadSize.+1),
285 },
286 {
287 "hello world!",
288 stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("a", pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.MaxPayloadSizescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/MaxPayloadSize.+1),
289 },
290 {
291 "hello world!",
292 stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("a", pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.MaxPayloadSizescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/MaxPayloadSize.+1),
293 "foo",
294 },
295 } {
296 comment := fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("input %d = %v\n", i, input)
297
298 var buf bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#
299 _, err := pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.WriteStringscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/WriteString().(&buf, stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.25.0 strings/Join().(input, ""))
300 s.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Assertions#Equal().(pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.ErrPayloadTooLongscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/ErrPayloadTooLong., err, comment)
301 }
302 }
303
304 func (s *SuiteWriterscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline_test`/SuiteWriter#) TestFormatStringscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline_test`/SuiteWriter#TestFormatString().() {
305 format := " %s %d\n"
306 str := "foo"
307 d := 42
308
309 var buf bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#
310 _, err := pktlinescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/.Writefscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/pktline`/Writef().(&buf, format, str, d)
311 s.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Assertions#NoError().(err)
312
313 expected := []byte("000c foo 42\n")
314 s.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Assertions#Equal().(expected, buf.Bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#Bytes().())
315 }