Skip to content

Commit f485302

Browse files
committed
ensure pointer value
1 parent ca3e7d6 commit f485302

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

decode_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,9 @@ func TestDecodeNoContext(t *testing.T) {
148148

149149
func TestDecodePointerField(t *testing.T) {
150150
type SData struct {
151-
Val string `instruct:"header"`
152-
IntVal *int32 `instruct:"header"`
151+
Val string `instruct:"header"`
152+
IntVal *int32 `instruct:"header"`
153+
IntVal2 **int64 `instruct:"header"`
153154
}
154155

155156
type DataType struct {
@@ -163,6 +164,7 @@ func TestDecodePointerField(t *testing.T) {
163164
r := httptest.NewRequest(http.MethodPost, "/", nil)
164165
r.Header.Set("val", "x1")
165166
r.Header.Set("intval", "92")
167+
r.Header.Set("intval2", "799")
166168

167169
var data DataType
168170

@@ -177,10 +179,13 @@ func TestDecodePointerField(t *testing.T) {
177179
require.Equal(t, int32(92), *data.IntVal)
178180
require.Equal(t, "x1", data.S.Val)
179181
require.Equal(t, int32(92), *data.S.IntVal)
182+
require.Equal(t, int64(799), **data.S.IntVal2)
180183
require.Equal(t, "x1", (*data.S2).Val)
181184
require.Equal(t, int32(92), *(*data.S2).IntVal)
185+
require.Equal(t, int64(799), **(*data.S2).IntVal2)
182186
require.Equal(t, "x1", (**data.S3).Val)
183187
require.Equal(t, int32(92), *(**data.S3).IntVal)
188+
require.Equal(t, int64(799), **(**data.S3).IntVal2)
184189
}
185190

186191
func TestDecodePointerPointerField(t *testing.T) {

0 commit comments

Comments
 (0)