1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
// Copyright 2013, 2014 Canonical Ltd.
// Licensed under the LGPLv3, see LICENCE file for details.
package errors_test
import (
"fmt"
"runtime"
"testing"
gc "gopkg.in/check.v1"
)
func Test(t *testing.T) {
gc.TestingT(t)
}
// errorLocationValue provides the function name and line number for where this
// function was called from - 1 line. What this means is that the returned value
// will be homed to the file line directly above where this function was called.
// This is a utility for testing error details and that associated error calls
// set the error location correctly.
func errorLocationValue(c *gc.C) string {
rpc := make([]uintptr, 1)
n := runtime.Callers(2, rpc[:])
if n < 1 {
return ""
}
frame, _ := runtime.CallersFrames(rpc).Next()
return fmt.Sprintf("%s:%d", frame.Function, frame.Line-1)
}
|