MCPcopy Index your code
hub / github.com/golang/groupcache / TestAllocatingByteSliceTarget

Function TestAllocatingByteSliceTarget

groupcache_test.go:344–366  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

342}
343
344func TestAllocatingByteSliceTarget(t *testing.T) {
345 var dst []byte
346 sink := AllocatingByteSliceSink(&dst)
347
348 inBytes := []byte("some bytes")
349 sink.SetBytes(inBytes)
350 if want := "some bytes"; string(dst) != want {
351 t.Errorf("SetBytes resulted in %q; want %q", dst, want)
352 }
353 v, err := sink.view()
354 if err != nil {
355 t.Fatalf("view after SetBytes failed: %v", err)
356 }
357 if &inBytes[0] == &dst[0] {
358 t.Error("inBytes and dst share memory")
359 }
360 if &inBytes[0] == &v.b[0] {
361 t.Error("inBytes and view share memory")
362 }
363 if &dst[0] == &v.b[0] {
364 t.Error("dst and view share memory")
365 }
366}
367
368// orderedFlightGroup allows the caller to force the schedule of when
369// orig.Do will be called. This is useful to serialize calls such

Callers

nothing calls this directly

Calls 3

AllocatingByteSliceSinkFunction · 0.85
SetBytesMethod · 0.65
viewMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…