| 31 | } |
| 32 | |
| 33 | func TestAs(t *testing.T) { |
| 34 | var errStrIn errorString = "TestForFun" |
| 35 | |
| 36 | var errStrOut errorString |
| 37 | if As(errStrIn, &errStrOut) { |
| 38 | if errStrOut != "TestForFun" { |
| 39 | t.Errorf("direct errStr value is not returned") |
| 40 | } |
| 41 | } else { |
| 42 | t.Errorf("direct errStr is not returned") |
| 43 | } |
| 44 | |
| 45 | errStrOut = "" |
| 46 | err := Wrap(errStrIn, 0) |
| 47 | if As(err, &errStrOut) { |
| 48 | if errStrOut != "TestForFun" { |
| 49 | t.Errorf("wrapped errStr value is not returned") |
| 50 | } |
| 51 | } else { |
| 52 | t.Errorf("wrapped errStr is not returned") |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | func TestStackFormat(t *testing.T) { |
| 57 | |