|
@@ -264,3 +264,41 @@ func TestParseMappingEntry(t *testing.T) {
|
264
|
264
|
}
|
265
|
265
|
}
|
266
|
266
|
}
|
|
267
|
+
|
|
268
|
+func TestParseGoCount(t *testing.T) {
|
|
269
|
+ for _, test := range []struct {
|
|
270
|
+ in string
|
|
271
|
+ typ string
|
|
272
|
+ }{
|
|
273
|
+ {
|
|
274
|
+ in: `# ignored comment
|
|
275
|
+
|
|
276
|
+threadcreate profile: total 123
|
|
277
|
+`,
|
|
278
|
+ typ: "threadcreate",
|
|
279
|
+ },
|
|
280
|
+ {
|
|
281
|
+ in: `
|
|
282
|
+# ignored comment
|
|
283
|
+goroutine profile: total 123456
|
|
284
|
+`,
|
|
285
|
+ typ: "goroutine",
|
|
286
|
+ },
|
|
287
|
+ {
|
|
288
|
+ in: `
|
|
289
|
+sub/dir-ect_o.ry profile: total 999
|
|
290
|
+`,
|
|
291
|
+ typ: "sub/dir-ect_o.ry",
|
|
292
|
+ },
|
|
293
|
+ } {
|
|
294
|
+ t.Run(test.typ, func(t *testing.T) {
|
|
295
|
+ p, err := parseGoCount([]byte(test.in))
|
|
296
|
+ if err != nil {
|
|
297
|
+ t.Fatalf("parseGoCount(%q) = %v", test.in, err)
|
|
298
|
+ }
|
|
299
|
+ if typ := p.PeriodType.Type; typ != test.typ {
|
|
300
|
+ t.Fatalf("parseGoCount(%q).PeriodType.Type = %q want %q", test.in, typ, test.typ)
|
|
301
|
+ }
|
|
302
|
+ })
|
|
303
|
+ }
|
|
304
|
+}
|