MCPcopy Create free account
hub / github.com/chain/txvm / TestWriteRawStack

Function TestWriteRawStack

log/log_test.go:331–354  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

329}
330
331func 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
356func TestFormatKey(t *testing.T) {
357 examples := []struct {

Callers

nothing calls this directly

Calls 3

writeRawStackFunction · 0.85
ContainsMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected