(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func TestStackTrace(t *testing.T) { |
| 16 | const testMsg = "test error" |
| 17 | er := New(testMsg) |
| 18 | |
| 19 | if er.GetMessage() != testMsg { |
| 20 | t.Errorf("error message %s != expected %s", er.GetMessage(), testMsg) |
| 21 | } |
| 22 | |
| 23 | if strings.Index(er.GetStack(), "github.com/dropbox/godropbox/errors/errors.go") != -1 { |
| 24 | t.Error("stack trace generation code should not be in the error stack trace") |
| 25 | } |
| 26 | |
| 27 | if strings.Index(er.GetStack(), "TestStackTrace") == -1 { |
| 28 | t.Error("stack trace must have test code in it") |
| 29 | } |
| 30 | |
| 31 | for i, r := range er.GetStack() { |
| 32 | if !(unicode.IsSpace(r) || unicode.IsPrint(r)) { |
| 33 | t.Errorf("stack trace has an unexpected rune at index %v (%q)", i, r) |
| 34 | break |
| 35 | } |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | func TestWrappedError(t *testing.T) { |
| 40 | const ( |
nothing calls this directly
no test coverage detected