-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathkv_test.go
34 lines (23 loc) · 1.09 KB
/
kv_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
package oops
import (
"testing"
"github.com/stretchr/testify/assert"
)
const anErrorStr = "assert.AnError general error for testing"
func TestDereferencePointers(t *testing.T) {
is := assert.New(t)
ptr := func(v string) *string { return &v }
err := With("hello", "world").Errorf(anErrorStr).(OopsError) //nolint:govet
is.EqualValues(map[string]any{"hello": "world"}, err.Context())
err = With("hello", ptr("world")).Errorf(anErrorStr).(OopsError) //nolint:govet
is.EqualValues(map[string]any{"hello": "world"}, err.Context())
err = With("hello", nil).Errorf(anErrorStr).(OopsError) //nolint:govet
is.EqualValues(map[string]any{"hello": nil}, err.Context())
err = With("hello", (*int)(nil)).Errorf(anErrorStr).(OopsError) //nolint:govet
is.EqualValues(map[string]any{"hello": nil}, err.Context())
err = With("hello", (***int)(nil)).Errorf(anErrorStr).(OopsError) //nolint:govet
is.EqualValues(map[string]any{"hello": nil}, err.Context())
var i **int
err = With("hello", (***int)(&i)).Errorf(anErrorStr).(OopsError) //nolint:govet
is.EqualValues(map[string]any{"hello": nil}, err.Context())
}