MCPcopy Create free account
hub / github.com/djherbis/buffer / TestGob

Function TestGob

buffer_test.go:291–314  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

289}
290
291func TestGob(t *testing.T) {
292 str := "HelloWorld"
293
294 buf := NewUnboundedBuffer(2, 2)
295 buf.Write([]byte(str))
296 b := bytes.NewBuffer(nil)
297 if err := gob.NewEncoder(b).Encode(&buf); err != nil {
298 t.Error(err.Error())
299 return
300 }
301 var buffer Buffer
302 if err := gob.NewDecoder(b).Decode(&buffer); err != nil {
303 t.Error(err.Error())
304 return
305 }
306 data := make([]byte, len(str))
307 if _, err := buffer.Read(data); err != nil && err != io.EOF {
308 t.Error(err.Error())
309 }
310 if !bytes.Equal(data, []byte(str)) {
311 t.Error("Gob Recover Failed... " + string(data))
312 }
313 buffer.Reset()
314}
315
316func TestDiscard(t *testing.T) {
317 buf := Discard

Callers

nothing calls this directly

Calls 4

ResetMethod · 0.95
NewUnboundedBufferFunction · 0.85
WriteMethod · 0.45
ReadMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…