MCPcopy
hub / github.com/grafana/tempo / TestInterner_internBytes

Function TestInterner_internBytes

pkg/parquetquery/intern/intern_test.go:11–28  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestInterner_internBytes(t *testing.T) {
12 i := New()
13 defer i.Close()
14
15 words := []string{"hello", "world", "hello", "world", "hello", "world"}
16 for _, w := range words {
17 _ = i.internBytes([]byte(w))
18 }
19 if len(i.m) != 2 {
20 // Values are interned, so there should be only 2 unique words
21 t.Errorf("expected 2, got %d", len(i.m))
22 }
23 interned1, interned2 := i.internBytes([]byte("hello")), i.internBytes([]byte("hello"))
24 if unsafe.SliceData(interned1) != unsafe.SliceData(interned2) {
25 // Values are interned, so the memory address should be the same
26 t.Error("expected same memory address")
27 }
28}
29
30func TestInterner_UnsafeClone(t *testing.T) {
31 i := New()

Callers

nothing calls this directly

Calls 4

internBytesMethod · 0.80
NewFunction · 0.70
CloseMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected