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

Function TestDiffBaseSample

profile/profile_test.go:1149–1200  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1147}
1148
1149func TestDiffBaseSample(t *testing.T) {
1150 var testcases = []struct {
1151 desc string
1152 labels map[string][]string
1153 wantDiffBaseSample bool
1154 }{
1155 {
1156 desc: "empty label does not have label",
1157 labels: map[string][]string{},
1158 wantDiffBaseSample: false,
1159 },
1160 {
1161 desc: "label with one key and value, including diff base label",
1162 labels: map[string][]string{"pprof::base": {"true"}},
1163 wantDiffBaseSample: true,
1164 },
1165 {
1166 desc: "label with one key and value, not including diff base label",
1167 labels: map[string][]string{"key": {"value"}},
1168 wantDiffBaseSample: false,
1169 },
1170 {
1171 desc: "label with many keys and values, including diff base label",
1172 labels: map[string][]string{
1173 "pprof::base": {"value2", "true"},
1174 "key2": {"true", "value2", "value2"},
1175 "key3": {"true", "value2", "value2"},
1176 },
1177 wantDiffBaseSample: true,
1178 },
1179 {
1180 desc: "label with many keys and values, not including diff base label",
1181 labels: map[string][]string{
1182 "key1": {"value2", "value1"},
1183 "key2": {"value1", "value2", "value2"},
1184 "key3": {"value1", "value2", "value2"},
1185 },
1186 wantDiffBaseSample: false,
1187 },
1188 }
1189
1190 for _, tc := range testcases {
1191 t.Run(tc.desc, func(t *testing.T) {
1192 sample := &Sample{
1193 Label: tc.labels,
1194 }
1195 if gotHasLabel := sample.DiffBaseSample(); gotHasLabel != tc.wantDiffBaseSample {
1196 t.Errorf("sample.DiffBaseSample() got %v, want %v", gotHasLabel, tc.wantDiffBaseSample)
1197 }
1198 })
1199 }
1200}
1201
1202func TestRemove(t *testing.T) {
1203 var testcases = []struct {

Callers

nothing calls this directly

Calls 1

DiffBaseSampleMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…