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

Function TestSwapAt

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

Source from the content-addressed store, hash-verified

693}
694
695func TestSwapAt(t *testing.T) {
696 buf := NewSwapAt(New(5), New(10))
697 buf.WriteAt([]byte("hey"), 0)
698 data := make([]byte, 10)
699 n, _ := buf.ReadAt(data, 0)
700 if string(data[:n]) != "hey" {
701 t.Error("expected hey got", string(data[:n]))
702 }
703 buf.WriteAt([]byte("hey"), 3)
704 n, _ = buf.ReadAt(data, 1)
705 if string(data[:n]) != "eyhey" {
706 t.Error("expected eyhey got", string(data[:n]))
707 }
708 buf.WriteAt([]byte("hey"), 5)
709 n, _ = buf.ReadAt(data, 1)
710 if string(data[:n]) != "eyhehey" {
711 t.Error("expected eyhehey got", string(data[:n]))
712 }
713}
714
715func TestSwap(t *testing.T) {
716 defer func() {

Callers

nothing calls this directly

Calls 4

NewSwapAtFunction · 0.85
NewFunction · 0.85
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…