-
Notifications
You must be signed in to change notification settings - Fork 1
/
error_test.go
36 lines (32 loc) · 1.1 KB
/
error_test.go
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
32
33
34
35
36
package lzjson_test
import (
"fmt"
"testing"
"github.com/go-restit/lzjson"
)
func TestParseError_GoString(t *testing.T) {
if want, have := "lzjson.ErrorUndefined", fmt.Sprintf("%#v", lzjson.ErrorUndefined); want != have {
t.Errorf("expected %#v, got %#v", want, have)
}
if want, have := "lzjson.ErrorNotObject", fmt.Sprintf("%#v", lzjson.ErrorNotObject); want != have {
t.Errorf("expected %#v, got %#v", want, have)
}
if want, have := "lzjson.ErrorNotArray", fmt.Sprintf("%#v", lzjson.ErrorNotArray); want != have {
t.Errorf("expected %#v, got %#v", want, have)
}
if want, have := "unknown parse error", lzjson.ParseError(-1).Error(); want != have {
t.Errorf("expected %#v, got %#v", want, have)
}
if want, have := "lzjson.ParseError(-1)", fmt.Sprintf("%#v", lzjson.ParseError(-1)); want != have {
t.Errorf("expected %#v, got %#v", want, have)
}
}
func TestError_String(t *testing.T) {
err := lzjson.Error{
Path: "hello",
Err: fmt.Errorf("some error msg"),
}
if want, have := "hello: some error msg", err.String(); want != have {
t.Errorf("\nexpected:\n%s\ngot:\n%s", want, have)
}
}