MCPcopy Create free account
hub / github.com/pingcap/tidb / TestMemoizeStr

Function TestMemoizeStr

pkg/util/stringutil/string_util_test.go:209–219  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

207}
208
209func TestMemoizeStr(t *testing.T) {
210 cnt := 0
211 slowStringFn := func() string {
212 cnt++
213 return "slow"
214 }
215 stringer := MemoizeStr(slowStringFn)
216 require.Equal(t, "slow", stringer.String())
217 require.Equal(t, "slow", stringer.String())
218 require.Equal(t, 1, cnt)
219}
220
221func BenchmarkDoMatch(b *testing.B) {
222 escape := byte('\\')

Callers

nothing calls this directly

Calls 3

MemoizeStrFunction · 0.85
EqualMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…