callerName gives the function name (qualified with a package path) for the caller after skip frames (where 0 means the current function).
(skip int)
| 115 | // callerName gives the function name (qualified with a package path) |
| 116 | // for the caller after skip frames (where 0 means the current function). |
| 117 | func callerName(skip int) string { |
| 118 | // Make room for the skip PC. |
| 119 | var pc [1]uintptr |
| 120 | n := runtime.Callers(skip+2, pc[:]) // skip + runtime.Callers + callerName |
| 121 | if n == 0 { |
| 122 | panic("testing: zero callers found") |
| 123 | } |
| 124 | frames := runtime.CallersFrames(pc[:n]) |
| 125 | frame, _ := frames.Next() |
| 126 | return frame.Function |
| 127 | } |
| 128 | |
| 129 | func TestGreater(t *testing.T) { |
| 130 | mockT := new(testing.T) |