(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func 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 | |
| 30 | func TestInterner_UnsafeClone(t *testing.T) { |
| 31 | i := New() |
nothing calls this directly
no test coverage detected