github.com/bingoohuang/gg@v0.0.0-20240325092523-45da7dee9335/pkg/jsoni/value_tests/ptr_test.go (about) 1 package test 2 3 func init() { 4 pInt := func(val int) *int { 5 return &val 6 } 7 marshalCases = append(marshalCases, 8 (*int)(nil), 9 pInt(100), 10 ) 11 unmarshalCases = append(unmarshalCases, unmarshalCase{ 12 obj: func() interface{} { 13 var i int 14 return &i 15 }, 16 input: "null", 17 }, unmarshalCase{ 18 obj: func() interface{} { 19 var i *int 20 return &i 21 }, 22 input: "10", 23 }, unmarshalCase{ 24 obj: func() interface{} { 25 var i int 26 pi := &i 27 return &pi 28 }, 29 input: "null", 30 }) 31 }