slice_test.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. package test
  2. func init() {
  3. testCases = append(testCases,
  4. (*[][4]bool)(nil),
  5. (*[][4]byte)(nil),
  6. (*[][4]float64)(nil),
  7. (*[][4]int32)(nil),
  8. (*[][4]*string)(nil),
  9. (*[][4]string)(nil),
  10. (*[][4]uint8)(nil),
  11. (*[]bool)(nil),
  12. (*[]byte)(nil),
  13. (*[]float64)(nil),
  14. (*[]int32)(nil),
  15. (*[]int64)(nil),
  16. (*[]map[int32]string)(nil),
  17. (*[]map[string]string)(nil),
  18. (*[4]*[4]bool)(nil),
  19. (*[4]*[4]byte)(nil),
  20. (*[4]*[4]float64)(nil),
  21. (*[4]*[4]int32)(nil),
  22. (*[4]*[4]*string)(nil),
  23. (*[4]*[4]string)(nil),
  24. (*[4]*[4]uint8)(nil),
  25. (*[]*bool)(nil),
  26. (*[]*float64)(nil),
  27. (*[]*int32)(nil),
  28. (*[]*map[int32]string)(nil),
  29. (*[]*map[string]string)(nil),
  30. (*[]*[]bool)(nil),
  31. (*[]*[]byte)(nil),
  32. (*[]*[]float64)(nil),
  33. (*[]*[]int32)(nil),
  34. (*[]*[]*string)(nil),
  35. (*[]*[]string)(nil),
  36. (*[]*[]uint8)(nil),
  37. (*[]*string)(nil),
  38. (*[]*struct {
  39. String string
  40. Int int32
  41. Float float64
  42. Struct struct {
  43. X string
  44. }
  45. Slice []string
  46. Map map[string]string
  47. })(nil),
  48. (*[]*uint8)(nil),
  49. (*[][]bool)(nil),
  50. (*[][]byte)(nil),
  51. (*[][]float64)(nil),
  52. (*[][]int32)(nil),
  53. (*[][]*string)(nil),
  54. (*[][]string)(nil),
  55. (*[][]uint8)(nil),
  56. (*[]string)(nil),
  57. (*[]struct{})(nil),
  58. (*[]structEmpty)(nil),
  59. (*[]struct {
  60. F *string
  61. })(nil),
  62. (*[]struct {
  63. String string
  64. Int int32
  65. Float float64
  66. Struct struct {
  67. X string
  68. }
  69. Slice []string
  70. Map map[string]string
  71. })(nil),
  72. (*[]uint8)(nil),
  73. (*[]jsonMarshaler)(nil),
  74. (*[]jsonMarshalerMap)(nil),
  75. (*[]textMarshaler)(nil),
  76. (*[]textMarshalerMap)(nil),
  77. )
  78. }
  79. type jsonMarshaler struct {
  80. Id string `json:"id,omitempty" db:"id"`
  81. }
  82. func (p *jsonMarshaler) MarshalJSON() ([]byte, error) {
  83. return []byte(`{}`), nil
  84. }
  85. func (p *jsonMarshaler) UnmarshalJSON(input []byte) error {
  86. p.Id = "hello"
  87. return nil
  88. }
  89. type jsonMarshalerMap map[int]int
  90. func (p *jsonMarshalerMap) MarshalJSON() ([]byte, error) {
  91. return []byte(`{}`), nil
  92. }
  93. func (p *jsonMarshalerMap) UnmarshalJSON(input []byte) error {
  94. return nil
  95. }
  96. type textMarshaler struct {
  97. Id string `json:"id,omitempty" db:"id"`
  98. }
  99. func (p *textMarshaler) MarshalText() ([]byte, error) {
  100. return []byte(`{}`), nil
  101. }
  102. func (p *textMarshaler) UnmarshalText(input []byte) error {
  103. p.Id = "hello"
  104. return nil
  105. }
  106. type textMarshalerMap map[int]int
  107. func (p *textMarshalerMap) MarshalText() ([]byte, error) {
  108. return []byte(`{}`), nil
  109. }
  110. func (p *textMarshalerMap) UnmarshalText(input []byte) error {
  111. return nil
  112. }