-
-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy patherror_test.go
More file actions
25 lines (19 loc) · 661 Bytes
/
error_test.go
File metadata and controls
25 lines (19 loc) · 661 Bytes
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
// Copyright (c) 2021, Peter Ohler, All rights reserved.
package ojg_test
import (
"strings"
"testing"
"github.com/ohler55/ojg"
"github.com/ohler55/ojg/tt"
)
func TestError(t *testing.T) {
err := ojg.NewError("some error")
tt.Equal(t, "some error", err.Error())
lines := strings.Split(string(err.Stack()), "\n")
tt.Equal(t, true, strings.Contains(lines[0], "goroutine"))
tt.Equal(t, true, strings.Contains(lines[len(lines)-2], "testing.go"))
ojg.ErrorWithStack = true
lines = strings.Split(err.Error(), "\n")
tt.Equal(t, true, strings.Contains(lines[0], "some error"))
tt.Equal(t, true, strings.Contains(lines[len(lines)-2], "testing.go"))
}