blob: 626d3148fa9ff1472f1fd133fbb96d5e33da3c98 (
plain)
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
|
package main
import (
"errors"
"testing"
)
func TestNewErrorwithSourceLocfMessage(t *testing.T) {
err := newErrorwithSourceLocf("a%sc", "b")
if err.Error() != "errors_test.go:9: abc" {
t.Errorf("Error message incorrect. Got: %s", err.Error())
}
}
func TestWrapErrorwithSourceLocfMessage(t *testing.T) {
cause := errors.New("someCause")
err := wrapErrorwithSourceLocf(cause, "a%sc", "b")
if err.Error() != "errors_test.go:17: abc: someCause" {
t.Errorf("Error message incorrect. Got: %s", err.Error())
}
}
func TestNewUserErrorf(t *testing.T) {
err := newUserErrorf("a%sc", "b")
if err.Error() != "abc" {
t.Errorf("Error message incorrect. Got: %s", err.Error())
}
}
|