MCPcopy Create free account
hub / github.com/golang/groupcache / TestTruncatingByteSliceTarget

Function TestTruncatingByteSliceTarget

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

Source from the content-addressed store, hash-verified

323}
324
325func TestTruncatingByteSliceTarget(t *testing.T) {
326 var buf [100]byte
327 s := buf[:]
328 if err := stringGroup.Get(dummyCtx, "short", TruncatingByteSliceSink(&s)); err != nil {
329 t.Fatal(err)
330 }
331 if want := "ECHO:short"; string(s) != want {
332 t.Errorf("short key got %q; want %q", s, want)
333 }
334
335 s = buf[:6]
336 if err := stringGroup.Get(dummyCtx, "truncated", TruncatingByteSliceSink(&s)); err != nil {
337 t.Fatal(err)
338 }
339 if want := "ECHO:t"; string(s) != want {
340 t.Errorf("truncated key got %q; want %q", s, want)
341 }
342}
343
344func TestAllocatingByteSliceTarget(t *testing.T) {
345 var dst []byte

Callers

nothing calls this directly

Calls 2

TruncatingByteSliceSinkFunction · 0.85
GetMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…