MCPcopy
hub / github.com/harness/harness / TestReadLinePrefix

Function TestReadLinePrefix

git/parser/diff_headers_test.go:112–227  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

110}
111
112func TestReadLinePrefix(t *testing.T) {
113 const maxLen = 256
114 tests := []struct {
115 name string
116 wf func(w io.Writer)
117 expLens []int
118 }{
119 {
120 name: "empty",
121 wf: func(io.Writer) {},
122 expLens: nil,
123 },
124 {
125 name: "single",
126 wf: func(w io.Writer) {
127 _, _ = w.Write([]byte("aaa"))
128 },
129 expLens: []int{3},
130 },
131 {
132 name: "single-eol",
133 wf: func(w io.Writer) {
134 _, _ = w.Write([]byte("aaa\n"))
135 },
136 expLens: []int{3},
137 },
138 {
139 name: "two-lines",
140 wf: func(w io.Writer) {
141 _, _ = w.Write([]byte("aa\nbb"))
142 },
143 expLens: []int{2, 2},
144 },
145 {
146 name: "two-lines-crlf",
147 wf: func(w io.Writer) {
148 _, _ = w.Write([]byte("aa\r\nbb\r\n"))
149 },
150 expLens: []int{2, 2},
151 },
152 {
153 name: "empty-line",
154 wf: func(w io.Writer) {
155 _, _ = w.Write([]byte("aa\n\ncc"))
156 },
157 expLens: []int{2, 0, 2},
158 },
159 {
160 name: "too-long",
161 wf: func(w io.Writer) {
162 for i := 0; i < maxLen; i++ {
163 _, _ = w.Write([]byte("a"))
164 }
165 _, _ = w.Write([]byte("\n"))
166 for i := 0; i < maxLen*2; i++ {
167 _, _ = w.Write([]byte("b"))
168 }
169 _, _ = w.Write([]byte("\n"))

Callers

nothing calls this directly

Calls 6

readLinePrefixFunction · 0.85
WriteMethod · 0.65
RunMethod · 0.65
CloseMethod · 0.65
ErrorMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…