MCPcopy Create free account
hub / github.com/google/pprof / TestFunctionMap

Function TestFunctionMap

internal/report/report_test.go:342–371  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

340}
341
342func TestFunctionMap(t *testing.T) {
343
344 fm := make(functionMap)
345 nodes := []graph.NodeInfo{
346 {Name: "fun1"},
347 {Name: "fun2", File: "filename"},
348 {Name: "fun1"},
349 {Name: "fun2", File: "filename2"},
350 }
351
352 want := []struct {
353 wantFunction profile.Function
354 wantAdded bool
355 }{
356 {profile.Function{ID: 1, Name: "fun1"}, true},
357 {profile.Function{ID: 2, Name: "fun2", Filename: "filename"}, true},
358 {profile.Function{ID: 1, Name: "fun1"}, false},
359 {profile.Function{ID: 3, Name: "fun2", Filename: "filename2"}, true},
360 }
361
362 for i, tc := range nodes {
363 gotFunc, gotAdded := fm.findOrAdd(tc)
364 if got, want := gotFunc, want[i].wantFunction; *got != want {
365 t.Errorf("%d: got %v, want %v", i, got, want)
366 }
367 if got, want := gotAdded, want[i].wantAdded; got != want {
368 t.Errorf("%d: got %v, want %v", i, got, want)
369 }
370 }
371}
372
373func TestLegendActiveFilters(t *testing.T) {
374 activeFilterInput := []string{

Callers

nothing calls this directly

Calls 1

findOrAddMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…