summaryrefslogtreecommitdiffstats
path: root/dependencies/pkg/mod/github.com/pkg/errors@v0.9.1/json_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'dependencies/pkg/mod/github.com/pkg/errors@v0.9.1/json_test.go')
-rw-r--r--dependencies/pkg/mod/github.com/pkg/errors@v0.9.1/json_test.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/dependencies/pkg/mod/github.com/pkg/errors@v0.9.1/json_test.go b/dependencies/pkg/mod/github.com/pkg/errors@v0.9.1/json_test.go
new file mode 100644
index 0000000..ad1adec
--- /dev/null
+++ b/dependencies/pkg/mod/github.com/pkg/errors@v0.9.1/json_test.go
@@ -0,0 +1,51 @@
+package errors
+
+import (
+ "encoding/json"
+ "regexp"
+ "testing"
+)
+
+func TestFrameMarshalText(t *testing.T) {
+ var tests = []struct {
+ Frame
+ want string
+ }{{
+ initpc,
+ `^github.com/pkg/errors\.init(\.ializers)? .+/github\.com/pkg/errors/stack_test.go:\d+$`,
+ }, {
+ 0,
+ `^unknown$`,
+ }}
+ for i, tt := range tests {
+ got, err := tt.Frame.MarshalText()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !regexp.MustCompile(tt.want).Match(got) {
+ t.Errorf("test %d: MarshalJSON:\n got %q\n want %q", i+1, string(got), tt.want)
+ }
+ }
+}
+
+func TestFrameMarshalJSON(t *testing.T) {
+ var tests = []struct {
+ Frame
+ want string
+ }{{
+ initpc,
+ `^"github\.com/pkg/errors\.init(\.ializers)? .+/github\.com/pkg/errors/stack_test.go:\d+"$`,
+ }, {
+ 0,
+ `^"unknown"$`,
+ }}
+ for i, tt := range tests {
+ got, err := json.Marshal(tt.Frame)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !regexp.MustCompile(tt.want).Match(got) {
+ t.Errorf("test %d: MarshalJSON:\n got %q\n want %q", i+1, string(got), tt.want)
+ }
+ }
+}