ptr_test.go 486 B

12345678910111213141516171819202122232425262728293031
  1. package test
  2. func init() {
  3. var pInt = func(val int) *int {
  4. return &val
  5. }
  6. marshalCases = append(marshalCases,
  7. (*int)(nil),
  8. pInt(100),
  9. )
  10. unmarshalCases = append(unmarshalCases, unmarshalCase{
  11. obj: func() interface{} {
  12. var i int
  13. return &i
  14. },
  15. input: "null",
  16. }, unmarshalCase{
  17. obj: func() interface{} {
  18. var i *int
  19. return &i
  20. },
  21. input: "10",
  22. }, unmarshalCase{
  23. obj: func() interface{} {
  24. var i int
  25. pi := &i
  26. return &pi
  27. },
  28. input: "null",
  29. })
  30. }