@@ -6,17 +6,29 @@ import (
6
6
"github.com/stretchr/testify/assert"
7
7
)
8
8
9
+ const anErrorStr = "assert.AnError general error for testing"
10
+
9
11
func TestDereferencePointers (t * testing.T ) {
10
12
is := assert .New (t )
11
13
12
14
ptr := func (v string ) * string { return & v }
13
15
14
- err := With ("hello" , "world" ).Errorf (assert . AnError . Error () ).(OopsError ) //nolint:govet
16
+ err := With ("hello" , "world" ).Errorf (anErrorStr ).(OopsError ) //nolint:govet
15
17
is .EqualValues (map [string ]any {"hello" : "world" }, err .Context ())
16
18
17
- err = With ("hello" , ptr ("world" )).Errorf (assert . AnError . Error () ).(OopsError ) //nolint:govet
19
+ err = With ("hello" , ptr ("world" )).Errorf (anErrorStr ).(OopsError ) //nolint:govet
18
20
is .EqualValues (map [string ]any {"hello" : "world" }, err .Context ())
19
21
20
- err = With ("hello" , nil ).Errorf (assert .AnError .Error ()).(OopsError ) //nolint:govet
22
+ err = With ("hello" , nil ).Errorf (anErrorStr ).(OopsError ) //nolint:govet
23
+ is .EqualValues (map [string ]any {"hello" : nil }, err .Context ())
24
+
25
+ err = With ("hello" , (* int )(nil )).Errorf (anErrorStr ).(OopsError ) //nolint:govet
26
+ is .EqualValues (map [string ]any {"hello" : nil }, err .Context ())
27
+
28
+ err = With ("hello" , (* * * int )(nil )).Errorf (anErrorStr ).(OopsError ) //nolint:govet
29
+ is .EqualValues (map [string ]any {"hello" : nil }, err .Context ())
30
+
31
+ var i * * int
32
+ err = With ("hello" , (* * * int )(& i )).Errorf (anErrorStr ).(OopsError ) //nolint:govet
21
33
is .EqualValues (map [string ]any {"hello" : nil }, err .Context ())
22
34
}
0 commit comments