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

Function TestPartitionAt2

buffer_test.go:866–890  ·  view source on GitHub ↗

TestPartitionAt2 tests ability to read at various offsets from buffer previously written.

(t *testing.T)

Source from the content-addressed store, hash-verified

864
865// TestPartitionAt2 tests ability to read at various offsets from buffer previously written.
866func TestPartitionAt2(t *testing.T) {
867 buf := NewPartitionAt(NewMemPoolAt(5))
868 buf.Write([]byte("Hello World"))
869 data := make([]byte, 2)
870 n, _ := buf.ReadAt(data, 2)
871 if !bytes.Equal(data[:n], []byte("ll")) {
872 t.Error("Read Failed. " + string(data[:n]))
873 }
874 n, _ = buf.ReadAt(data, 4)
875 if !bytes.Equal(data[:n], []byte("o ")) {
876 t.Error("Read Failed. " + string(data[:n]))
877 }
878 n, _ = buf.ReadAt(data, 10)
879 if !bytes.Equal(data[:n], []byte("d")) {
880 t.Error("Read Failed. " + string(data[:n]))
881 }
882 n, _ = buf.ReadAt(data, 100)
883 if !bytes.Equal(data[:n], []byte{}) {
884 t.Error("Read Failed. " + string(data[:n]))
885 }
886
887 buf.Reset()
888 checkCap(t, buf, math.MaxInt64)
889 runPerfectSeries(t, buf)
890}
891
892// TestPartitionAt3 tests ability to overwrite buffer previously written.
893func TestPartitionAt3(t *testing.T) {

Callers

nothing calls this directly

Calls 7

NewPartitionAtFunction · 0.85
NewMemPoolAtFunction · 0.85
checkCapFunction · 0.85
runPerfectSeriesFunction · 0.85
ResetMethod · 0.65
WriteMethod · 0.45
ReadAtMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…