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

Function TestFile

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

Source from the content-addressed store, hash-verified

404}
405
406func TestFile(t *testing.T) {
407 file, err := ioutil.TempFile("", "buffer")
408 if err != nil {
409 t.Error(err.Error())
410 }
411 defer os.Remove(file.Name())
412 defer file.Close()
413
414 buf := NewFile(1024, file)
415 checkCap(t, buf, 1024)
416 runPerfectSeries(t, buf)
417 buf.Reset()
418
419 buf = NewFile(3, file)
420 buf.Write([]byte("abc"))
421 buf.Read(make([]byte, 1))
422 buf.Write([]byte("a"))
423 d, _ := ioutil.ReadAll(buf)
424 if !bytes.Equal(d, []byte("bca")) {
425 t.Error("back and forth error!")
426 }
427}
428
429func TestMem(t *testing.T) {
430 buf := New(1024)

Callers

nothing calls this directly

Calls 8

NewFileFunction · 0.85
checkCapFunction · 0.85
runPerfectSeriesFunction · 0.85
NameMethod · 0.65
CloseMethod · 0.65
ResetMethod · 0.65
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…