(t *testing.T)
| 329 | } |
| 330 | |
| 331 | func TestWriteRawStack(t *testing.T) { |
| 332 | pc := make([]uintptr, 10) |
| 333 | n := runtime.Callers(1, pc) |
| 334 | if n < 2 { |
| 335 | t.Fatalf("runtime.Callers failed") |
| 336 | } |
| 337 | |
| 338 | cases := []struct { |
| 339 | v interface{} |
| 340 | w string |
| 341 | }{ |
| 342 | {[]byte("foo\nbar"), "foo\nbar\n"}, |
| 343 | {runtime.CallersFrames(pc[:2]), "/log.TestWriteRawStack\n"}, |
| 344 | {1, ""}, // int is not a valid stack val |
| 345 | } |
| 346 | |
| 347 | for _, test := range cases { |
| 348 | var buf bytes.Buffer |
| 349 | writeRawStack(&buf, test.v) |
| 350 | if g := buf.String(); !strings.Contains(g, test.w) { |
| 351 | t.Errorf("writeRawStack(%#v) = %q, must contain %q", test.v, g, test.w) |
| 352 | } |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | func TestFormatKey(t *testing.T) { |
| 357 | examples := []struct { |
nothing calls this directly
no test coverage detected