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

Function TestXerialWriterAgainstGoXerialSnappy

compress/snappy/xerial_test.go:142–165  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

140}
141
142func TestXerialWriterAgainstGoXerialSnappy(t *testing.T) {
143 rawData := new(bytes.Buffer)
144 rawData.Grow(1024 * 1024)
145 io.CopyN(rawData, rand.Reader, 1024*1024)
146
147 framedAndCompressedData := new(bytes.Buffer)
148 framedAndCompressedData.Grow(rawData.Len())
149 w := &xerialWriter{writer: framedAndCompressedData, framed: true, encode: snappy.Encode}
150 r := simpleReader{bytes.NewReader(rawData.Bytes())}
151 io.Copy(w, r)
152 w.Flush()
153
154 unframedAndDecompressedData, err := goxerialsnappy.Decode(framedAndCompressedData.Bytes())
155 if err != nil {
156 t.Error(err)
157 }
158
159 b0 := rawData.Bytes()
160 b1 := unframedAndDecompressedData
161
162 if !bytes.Equal(b0, b1) {
163 t.Error("data mismatch")
164 }
165}

Callers

nothing calls this directly

Calls 5

FlushMethod · 0.95
LenMethod · 0.65
NewReaderMethod · 0.65
BytesMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected