MCPcopy
hub / github.com/segmentio/kafka-go / testWriteOptimization

Function testWriteOptimization

write_test.go:158–192  ·  view source on GitHub ↗
(t *testing.T, h requestHeader, r request, f func(*writeBuffer))

Source from the content-addressed store, hash-verified

156}
157
158func testWriteOptimization(t *testing.T, h requestHeader, r request, f func(*writeBuffer)) {
159 b1 := &bytes.Buffer{}
160 w1 := &writeBuffer{w: b1}
161
162 b2 := &bytes.Buffer{}
163 w2 := &writeBuffer{w: b2}
164
165 h.Size = (h.size() + r.size()) - 4
166 h.writeTo(w1)
167 r.writeTo(w1)
168
169 f(w2)
170
171 c1 := b1.Bytes()
172 c2 := b2.Bytes()
173
174 if !bytes.Equal(c1, c2) {
175 t.Error("content differs")
176
177 n1 := len(c1)
178 n2 := len(c2)
179
180 if n1 != n2 {
181 t.Log("content length 1 =", n1)
182 t.Log("content length 2 =", n2)
183 } else {
184 for i := 0; i != n1; i++ {
185 if c1[i] != c2[i] {
186 t.Logf("byte at offset %d/%d: %#x != %#x", i, n1, c1[i], c2[i])
187 break
188 }
189 }
190 }
191 }
192}
193
194func TestWriteV2RecordBatch(t *testing.T) {
195 if !ktesting.KafkaIsAtLeast("0.11.0") {

Callers 3

testWriteFetchRequestV2Function · 0.85

Calls 4

sizeMethod · 0.65
writeToMethod · 0.65
BytesMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected