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

Function TestPartitionAt3

buffer_test.go:893–915  ·  view source on GitHub ↗

TestPartitionAt3 tests ability to overwrite buffer previously written.

(t *testing.T)

Source from the content-addressed store, hash-verified

891
892// TestPartitionAt3 tests ability to overwrite buffer previously written.
893func TestPartitionAt3(t *testing.T) {
894 buf := NewPartitionAt(NewMemPoolAt(5))
895 buf.Write(make([]byte, 15, 15)) // allocates 3 membuffers
896 buf.WriteAt([]byte("hey"), 0)
897 data := make([]byte, 10)
898 data = data[:3]
899 buf.ReadAt(data, 0)
900 if string(data) != "hey" {
901 t.Error("expected hey got", string(data))
902 }
903 buf.WriteAt([]byte("hey"), 3)
904 data = data[:5]
905 buf.ReadAt(data, 1)
906 if string(data) != "eyhey" {
907 t.Error("expected eyhey got", string(data))
908 }
909 buf.WriteAt([]byte("hey"), 5)
910 data = data[:7]
911 buf.ReadAt(data, 1)
912 if string(data) != "eyhehey" {
913 t.Error("expected eyhehey got", string(data))
914 }
915}

Callers

nothing calls this directly

Calls 5

NewPartitionAtFunction · 0.85
NewMemPoolAtFunction · 0.85
WriteMethod · 0.45
WriteAtMethod · 0.45
ReadAtMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…