github.com/grbit/go-json@v0.11.0/test/cover/cover_slice_test.go (about)

     1  package json_test
     2  
     3  import (
     4  	"bytes"
     5  	"fmt"
     6  	"testing"
     7  
     8  	"github.com/grbit/go-json"
     9  )
    10  
    11  type coverSliceMarshalJSON struct {
    12  	A int
    13  }
    14  
    15  func (coverSliceMarshalJSON) MarshalJSON() ([]byte, error) {
    16  	return []byte(`"hello"`), nil
    17  }
    18  
    19  type coverSliceMarshalText struct {
    20  	A int
    21  }
    22  
    23  func (coverSliceMarshalText) MarshalText() ([]byte, error) {
    24  	return []byte(`"hello"`), nil
    25  }
    26  
    27  type recursiveSlice struct {
    28  	A int
    29  	B []*recursiveSlice
    30  }
    31  
    32  func TestCoverSlice(t *testing.T) {
    33  	type structSlice struct {
    34  		A []int `json:"a"`
    35  	}
    36  	type structSliceOmitEmpty struct {
    37  		A []int `json:"a,omitempty"`
    38  	}
    39  	type structSliceString struct {
    40  		A []int `json:"a,string"`
    41  	}
    42  	type structSlicePtr struct {
    43  		A *[]int `json:"a"`
    44  	}
    45  	type structSlicePtrOmitEmpty struct {
    46  		A *[]int `json:"a,omitempty"`
    47  	}
    48  	type structSlicePtrString struct {
    49  		A *[]int `json:"a,string"`
    50  	}
    51  
    52  	type structSlicePtrContent struct {
    53  		A []*int `json:"a"`
    54  	}
    55  	type structSliceOmitEmptyPtrContent struct {
    56  		A []*int `json:"a,omitempty"`
    57  	}
    58  	type structSliceStringPtrContent struct {
    59  		A []*int `json:"a,string"`
    60  	}
    61  	type structSlicePtrPtrContent struct {
    62  		A *[]*int `json:"a"`
    63  	}
    64  	type structSlicePtrOmitEmptyPtrContent struct {
    65  		A *[]*int `json:"a,omitempty"`
    66  	}
    67  	type structSlicePtrStringPtrContent struct {
    68  		A *[]*int `json:"a,string"`
    69  	}
    70  
    71  	tests := []struct {
    72  		name string
    73  		data interface{}
    74  	}{
    75  		{
    76  			name: "SliceInt",
    77  			data: []int{1, 2, 3},
    78  		},
    79  		{
    80  			name: "SliceInt8",
    81  			data: []int8{1, 2, 3},
    82  		},
    83  		{
    84  			name: "SliceInt16",
    85  			data: []int16{1, 2, 3},
    86  		},
    87  		{
    88  			name: "SliceInt32",
    89  			data: []int32{1, 2, 3},
    90  		},
    91  		{
    92  			name: "SliceInt64",
    93  			data: []int64{1, 2, 3},
    94  		},
    95  		{
    96  			name: "SliceUint",
    97  			data: []uint{1, 2, 3},
    98  		},
    99  		{
   100  			name: "SliceUint8",
   101  			data: []uint8{1, 2, 3},
   102  		},
   103  		{
   104  			name: "SliceUint16",
   105  			data: []uint16{1, 2, 3},
   106  		},
   107  		{
   108  			name: "SliceUint32",
   109  			data: []uint32{1, 2, 3},
   110  		},
   111  		{
   112  			name: "SliceUint64",
   113  			data: []uint64{1, 2, 3},
   114  		},
   115  		{
   116  			name: "SliceFloat32",
   117  			data: []float32{1, 2, 3},
   118  		},
   119  		{
   120  			name: "SliceFloat64",
   121  			data: []float64{1, 2, 3},
   122  		},
   123  		{
   124  			name: "SliceString",
   125  			data: []string{"a", "b"},
   126  		},
   127  		{
   128  			name: "SliceBool",
   129  			data: []bool{false, true, false},
   130  		},
   131  		{
   132  			name: "SliceBytes",
   133  			data: [][]byte{[]byte("a"), []byte("b"), nil, []byte("c")},
   134  		},
   135  		{
   136  			name: "SliceSlice",
   137  			data: [][]int{[]int{1, 2, 3}, nil, []int{4, 5, 6}},
   138  		},
   139  		{
   140  			name: "SliceArray",
   141  			data: [][3]int{[3]int{1, 2, 3}, [3]int{4, 5, 6}},
   142  		},
   143  		{
   144  			name: "SliceMap",
   145  			data: []map[string]int{map[string]int{"a": 1}, nil, map[string]int{"b": 2}},
   146  		},
   147  		{
   148  			name: "SliceStruct",
   149  			data: []struct{ A int }{struct{ A int }{A: 1}, struct{ A int }{A: 2}},
   150  		},
   151  		{
   152  			name: "SliceMarshalJSON",
   153  			data: []coverSliceMarshalJSON{{A: 1}, {A: 2}},
   154  		},
   155  		{
   156  			name: "SliceMarshalText",
   157  			data: []coverSliceMarshalText{{A: 1}, {A: 2}},
   158  		},
   159  		{
   160  			name: "SliceIntPtr",
   161  			data: []*int{intptr(1), intptr(2), nil, intptr(3)},
   162  		},
   163  		{
   164  			name: "SliceInt8Ptr",
   165  			data: []*int8{int8ptr(1), int8ptr(2), nil, int8ptr(3)},
   166  		},
   167  		{
   168  			name: "SliceInt16Ptr",
   169  			data: []*int16{int16ptr(1), int16ptr(2), nil, int16ptr(3)},
   170  		},
   171  		{
   172  			name: "SliceInt32Ptr",
   173  			data: []*int32{int32ptr(1), int32ptr(2), nil, int32ptr(3)},
   174  		},
   175  		{
   176  			name: "SliceInt64Ptr",
   177  			data: []*int64{int64ptr(1), int64ptr(2), nil, int64ptr(3)},
   178  		},
   179  		{
   180  			name: "SliceUintPtr",
   181  			data: []*uint{uptr(1), uptr(2), nil, uptr(3)},
   182  		},
   183  		{
   184  			name: "SliceUint8Ptr",
   185  			data: []*uint8{uint8ptr(1), uint8ptr(2), nil, uint8ptr(3)},
   186  		},
   187  		{
   188  			name: "SliceUint16Ptr",
   189  			data: []*uint16{uint16ptr(1), uint16ptr(2), nil, uint16ptr(3)},
   190  		},
   191  		{
   192  			name: "SliceUint32Ptr",
   193  			data: []*uint32{uint32ptr(1), uint32ptr(2), nil, uint32ptr(3)},
   194  		},
   195  		{
   196  			name: "SliceUint64Ptr",
   197  			data: []*uint64{uint64ptr(1), uint64ptr(2), nil, uint64ptr(3)},
   198  		},
   199  		{
   200  			name: "SliceFloat32Ptr",
   201  			data: []*float32{float32ptr(1), float32ptr(2), nil, float32ptr(3)},
   202  		},
   203  		{
   204  			name: "SliceFloat64Ptr",
   205  			data: []*float64{float64ptr(1), float64ptr(2), nil, float64ptr(3)},
   206  		},
   207  		{
   208  			name: "SliceStringPtr",
   209  			data: []*string{stringptr("a"), nil, stringptr("b")},
   210  		},
   211  		{
   212  			name: "SliceBoolPtr",
   213  			data: []*bool{boolptr(false), boolptr(true), nil, boolptr(false)},
   214  		},
   215  		{
   216  			name: "SliceBytesPtr",
   217  			data: []*[]byte{bytesptr([]byte("a")), bytesptr([]byte("b")), nil, bytesptr([]byte("c"))},
   218  		},
   219  		{
   220  			name: "SliceSlicePtr",
   221  			data: []*[]int{sliceptr([]int{1, 2, 3}), nil, sliceptr([]int{4, 5, 6})},
   222  		},
   223  		{
   224  			name: "SliceArrayPtr",
   225  			data: []*[2]int{arrayptr([2]int{1, 2}), nil, arrayptr([2]int{4, 5})},
   226  		},
   227  		{
   228  			name: "SliceMapPtr",
   229  			data: []*map[string]int{mapptr(map[string]int{"a": 1}), nil, mapptr(map[string]int{"b": 2})},
   230  		},
   231  		{
   232  			name: "SliceStructPtr",
   233  			data: []*struct{ A int }{&struct{ A int }{A: 1}, &struct{ A int }{A: 2}},
   234  		},
   235  		{
   236  			name: "RecursiveSlice",
   237  			data: []*recursiveSlice{
   238  				{
   239  					A: 1, B: []*recursiveSlice{
   240  						{
   241  							A: 2, B: []*recursiveSlice{
   242  								{
   243  									A: 3,
   244  								},
   245  							},
   246  						},
   247  					},
   248  				},
   249  				{
   250  					A: 4, B: []*recursiveSlice{
   251  						{
   252  							A: 5, B: []*recursiveSlice{
   253  								{
   254  									A: 6,
   255  								},
   256  							},
   257  						},
   258  					},
   259  				},
   260  			},
   261  		},
   262  
   263  		// HeadSliceZero
   264  		{
   265  			name: "HeadSliceZero",
   266  			data: struct {
   267  				A []int `json:"a"`
   268  			}{},
   269  		},
   270  		{
   271  			name: "HeadSliceZeroOmitEmpty",
   272  			data: struct {
   273  				A []int `json:"a,omitempty"`
   274  			}{},
   275  		},
   276  		{
   277  			name: "HeadSliceZeroString",
   278  			data: struct {
   279  				A []int `json:"a,string"`
   280  			}{},
   281  		},
   282  
   283  		// HeadSlice
   284  		{
   285  			name: "HeadSlice",
   286  			data: struct {
   287  				A []int `json:"a"`
   288  			}{A: []int{-1}},
   289  		},
   290  		{
   291  			name: "HeadSliceOmitEmpty",
   292  			data: struct {
   293  				A []int `json:"a,omitempty"`
   294  			}{A: []int{-1}},
   295  		},
   296  		{
   297  			name: "HeadSliceString",
   298  			data: struct {
   299  				A []int `json:"a,string"`
   300  			}{A: []int{-1}},
   301  		},
   302  
   303  		// HeadSlicePtr
   304  		{
   305  			name: "HeadSlicePtr",
   306  			data: struct {
   307  				A *[]int `json:"a"`
   308  			}{A: sliceptr([]int{-1})},
   309  		},
   310  		{
   311  			name: "HeadSlicePtrOmitEmpty",
   312  			data: struct {
   313  				A *[]int `json:"a,omitempty"`
   314  			}{A: sliceptr([]int{-1})},
   315  		},
   316  		{
   317  			name: "HeadSlicePtrString",
   318  			data: struct {
   319  				A *[]int `json:"a,string"`
   320  			}{A: sliceptr([]int{-1})},
   321  		},
   322  
   323  		// HeadSlicePtrNil
   324  		{
   325  			name: "HeadSlicePtrNil",
   326  			data: struct {
   327  				A *[]int `json:"a"`
   328  			}{A: nil},
   329  		},
   330  		{
   331  			name: "HeadSlicePtrNilOmitEmpty",
   332  			data: struct {
   333  				A *[]int `json:"a,omitempty"`
   334  			}{A: nil},
   335  		},
   336  		{
   337  			name: "HeadSlicePtrNilString",
   338  			data: struct {
   339  				A *[]int `json:"a,string"`
   340  			}{A: nil},
   341  		},
   342  
   343  		// PtrHeadSliceZero
   344  		{
   345  			name: "PtrHeadSliceZero",
   346  			data: &struct {
   347  				A []int `json:"a"`
   348  			}{},
   349  		},
   350  		{
   351  			name: "PtrHeadSliceZeroOmitEmpty",
   352  			data: &struct {
   353  				A []int `json:"a,omitempty"`
   354  			}{},
   355  		},
   356  		{
   357  			name: "PtrHeadSliceZeroString",
   358  			data: &struct {
   359  				A []int `json:"a,string"`
   360  			}{},
   361  		},
   362  
   363  		// PtrHeadSlice
   364  		{
   365  			name: "PtrHeadSlice",
   366  			data: &struct {
   367  				A []int `json:"a"`
   368  			}{A: []int{-1}},
   369  		},
   370  		{
   371  			name: "PtrHeadSliceOmitEmpty",
   372  			data: &struct {
   373  				A []int `json:"a,omitempty"`
   374  			}{A: []int{-1}},
   375  		},
   376  		{
   377  			name: "PtrHeadSliceString",
   378  			data: &struct {
   379  				A []int `json:"a,string"`
   380  			}{A: []int{-1}},
   381  		},
   382  
   383  		// PtrHeadSlicePtr
   384  		{
   385  			name: "PtrHeadSlicePtr",
   386  			data: &struct {
   387  				A *[]int `json:"a"`
   388  			}{A: sliceptr([]int{-1})},
   389  		},
   390  		{
   391  			name: "PtrHeadSlicePtrOmitEmpty",
   392  			data: &struct {
   393  				A *[]int `json:"a,omitempty"`
   394  			}{A: sliceptr([]int{-1})},
   395  		},
   396  		{
   397  			name: "PtrHeadSlicePtrString",
   398  			data: &struct {
   399  				A *[]int `json:"a,string"`
   400  			}{A: sliceptr([]int{-1})},
   401  		},
   402  
   403  		// PtrHeadSlicePtrNil
   404  		{
   405  			name: "PtrHeadSlicePtrNil",
   406  			data: &struct {
   407  				A *[]int `json:"a"`
   408  			}{A: nil},
   409  		},
   410  		{
   411  			name: "PtrHeadSlicePtrNilOmitEmpty",
   412  			data: &struct {
   413  				A *[]int `json:"a,omitempty"`
   414  			}{A: nil},
   415  		},
   416  		{
   417  			name: "PtrHeadSlicePtrNilString",
   418  			data: &struct {
   419  				A *[]int `json:"a,string"`
   420  			}{A: nil},
   421  		},
   422  
   423  		// PtrHeadSliceNil
   424  		{
   425  			name: "PtrHeadSliceNil",
   426  			data: (*struct {
   427  				A *[]int `json:"a"`
   428  			})(nil),
   429  		},
   430  		{
   431  			name: "PtrHeadSliceNilOmitEmpty",
   432  			data: (*struct {
   433  				A *[]int `json:"a,omitempty"`
   434  			})(nil),
   435  		},
   436  		{
   437  			name: "PtrHeadSliceNilString",
   438  			data: (*struct {
   439  				A *[]int `json:"a,string"`
   440  			})(nil),
   441  		},
   442  
   443  		// HeadSliceZeroMultiFields
   444  		{
   445  			name: "HeadSliceZeroMultiFields",
   446  			data: struct {
   447  				A []int `json:"a"`
   448  				B []int `json:"b"`
   449  				C []int `json:"c"`
   450  			}{},
   451  		},
   452  		{
   453  			name: "HeadSliceZeroMultiFieldsOmitEmpty",
   454  			data: struct {
   455  				A []int `json:"a,omitempty"`
   456  				B []int `json:"b,omitempty"`
   457  				C []int `json:"c,omitempty"`
   458  			}{},
   459  		},
   460  		{
   461  			name: "HeadSliceZeroMultiFields",
   462  			data: struct {
   463  				A []int `json:"a,string"`
   464  				B []int `json:"b,string"`
   465  				C []int `json:"c,string"`
   466  			}{},
   467  		},
   468  
   469  		// HeadSliceMultiFields
   470  		{
   471  			name: "HeadSliceMultiFields",
   472  			data: struct {
   473  				A []int `json:"a"`
   474  				B []int `json:"b"`
   475  				C []int `json:"c"`
   476  			}{A: []int{-1}, B: []int{-2}, C: []int{-3}},
   477  		},
   478  		{
   479  			name: "HeadSliceMultiFieldsOmitEmpty",
   480  			data: struct {
   481  				A []int `json:"a,omitempty"`
   482  				B []int `json:"b,omitempty"`
   483  				C []int `json:"c,omitempty"`
   484  			}{A: []int{-1}, B: []int{-2}, C: []int{-3}},
   485  		},
   486  		{
   487  			name: "HeadSliceMultiFieldsString",
   488  			data: struct {
   489  				A []int `json:"a,string"`
   490  				B []int `json:"b,string"`
   491  				C []int `json:"c,string"`
   492  			}{A: []int{-1}, B: []int{-2}, C: []int{-3}},
   493  		},
   494  
   495  		// HeadSlicePtrMultiFields
   496  		{
   497  			name: "HeadSlicePtrMultiFields",
   498  			data: struct {
   499  				A *[]int `json:"a"`
   500  				B *[]int `json:"b"`
   501  				C *[]int `json:"c"`
   502  			}{A: sliceptr([]int{-1}), B: sliceptr([]int{-2}), C: sliceptr([]int{-3})},
   503  		},
   504  		{
   505  			name: "HeadSlicePtrMultiFieldsOmitEmpty",
   506  			data: struct {
   507  				A *[]int `json:"a,omitempty"`
   508  				B *[]int `json:"b,omitempty"`
   509  				C *[]int `json:"c,omitempty"`
   510  			}{A: sliceptr([]int{-1}), B: sliceptr([]int{-2}), C: sliceptr([]int{-3})},
   511  		},
   512  		{
   513  			name: "HeadSlicePtrMultiFieldsString",
   514  			data: struct {
   515  				A *[]int `json:"a,string"`
   516  				B *[]int `json:"b,string"`
   517  				C *[]int `json:"c,string"`
   518  			}{A: sliceptr([]int{-1}), B: sliceptr([]int{-2}), C: sliceptr([]int{-3})},
   519  		},
   520  
   521  		// HeadSlicePtrNilMultiFields
   522  		{
   523  			name: "HeadSlicePtrNilMultiFields",
   524  			data: struct {
   525  				A *[]int `json:"a"`
   526  				B *[]int `json:"b"`
   527  				C *[]int `json:"c"`
   528  			}{A: nil, B: nil, C: nil},
   529  		},
   530  		{
   531  			name: "HeadSlicePtrNilMultiFieldsOmitEmpty",
   532  			data: struct {
   533  				A *[]int `json:"a,omitempty"`
   534  				B *[]int `json:"b,omitempty"`
   535  				C *[]int `json:"c,omitempty"`
   536  			}{A: nil, B: nil, C: nil},
   537  		},
   538  		{
   539  			name: "HeadSlicePtrNilMultiFieldsString",
   540  			data: struct {
   541  				A *[]int `json:"a,string"`
   542  				B *[]int `json:"b,string"`
   543  				C *[]int `json:"c,string"`
   544  			}{A: nil, B: nil, C: nil},
   545  		},
   546  
   547  		// PtrHeadSliceZeroMultiFields
   548  		{
   549  			name: "PtrHeadSliceZeroMultiFields",
   550  			data: &struct {
   551  				A []int `json:"a"`
   552  				B []int `json:"b"`
   553  			}{},
   554  		},
   555  		{
   556  			name: "PtrHeadSliceZeroMultiFieldsOmitEmpty",
   557  			data: &struct {
   558  				A []int `json:"a,omitempty"`
   559  				B []int `json:"b,omitempty"`
   560  			}{},
   561  		},
   562  		{
   563  			name: "PtrHeadSliceZeroMultiFieldsString",
   564  			data: &struct {
   565  				A []int `json:"a,string"`
   566  				B []int `json:"b,string"`
   567  			}{},
   568  		},
   569  
   570  		// PtrHeadSliceMultiFields
   571  		{
   572  			name: "PtrHeadSliceMultiFields",
   573  			data: &struct {
   574  				A []int `json:"a"`
   575  				B []int `json:"b"`
   576  			}{A: []int{-1}, B: nil},
   577  		},
   578  		{
   579  			name: "PtrHeadSliceMultiFieldsOmitEmpty",
   580  			data: &struct {
   581  				A []int `json:"a,omitempty"`
   582  				B []int `json:"b,omitempty"`
   583  			}{A: []int{-1}, B: nil},
   584  		},
   585  		{
   586  			name: "PtrHeadSliceMultiFieldsString",
   587  			data: &struct {
   588  				A []int `json:"a,string"`
   589  				B []int `json:"b,string"`
   590  			}{A: []int{-1}, B: nil},
   591  		},
   592  
   593  		// PtrHeadSlicePtrMultiFields
   594  		{
   595  			name: "PtrHeadSlicePtrMultiFields",
   596  			data: &struct {
   597  				A *[]int `json:"a"`
   598  				B *[]int `json:"b"`
   599  			}{A: sliceptr([]int{-1}), B: sliceptr([]int{-2})},
   600  		},
   601  		{
   602  			name: "PtrHeadSlicePtrMultiFieldsOmitEmpty",
   603  			data: &struct {
   604  				A *[]int `json:"a,omitempty"`
   605  				B *[]int `json:"b,omitempty"`
   606  			}{A: sliceptr([]int{-1}), B: sliceptr([]int{-2})},
   607  		},
   608  		{
   609  			name: "PtrHeadSlicePtrMultiFieldsString",
   610  			data: &struct {
   611  				A *[]int `json:"a,string"`
   612  				B *[]int `json:"b,string"`
   613  			}{A: sliceptr([]int{-1}), B: sliceptr([]int{-2})},
   614  		},
   615  
   616  		// PtrHeadSlicePtrNilMultiFields
   617  		{
   618  			name: "PtrHeadSlicePtrNilMultiFields",
   619  			data: &struct {
   620  				A *[]int `json:"a"`
   621  				B *[]int `json:"b"`
   622  			}{A: nil, B: nil},
   623  		},
   624  		{
   625  			name: "PtrHeadSlicePtrNilMultiFieldsOmitEmpty",
   626  			data: &struct {
   627  				A *[]int `json:"a,omitempty"`
   628  				B *[]int `json:"b,omitempty"`
   629  			}{A: nil, B: nil},
   630  		},
   631  		{
   632  			name: "PtrHeadSlicePtrNilMultiFieldsString",
   633  			data: &struct {
   634  				A *[]int `json:"a,string"`
   635  				B *[]int `json:"b,string"`
   636  			}{A: nil, B: nil},
   637  		},
   638  
   639  		// PtrHeadSliceNilMultiFields
   640  		{
   641  			name: "PtrHeadSliceNilMultiFields",
   642  			data: (*struct {
   643  				A []int `json:"a"`
   644  				B []int `json:"b"`
   645  			})(nil),
   646  		},
   647  		{
   648  			name: "PtrHeadSliceNilMultiFieldsOmitEmpty",
   649  			data: (*struct {
   650  				A []int `json:"a,omitempty"`
   651  				B []int `json:"b,omitempty"`
   652  			})(nil),
   653  		},
   654  		{
   655  			name: "PtrHeadSliceNilMultiFieldsString",
   656  			data: (*struct {
   657  				A []int `json:"a,string"`
   658  				B []int `json:"b,string"`
   659  			})(nil),
   660  		},
   661  
   662  		// PtrHeadSliceNilMultiFields
   663  		{
   664  			name: "PtrHeadSliceNilMultiFields",
   665  			data: (*struct {
   666  				A *[]int `json:"a"`
   667  				B *[]int `json:"b"`
   668  			})(nil),
   669  		},
   670  		{
   671  			name: "PtrHeadSliceNilMultiFieldsOmitEmpty",
   672  			data: (*struct {
   673  				A *[]int `json:"a,omitempty"`
   674  				B *[]int `json:"b,omitempty"`
   675  			})(nil),
   676  		},
   677  		{
   678  			name: "PtrHeadSliceNilMultiFieldsString",
   679  			data: (*struct {
   680  				A *[]int `json:"a,string"`
   681  				B *[]int `json:"b,string"`
   682  			})(nil),
   683  		},
   684  
   685  		// HeadSliceZeroNotRoot
   686  		{
   687  			name: "HeadSliceZeroNotRoot",
   688  			data: struct {
   689  				A struct {
   690  					A []int `json:"a"`
   691  				}
   692  			}{},
   693  		},
   694  		{
   695  			name: "HeadSliceZeroNotRootOmitEmpty",
   696  			data: struct {
   697  				A struct {
   698  					A []int `json:"a,omitempty"`
   699  				}
   700  			}{},
   701  		},
   702  		{
   703  			name: "HeadSliceZeroNotRootString",
   704  			data: struct {
   705  				A struct {
   706  					A []int `json:"a,string"`
   707  				}
   708  			}{},
   709  		},
   710  
   711  		// HeadSliceNotRoot
   712  		{
   713  			name: "HeadSliceNotRoot",
   714  			data: struct {
   715  				A struct {
   716  					A []int `json:"a"`
   717  				}
   718  			}{A: struct {
   719  				A []int `json:"a"`
   720  			}{A: []int{-1}}},
   721  		},
   722  		{
   723  			name: "HeadSliceNotRootOmitEmpty",
   724  			data: struct {
   725  				A struct {
   726  					A []int `json:"a,omitempty"`
   727  				}
   728  			}{A: struct {
   729  				A []int `json:"a,omitempty"`
   730  			}{A: []int{-1}}},
   731  		},
   732  		{
   733  			name: "HeadSliceNotRootString",
   734  			data: struct {
   735  				A struct {
   736  					A []int `json:"a,string"`
   737  				}
   738  			}{A: struct {
   739  				A []int `json:"a,string"`
   740  			}{A: []int{-1}}},
   741  		},
   742  
   743  		// HeadSlicePtrNotRoot
   744  		{
   745  			name: "HeadSlicePtrNotRoot",
   746  			data: struct {
   747  				A struct {
   748  					A *[]int `json:"a"`
   749  				}
   750  			}{A: struct {
   751  				A *[]int `json:"a"`
   752  			}{sliceptr([]int{-1})}},
   753  		},
   754  		{
   755  			name: "HeadSlicePtrNotRootOmitEmpty",
   756  			data: struct {
   757  				A struct {
   758  					A *[]int `json:"a,omitempty"`
   759  				}
   760  			}{A: struct {
   761  				A *[]int `json:"a,omitempty"`
   762  			}{sliceptr([]int{-1})}},
   763  		},
   764  		{
   765  			name: "HeadSlicePtrNotRootString",
   766  			data: struct {
   767  				A struct {
   768  					A *[]int `json:"a,string"`
   769  				}
   770  			}{A: struct {
   771  				A *[]int `json:"a,string"`
   772  			}{sliceptr([]int{-1})}},
   773  		},
   774  
   775  		// HeadSlicePtrNilNotRoot
   776  		{
   777  			name: "HeadSlicePtrNilNotRoot",
   778  			data: struct {
   779  				A struct {
   780  					A *[]int `json:"a"`
   781  				}
   782  			}{},
   783  		},
   784  		{
   785  			name: "HeadSlicePtrNilNotRootOmitEmpty",
   786  			data: struct {
   787  				A struct {
   788  					A *[]int `json:"a,omitempty"`
   789  				}
   790  			}{},
   791  		},
   792  		{
   793  			name: "HeadSlicePtrNilNotRootString",
   794  			data: struct {
   795  				A struct {
   796  					A *[]int `json:"a,string"`
   797  				}
   798  			}{},
   799  		},
   800  
   801  		// PtrHeadSliceZeroNotRoot
   802  		{
   803  			name: "PtrHeadSliceZeroNotRoot",
   804  			data: struct {
   805  				A *struct {
   806  					A []int `json:"a"`
   807  				}
   808  			}{A: new(struct {
   809  				A []int `json:"a"`
   810  			})},
   811  		},
   812  		{
   813  			name: "PtrHeadSliceZeroNotRootOmitEmpty",
   814  			data: struct {
   815  				A *struct {
   816  					A []int `json:"a,omitempty"`
   817  				}
   818  			}{A: new(struct {
   819  				A []int `json:"a,omitempty"`
   820  			})},
   821  		},
   822  		{
   823  			name: "PtrHeadSliceZeroNotRootString",
   824  			data: struct {
   825  				A *struct {
   826  					A []int `json:"a,string"`
   827  				}
   828  			}{A: new(struct {
   829  				A []int `json:"a,string"`
   830  			})},
   831  		},
   832  
   833  		// PtrHeadSliceNotRoot
   834  		{
   835  			name: "PtrHeadSliceNotRoot",
   836  			data: struct {
   837  				A *struct {
   838  					A []int `json:"a"`
   839  				}
   840  			}{A: &(struct {
   841  				A []int `json:"a"`
   842  			}{A: []int{-1}})},
   843  		},
   844  		{
   845  			name: "PtrHeadSliceNotRootOmitEmpty",
   846  			data: struct {
   847  				A *struct {
   848  					A []int `json:"a,omitempty"`
   849  				}
   850  			}{A: &(struct {
   851  				A []int `json:"a,omitempty"`
   852  			}{A: []int{-1}})},
   853  		},
   854  		{
   855  			name: "PtrHeadSliceNotRootString",
   856  			data: struct {
   857  				A *struct {
   858  					A []int `json:"a,string"`
   859  				}
   860  			}{A: &(struct {
   861  				A []int `json:"a,string"`
   862  			}{A: []int{-1}})},
   863  		},
   864  
   865  		// PtrHeadSlicePtrNotRoot
   866  		{
   867  			name: "PtrHeadSlicePtrNotRoot",
   868  			data: struct {
   869  				A *struct {
   870  					A *[]int `json:"a"`
   871  				}
   872  			}{A: &(struct {
   873  				A *[]int `json:"a"`
   874  			}{A: sliceptr([]int{-1})})},
   875  		},
   876  		{
   877  			name: "PtrHeadSlicePtrNotRootOmitEmpty",
   878  			data: struct {
   879  				A *struct {
   880  					A *[]int `json:"a,omitempty"`
   881  				}
   882  			}{A: &(struct {
   883  				A *[]int `json:"a,omitempty"`
   884  			}{A: sliceptr([]int{-1})})},
   885  		},
   886  		{
   887  			name: "PtrHeadSlicePtrNotRootString",
   888  			data: struct {
   889  				A *struct {
   890  					A *[]int `json:"a,string"`
   891  				}
   892  			}{A: &(struct {
   893  				A *[]int `json:"a,string"`
   894  			}{A: sliceptr([]int{-1})})},
   895  		},
   896  
   897  		// PtrHeadSlicePtrNilNotRoot
   898  		{
   899  			name: "PtrHeadSlicePtrNilNotRoot",
   900  			data: struct {
   901  				A *struct {
   902  					A *[]int `json:"a"`
   903  				}
   904  			}{A: &(struct {
   905  				A *[]int `json:"a"`
   906  			}{A: nil})},
   907  		},
   908  		{
   909  			name: "PtrHeadSlicePtrNilNotRootOmitEmpty",
   910  			data: struct {
   911  				A *struct {
   912  					A *[]int `json:"a,omitempty"`
   913  				}
   914  			}{A: &(struct {
   915  				A *[]int `json:"a,omitempty"`
   916  			}{A: nil})},
   917  		},
   918  		{
   919  			name: "PtrHeadSlicePtrNilNotRootString",
   920  			data: struct {
   921  				A *struct {
   922  					A *[]int `json:"a,string"`
   923  				}
   924  			}{A: &(struct {
   925  				A *[]int `json:"a,string"`
   926  			}{A: nil})},
   927  		},
   928  
   929  		// PtrHeadSliceNilNotRoot
   930  		{
   931  			name: "PtrHeadSliceNilNotRoot",
   932  			data: struct {
   933  				A *struct {
   934  					A *[]int `json:"a"`
   935  				}
   936  			}{A: nil},
   937  		},
   938  		{
   939  			name: "PtrHeadSliceNilNotRootOmitEmpty",
   940  			data: struct {
   941  				A *struct {
   942  					A *[]int `json:"a,omitempty"`
   943  				} `json:",omitempty"`
   944  			}{A: nil},
   945  		},
   946  		{
   947  			name: "PtrHeadSliceNilNotRootString",
   948  			data: struct {
   949  				A *struct {
   950  					A *[]int `json:"a,string"`
   951  				} `json:",string"`
   952  			}{A: nil},
   953  		},
   954  
   955  		// HeadSliceZeroMultiFieldsNotRoot
   956  		{
   957  			name: "HeadSliceZeroMultiFieldsNotRoot",
   958  			data: struct {
   959  				A struct {
   960  					A []int `json:"a"`
   961  				}
   962  				B struct {
   963  					B []int `json:"b"`
   964  				}
   965  			}{},
   966  		},
   967  		{
   968  			name: "HeadSliceZeroMultiFieldsNotRootOmitEmpty",
   969  			data: struct {
   970  				A struct {
   971  					A []int `json:"a,omitempty"`
   972  				}
   973  				B struct {
   974  					B []int `json:"b,omitempty"`
   975  				}
   976  			}{},
   977  		},
   978  		{
   979  			name: "HeadSliceZeroMultiFieldsNotRootString",
   980  			data: struct {
   981  				A struct {
   982  					A []int `json:"a,string"`
   983  				}
   984  				B struct {
   985  					B []int `json:"b,string"`
   986  				}
   987  			}{},
   988  		},
   989  
   990  		// HeadSliceMultiFieldsNotRoot
   991  		{
   992  			name: "HeadSliceMultiFieldsNotRoot",
   993  			data: struct {
   994  				A struct {
   995  					A []int `json:"a"`
   996  				}
   997  				B struct {
   998  					B []int `json:"b"`
   999  				}
  1000  			}{A: struct {
  1001  				A []int `json:"a"`
  1002  			}{A: []int{-1}}, B: struct {
  1003  				B []int `json:"b"`
  1004  			}{B: []int{0}}},
  1005  		},
  1006  		{
  1007  			name: "HeadSliceMultiFieldsNotRootOmitEmpty",
  1008  			data: struct {
  1009  				A struct {
  1010  					A []int `json:"a,omitempty"`
  1011  				}
  1012  				B struct {
  1013  					B []int `json:"b,omitempty"`
  1014  				}
  1015  			}{A: struct {
  1016  				A []int `json:"a,omitempty"`
  1017  			}{A: []int{-1}}, B: struct {
  1018  				B []int `json:"b,omitempty"`
  1019  			}{B: []int{1}}},
  1020  		},
  1021  		{
  1022  			name: "HeadSliceMultiFieldsNotRootString",
  1023  			data: struct {
  1024  				A struct {
  1025  					A []int `json:"a,string"`
  1026  				}
  1027  				B struct {
  1028  					B []int `json:"b,string"`
  1029  				}
  1030  			}{A: struct {
  1031  				A []int `json:"a,string"`
  1032  			}{A: []int{-1}}, B: struct {
  1033  				B []int `json:"b,string"`
  1034  			}{B: []int{1}}},
  1035  		},
  1036  
  1037  		// HeadSlicePtrMultiFieldsNotRoot
  1038  		{
  1039  			name: "HeadSlicePtrMultiFieldsNotRoot",
  1040  			data: struct {
  1041  				A struct {
  1042  					A *[]int `json:"a"`
  1043  				}
  1044  				B struct {
  1045  					B *[]int `json:"b"`
  1046  				}
  1047  			}{A: struct {
  1048  				A *[]int `json:"a"`
  1049  			}{A: sliceptr([]int{-1})}, B: struct {
  1050  				B *[]int `json:"b"`
  1051  			}{B: sliceptr([]int{1})}},
  1052  		},
  1053  		{
  1054  			name: "HeadSlicePtrMultiFieldsNotRootOmitEmpty",
  1055  			data: struct {
  1056  				A struct {
  1057  					A *[]int `json:"a,omitempty"`
  1058  				}
  1059  				B struct {
  1060  					B *[]int `json:"b,omitempty"`
  1061  				}
  1062  			}{A: struct {
  1063  				A *[]int `json:"a,omitempty"`
  1064  			}{A: sliceptr([]int{-1})}, B: struct {
  1065  				B *[]int `json:"b,omitempty"`
  1066  			}{B: sliceptr([]int{1})}},
  1067  		},
  1068  		{
  1069  			name: "HeadSlicePtrMultiFieldsNotRootString",
  1070  			data: struct {
  1071  				A struct {
  1072  					A *[]int `json:"a,string"`
  1073  				}
  1074  				B struct {
  1075  					B *[]int `json:"b,string"`
  1076  				}
  1077  			}{A: struct {
  1078  				A *[]int `json:"a,string"`
  1079  			}{A: sliceptr([]int{-1})}, B: struct {
  1080  				B *[]int `json:"b,string"`
  1081  			}{B: sliceptr([]int{1})}},
  1082  		},
  1083  
  1084  		// HeadSlicePtrNilMultiFieldsNotRoot
  1085  		{
  1086  			name: "HeadSlicePtrNilMultiFieldsNotRoot",
  1087  			data: struct {
  1088  				A struct {
  1089  					A *[]int `json:"a"`
  1090  				}
  1091  				B struct {
  1092  					B *[]int `json:"b"`
  1093  				}
  1094  			}{A: struct {
  1095  				A *[]int `json:"a"`
  1096  			}{A: nil}, B: struct {
  1097  				B *[]int `json:"b"`
  1098  			}{B: nil}},
  1099  		},
  1100  		{
  1101  			name: "HeadSlicePtrNilMultiFieldsNotRootOmitEmpty",
  1102  			data: struct {
  1103  				A struct {
  1104  					A *[]int `json:"a,omitempty"`
  1105  				}
  1106  				B struct {
  1107  					B *[]int `json:"b,omitempty"`
  1108  				}
  1109  			}{A: struct {
  1110  				A *[]int `json:"a,omitempty"`
  1111  			}{A: nil}, B: struct {
  1112  				B *[]int `json:"b,omitempty"`
  1113  			}{B: nil}},
  1114  		},
  1115  		{
  1116  			name: "HeadSlicePtrNilMultiFieldsNotRootString",
  1117  			data: struct {
  1118  				A struct {
  1119  					A *[]int `json:"a,string"`
  1120  				}
  1121  				B struct {
  1122  					B *[]int `json:"b,string"`
  1123  				}
  1124  			}{A: struct {
  1125  				A *[]int `json:"a,string"`
  1126  			}{A: nil}, B: struct {
  1127  				B *[]int `json:"b,string"`
  1128  			}{B: nil}},
  1129  		},
  1130  
  1131  		// PtrHeadSliceZeroMultiFieldsNotRoot
  1132  		{
  1133  			name: "PtrHeadSliceZeroMultiFieldsNotRoot",
  1134  			data: &struct {
  1135  				A struct {
  1136  					A []int `json:"a"`
  1137  				}
  1138  				B struct {
  1139  					B []int `json:"b"`
  1140  				}
  1141  			}{},
  1142  		},
  1143  		{
  1144  			name: "PtrHeadSliceZeroMultiFieldsNotRootOmitEmpty",
  1145  			data: &struct {
  1146  				A struct {
  1147  					A []int `json:"a,omitempty"`
  1148  				}
  1149  				B struct {
  1150  					B []int `json:"b,omitempty"`
  1151  				}
  1152  			}{},
  1153  		},
  1154  		{
  1155  			name: "PtrHeadSliceZeroMultiFieldsNotRootString",
  1156  			data: &struct {
  1157  				A struct {
  1158  					A []int `json:"a,string"`
  1159  				}
  1160  				B struct {
  1161  					B []int `json:"b,string"`
  1162  				}
  1163  			}{},
  1164  		},
  1165  
  1166  		// PtrHeadSliceMultiFieldsNotRoot
  1167  		{
  1168  			name: "PtrHeadSliceMultiFieldsNotRoot",
  1169  			data: &struct {
  1170  				A struct {
  1171  					A []int `json:"a"`
  1172  				}
  1173  				B struct {
  1174  					B []int `json:"b"`
  1175  				}
  1176  			}{A: struct {
  1177  				A []int `json:"a"`
  1178  			}{A: []int{-1}}, B: struct {
  1179  				B []int `json:"b"`
  1180  			}{B: []int{1}}},
  1181  		},
  1182  		{
  1183  			name: "PtrHeadSliceMultiFieldsNotRootOmitEmpty",
  1184  			data: &struct {
  1185  				A struct {
  1186  					A []int `json:"a,omitempty"`
  1187  				}
  1188  				B struct {
  1189  					B []int `json:"b,omitempty"`
  1190  				}
  1191  			}{A: struct {
  1192  				A []int `json:"a,omitempty"`
  1193  			}{A: []int{-1}}, B: struct {
  1194  				B []int `json:"b,omitempty"`
  1195  			}{B: []int{1}}},
  1196  		},
  1197  		{
  1198  			name: "PtrHeadSliceMultiFieldsNotRootString",
  1199  			data: &struct {
  1200  				A struct {
  1201  					A []int `json:"a,string"`
  1202  				}
  1203  				B struct {
  1204  					B []int `json:"b,string"`
  1205  				}
  1206  			}{A: struct {
  1207  				A []int `json:"a,string"`
  1208  			}{A: []int{-1}}, B: struct {
  1209  				B []int `json:"b,string"`
  1210  			}{B: []int{1}}},
  1211  		},
  1212  
  1213  		// PtrHeadSlicePtrMultiFieldsNotRoot
  1214  		{
  1215  			name: "PtrHeadSlicePtrMultiFieldsNotRoot",
  1216  			data: &struct {
  1217  				A *struct {
  1218  					A *[]int `json:"a"`
  1219  				}
  1220  				B *struct {
  1221  					B *[]int `json:"b"`
  1222  				}
  1223  			}{A: &(struct {
  1224  				A *[]int `json:"a"`
  1225  			}{A: sliceptr([]int{-1})}), B: &(struct {
  1226  				B *[]int `json:"b"`
  1227  			}{B: sliceptr([]int{1})})},
  1228  		},
  1229  		{
  1230  			name: "PtrHeadSlicePtrMultiFieldsNotRootOmitEmpty",
  1231  			data: &struct {
  1232  				A *struct {
  1233  					A *[]int `json:"a,omitempty"`
  1234  				}
  1235  				B *struct {
  1236  					B *[]int `json:"b,omitempty"`
  1237  				}
  1238  			}{A: &(struct {
  1239  				A *[]int `json:"a,omitempty"`
  1240  			}{A: sliceptr([]int{-1})}), B: &(struct {
  1241  				B *[]int `json:"b,omitempty"`
  1242  			}{B: sliceptr([]int{1})})},
  1243  		},
  1244  		{
  1245  			name: "PtrHeadSlicePtrMultiFieldsNotRootString",
  1246  			data: &struct {
  1247  				A *struct {
  1248  					A *[]int `json:"a,string"`
  1249  				}
  1250  				B *struct {
  1251  					B *[]int `json:"b,string"`
  1252  				}
  1253  			}{A: &(struct {
  1254  				A *[]int `json:"a,string"`
  1255  			}{A: sliceptr([]int{-1})}), B: &(struct {
  1256  				B *[]int `json:"b,string"`
  1257  			}{B: sliceptr([]int{1})})},
  1258  		},
  1259  
  1260  		// PtrHeadSlicePtrNilMultiFieldsNotRoot
  1261  		{
  1262  			name: "PtrHeadSlicePtrNilMultiFieldsNotRoot",
  1263  			data: &struct {
  1264  				A *struct {
  1265  					A *[]int `json:"a"`
  1266  				}
  1267  				B *struct {
  1268  					B *[]int `json:"b"`
  1269  				}
  1270  			}{A: nil, B: nil},
  1271  		},
  1272  		{
  1273  			name: "PtrHeadSlicePtrNilMultiFieldsNotRootOmitEmpty",
  1274  			data: &struct {
  1275  				A *struct {
  1276  					A *[]int `json:"a,omitempty"`
  1277  				} `json:",omitempty"`
  1278  				B *struct {
  1279  					B *[]int `json:"b,omitempty"`
  1280  				} `json:",omitempty"`
  1281  			}{A: nil, B: nil},
  1282  		},
  1283  		{
  1284  			name: "PtrHeadSlicePtrNilMultiFieldsNotRootString",
  1285  			data: &struct {
  1286  				A *struct {
  1287  					A *[]int `json:"a,string"`
  1288  				} `json:",string"`
  1289  				B *struct {
  1290  					B *[]int `json:"b,string"`
  1291  				} `json:",string"`
  1292  			}{A: nil, B: nil},
  1293  		},
  1294  
  1295  		// PtrHeadSliceNilMultiFieldsNotRoot
  1296  		{
  1297  			name: "PtrHeadSliceNilMultiFieldsNotRoot",
  1298  			data: (*struct {
  1299  				A *struct {
  1300  					A *[]int `json:"a"`
  1301  				}
  1302  				B *struct {
  1303  					B *[]int `json:"b"`
  1304  				}
  1305  			})(nil),
  1306  		},
  1307  		{
  1308  			name: "PtrHeadSliceNilMultiFieldsNotRootOmitEmpty",
  1309  			data: (*struct {
  1310  				A *struct {
  1311  					A *[]int `json:"a,omitempty"`
  1312  				}
  1313  				B *struct {
  1314  					B *[]int `json:"b,omitempty"`
  1315  				}
  1316  			})(nil),
  1317  		},
  1318  		{
  1319  			name: "PtrHeadSliceNilMultiFieldsNotRootString",
  1320  			data: (*struct {
  1321  				A *struct {
  1322  					A *[]int `json:"a,string"`
  1323  				}
  1324  				B *struct {
  1325  					B *[]int `json:"b,string"`
  1326  				}
  1327  			})(nil),
  1328  		},
  1329  
  1330  		// PtrHeadSliceDoubleMultiFieldsNotRoot
  1331  		{
  1332  			name: "PtrHeadSliceDoubleMultiFieldsNotRoot",
  1333  			data: &struct {
  1334  				A *struct {
  1335  					A []int `json:"a"`
  1336  					B []int `json:"b"`
  1337  				}
  1338  				B *struct {
  1339  					A []int `json:"a"`
  1340  					B []int `json:"b"`
  1341  				}
  1342  			}{A: &(struct {
  1343  				A []int `json:"a"`
  1344  				B []int `json:"b"`
  1345  			}{A: []int{-1}, B: []int{1}}), B: &(struct {
  1346  				A []int `json:"a"`
  1347  				B []int `json:"b"`
  1348  			}{A: []int{-1}, B: nil})},
  1349  		},
  1350  		{
  1351  			name: "PtrHeadSliceDoubleMultiFieldsNotRootOmitEmpty",
  1352  			data: &struct {
  1353  				A *struct {
  1354  					A []int `json:"a,omitempty"`
  1355  					B []int `json:"b,omitempty"`
  1356  				}
  1357  				B *struct {
  1358  					A []int `json:"a,omitempty"`
  1359  					B []int `json:"b,omitempty"`
  1360  				}
  1361  			}{A: &(struct {
  1362  				A []int `json:"a,omitempty"`
  1363  				B []int `json:"b,omitempty"`
  1364  			}{A: []int{-1}, B: []int{1}}), B: &(struct {
  1365  				A []int `json:"a,omitempty"`
  1366  				B []int `json:"b,omitempty"`
  1367  			}{A: []int{-1}, B: nil})},
  1368  		},
  1369  		{
  1370  			name: "PtrHeadSliceDoubleMultiFieldsNotRootString",
  1371  			data: &struct {
  1372  				A *struct {
  1373  					A []int `json:"a,string"`
  1374  					B []int `json:"b,string"`
  1375  				}
  1376  				B *struct {
  1377  					A []int `json:"a,string"`
  1378  					B []int `json:"b,string"`
  1379  				}
  1380  			}{A: &(struct {
  1381  				A []int `json:"a,string"`
  1382  				B []int `json:"b,string"`
  1383  			}{A: []int{-1}, B: []int{1}}), B: &(struct {
  1384  				A []int `json:"a,string"`
  1385  				B []int `json:"b,string"`
  1386  			}{A: []int{-1}, B: nil})},
  1387  		},
  1388  
  1389  		// PtrHeadSliceNilDoubleMultiFieldsNotRoot
  1390  		{
  1391  			name: "PtrHeadSliceNilDoubleMultiFieldsNotRoot",
  1392  			data: &struct {
  1393  				A *struct {
  1394  					A []int `json:"a"`
  1395  					B []int `json:"b"`
  1396  				}
  1397  				B *struct {
  1398  					A []int `json:"a"`
  1399  					B []int `json:"b"`
  1400  				}
  1401  			}{A: nil, B: nil},
  1402  		},
  1403  		{
  1404  			name: "PtrHeadSliceNilDoubleMultiFieldsNotRootOmitEmpty",
  1405  			data: &struct {
  1406  				A *struct {
  1407  					A []int `json:"a,omitempty"`
  1408  					B []int `json:"b,omitempty"`
  1409  				} `json:",omitempty"`
  1410  				B *struct {
  1411  					A []int `json:"a,omitempty"`
  1412  					B []int `json:"b,omitempty"`
  1413  				} `json:",omitempty"`
  1414  			}{A: nil, B: nil},
  1415  		},
  1416  		{
  1417  			name: "PtrHeadSliceNilDoubleMultiFieldsNotRootString",
  1418  			data: &struct {
  1419  				A *struct {
  1420  					A []int `json:"a,string"`
  1421  					B []int `json:"b,string"`
  1422  				}
  1423  				B *struct {
  1424  					A []int `json:"a,string"`
  1425  					B []int `json:"b,string"`
  1426  				}
  1427  			}{A: nil, B: nil},
  1428  		},
  1429  
  1430  		// PtrHeadSliceNilDoubleMultiFieldsNotRoot
  1431  		{
  1432  			name: "PtrHeadSliceNilDoubleMultiFieldsNotRoot",
  1433  			data: (*struct {
  1434  				A *struct {
  1435  					A []int `json:"a"`
  1436  					B []int `json:"b"`
  1437  				}
  1438  				B *struct {
  1439  					A []int `json:"a"`
  1440  					B []int `json:"b"`
  1441  				}
  1442  			})(nil),
  1443  		},
  1444  		{
  1445  			name: "PtrHeadSliceNilDoubleMultiFieldsNotRootOmitEmpty",
  1446  			data: (*struct {
  1447  				A *struct {
  1448  					A []int `json:"a,omitempty"`
  1449  					B []int `json:"b,omitempty"`
  1450  				}
  1451  				B *struct {
  1452  					A []int `json:"a,omitempty"`
  1453  					B []int `json:"b,omitempty"`
  1454  				}
  1455  			})(nil),
  1456  		},
  1457  		{
  1458  			name: "PtrHeadSliceNilDoubleMultiFieldsNotRootString",
  1459  			data: (*struct {
  1460  				A *struct {
  1461  					A []int `json:"a,string"`
  1462  					B []int `json:"b,string"`
  1463  				}
  1464  				B *struct {
  1465  					A []int `json:"a,string"`
  1466  					B []int `json:"b,string"`
  1467  				}
  1468  			})(nil),
  1469  		},
  1470  
  1471  		// PtrHeadSlicePtrDoubleMultiFieldsNotRoot
  1472  		{
  1473  			name: "PtrHeadSlicePtrDoubleMultiFieldsNotRoot",
  1474  			data: &struct {
  1475  				A *struct {
  1476  					A *[]int `json:"a"`
  1477  					B *[]int `json:"b"`
  1478  				}
  1479  				B *struct {
  1480  					A *[]int `json:"a"`
  1481  					B *[]int `json:"b"`
  1482  				}
  1483  			}{A: &(struct {
  1484  				A *[]int `json:"a"`
  1485  				B *[]int `json:"b"`
  1486  			}{A: sliceptr([]int{-1}), B: sliceptr([]int{1})}), B: &(struct {
  1487  				A *[]int `json:"a"`
  1488  				B *[]int `json:"b"`
  1489  			}{A: nil, B: nil})},
  1490  		},
  1491  		{
  1492  			name: "PtrHeadSlicePtrDoubleMultiFieldsNotRootOmitEmpty",
  1493  			data: &struct {
  1494  				A *struct {
  1495  					A *[]int `json:"a,omitempty"`
  1496  					B *[]int `json:"b,omitempty"`
  1497  				}
  1498  				B *struct {
  1499  					A *[]int `json:"a,omitempty"`
  1500  					B *[]int `json:"b,omitempty"`
  1501  				}
  1502  			}{A: &(struct {
  1503  				A *[]int `json:"a,omitempty"`
  1504  				B *[]int `json:"b,omitempty"`
  1505  			}{A: sliceptr([]int{-1}), B: sliceptr([]int{1})}), B: &(struct {
  1506  				A *[]int `json:"a,omitempty"`
  1507  				B *[]int `json:"b,omitempty"`
  1508  			}{A: nil, B: nil})},
  1509  		},
  1510  		{
  1511  			name: "PtrHeadSlicePtrDoubleMultiFieldsNotRootString",
  1512  			data: &struct {
  1513  				A *struct {
  1514  					A *[]int `json:"a,string"`
  1515  					B *[]int `json:"b,string"`
  1516  				}
  1517  				B *struct {
  1518  					A *[]int `json:"a,string"`
  1519  					B *[]int `json:"b,string"`
  1520  				}
  1521  			}{A: &(struct {
  1522  				A *[]int `json:"a,string"`
  1523  				B *[]int `json:"b,string"`
  1524  			}{A: sliceptr([]int{-1}), B: sliceptr([]int{1})}), B: &(struct {
  1525  				A *[]int `json:"a,string"`
  1526  				B *[]int `json:"b,string"`
  1527  			}{A: nil, B: nil})},
  1528  		},
  1529  
  1530  		// PtrHeadSlicePtrNilDoubleMultiFieldsNotRoot
  1531  		{
  1532  			name: "PtrHeadSlicePtrNilDoubleMultiFieldsNotRoot",
  1533  			data: &struct {
  1534  				A *struct {
  1535  					A *[]int `json:"a"`
  1536  					B *[]int `json:"b"`
  1537  				}
  1538  				B *struct {
  1539  					A *[]int `json:"a"`
  1540  					B *[]int `json:"b"`
  1541  				}
  1542  			}{A: nil, B: nil},
  1543  		},
  1544  		{
  1545  			name: "PtrHeadSlicePtrNilDoubleMultiFieldsNotRootOmitEmpty",
  1546  			data: &struct {
  1547  				A *struct {
  1548  					A *[]int `json:"a,omitempty"`
  1549  					B *[]int `json:"b,omitempty"`
  1550  				} `json:",omitempty"`
  1551  				B *struct {
  1552  					A *[]int `json:"a,omitempty"`
  1553  					B *[]int `json:"b,omitempty"`
  1554  				} `json:",omitempty"`
  1555  			}{A: nil, B: nil},
  1556  		},
  1557  		{
  1558  			name: "PtrHeadSlicePtrNilDoubleMultiFieldsNotRootString",
  1559  			data: &struct {
  1560  				A *struct {
  1561  					A *[]int `json:"a,string"`
  1562  					B *[]int `json:"b,string"`
  1563  				}
  1564  				B *struct {
  1565  					A *[]int `json:"a,string"`
  1566  					B *[]int `json:"b,string"`
  1567  				}
  1568  			}{A: nil, B: nil},
  1569  		},
  1570  
  1571  		// PtrHeadSlicePtrNilDoubleMultiFieldsNotRoot
  1572  		{
  1573  			name: "PtrHeadSlicePtrNilDoubleMultiFieldsNotRoot",
  1574  			data: (*struct {
  1575  				A *struct {
  1576  					A *[]int `json:"a"`
  1577  					B *[]int `json:"b"`
  1578  				}
  1579  				B *struct {
  1580  					A *[]int `json:"a"`
  1581  					B *[]int `json:"b"`
  1582  				}
  1583  			})(nil),
  1584  		},
  1585  		{
  1586  			name: "PtrHeadSlicePtrNilDoubleMultiFieldsNotRootOmitEmpty",
  1587  			data: (*struct {
  1588  				A *struct {
  1589  					A *[]int `json:"a,omitempty"`
  1590  					B *[]int `json:"b,omitempty"`
  1591  				}
  1592  				B *struct {
  1593  					A *[]int `json:"a,omitempty"`
  1594  					B *[]int `json:"b,omitempty"`
  1595  				}
  1596  			})(nil),
  1597  		},
  1598  		{
  1599  			name: "PtrHeadSlicePtrNilDoubleMultiFieldsNotRootString",
  1600  			data: (*struct {
  1601  				A *struct {
  1602  					A *[]int `json:"a,string"`
  1603  					B *[]int `json:"b,string"`
  1604  				}
  1605  				B *struct {
  1606  					A *[]int `json:"a,string"`
  1607  					B *[]int `json:"b,string"`
  1608  				}
  1609  			})(nil),
  1610  		},
  1611  
  1612  		// AnonymousHeadSlice
  1613  		{
  1614  			name: "AnonymousHeadSlice",
  1615  			data: struct {
  1616  				structSlice
  1617  				B []int `json:"b"`
  1618  			}{
  1619  				structSlice: structSlice{A: []int{-1}},
  1620  				B:           nil,
  1621  			},
  1622  		},
  1623  		{
  1624  			name: "AnonymousHeadSliceOmitEmpty",
  1625  			data: struct {
  1626  				structSliceOmitEmpty
  1627  				B []int `json:"b,omitempty"`
  1628  			}{
  1629  				structSliceOmitEmpty: structSliceOmitEmpty{A: []int{-1}},
  1630  				B:                    nil,
  1631  			},
  1632  		},
  1633  		{
  1634  			name: "AnonymousHeadSliceString",
  1635  			data: struct {
  1636  				structSliceString
  1637  				B []int `json:"b,string"`
  1638  			}{
  1639  				structSliceString: structSliceString{A: []int{-1}},
  1640  				B:                 nil,
  1641  			},
  1642  		},
  1643  
  1644  		// PtrAnonymousHeadSlice
  1645  		{
  1646  			name: "PtrAnonymousHeadSlice",
  1647  			data: struct {
  1648  				*structSlice
  1649  				B []int `json:"b"`
  1650  			}{
  1651  				structSlice: &structSlice{A: []int{-1}},
  1652  				B:           nil,
  1653  			},
  1654  		},
  1655  		{
  1656  			name: "PtrAnonymousHeadSliceOmitEmpty",
  1657  			data: struct {
  1658  				*structSliceOmitEmpty
  1659  				B []int `json:"b,omitempty"`
  1660  			}{
  1661  				structSliceOmitEmpty: &structSliceOmitEmpty{A: []int{-1}},
  1662  				B:                    nil,
  1663  			},
  1664  		},
  1665  		{
  1666  			name: "PtrAnonymousHeadSliceString",
  1667  			data: struct {
  1668  				*structSliceString
  1669  				B []int `json:"b,string"`
  1670  			}{
  1671  				structSliceString: &structSliceString{A: []int{-1}},
  1672  				B:                 nil,
  1673  			},
  1674  		},
  1675  
  1676  		// PtrAnonymousHeadSliceNil
  1677  		{
  1678  			name: "PtrAnonymousHeadSliceNil",
  1679  			data: struct {
  1680  				*structSlice
  1681  				B []int `json:"b"`
  1682  			}{
  1683  				structSlice: &structSlice{A: nil},
  1684  				B:           nil,
  1685  			},
  1686  		},
  1687  		{
  1688  			name: "PtrAnonymousHeadSliceNilOmitEmpty",
  1689  			data: struct {
  1690  				*structSliceOmitEmpty
  1691  				B []int `json:"b,omitempty"`
  1692  			}{
  1693  				structSliceOmitEmpty: &structSliceOmitEmpty{A: nil},
  1694  				B:                    nil,
  1695  			},
  1696  		},
  1697  		{
  1698  			name: "PtrAnonymousHeadSliceNilString",
  1699  			data: struct {
  1700  				*structSliceString
  1701  				B []int `json:"b,string"`
  1702  			}{
  1703  				structSliceString: &structSliceString{A: nil},
  1704  				B:                 nil,
  1705  			},
  1706  		},
  1707  
  1708  		// NilPtrAnonymousHeadSlice
  1709  		{
  1710  			name: "NilPtrAnonymousHeadSlice",
  1711  			data: struct {
  1712  				*structSlice
  1713  				B []int `json:"b"`
  1714  			}{
  1715  				structSlice: nil,
  1716  				B:           []int{-1},
  1717  			},
  1718  		},
  1719  		{
  1720  			name: "NilPtrAnonymousHeadSliceOmitEmpty",
  1721  			data: struct {
  1722  				*structSliceOmitEmpty
  1723  				B []int `json:"b,omitempty"`
  1724  			}{
  1725  				structSliceOmitEmpty: nil,
  1726  				B:                    []int{-1},
  1727  			},
  1728  		},
  1729  		{
  1730  			name: "NilPtrAnonymousHeadSliceString",
  1731  			data: struct {
  1732  				*structSliceString
  1733  				B []int `json:"b,string"`
  1734  			}{
  1735  				structSliceString: nil,
  1736  				B:                 []int{-1},
  1737  			},
  1738  		},
  1739  
  1740  		// AnonymousHeadSlicePtr
  1741  		{
  1742  			name: "AnonymousHeadSlicePtr",
  1743  			data: struct {
  1744  				structSlicePtr
  1745  				B *[]int `json:"b"`
  1746  			}{
  1747  				structSlicePtr: structSlicePtr{A: sliceptr([]int{-1})},
  1748  				B:              nil,
  1749  			},
  1750  		},
  1751  		{
  1752  			name: "AnonymousHeadSlicePtrOmitEmpty",
  1753  			data: struct {
  1754  				structSlicePtrOmitEmpty
  1755  				B *[]int `json:"b,omitempty"`
  1756  			}{
  1757  				structSlicePtrOmitEmpty: structSlicePtrOmitEmpty{A: sliceptr([]int{-1})},
  1758  				B:                       nil,
  1759  			},
  1760  		},
  1761  		{
  1762  			name: "AnonymousHeadSlicePtrString",
  1763  			data: struct {
  1764  				structSlicePtrString
  1765  				B *[]int `json:"b,string"`
  1766  			}{
  1767  				structSlicePtrString: structSlicePtrString{A: sliceptr([]int{-1})},
  1768  				B:                    nil,
  1769  			},
  1770  		},
  1771  
  1772  		// AnonymousHeadSlicePtrNil
  1773  		{
  1774  			name: "AnonymousHeadSlicePtrNil",
  1775  			data: struct {
  1776  				structSlicePtr
  1777  				B *[]int `json:"b"`
  1778  			}{
  1779  				structSlicePtr: structSlicePtr{A: nil},
  1780  				B:              sliceptr([]int{-1}),
  1781  			},
  1782  		},
  1783  		{
  1784  			name: "AnonymousHeadSlicePtrNilOmitEmpty",
  1785  			data: struct {
  1786  				structSlicePtrOmitEmpty
  1787  				B *[]int `json:"b,omitempty"`
  1788  			}{
  1789  				structSlicePtrOmitEmpty: structSlicePtrOmitEmpty{A: nil},
  1790  				B:                       sliceptr([]int{-1}),
  1791  			},
  1792  		},
  1793  		{
  1794  			name: "AnonymousHeadSlicePtrNilString",
  1795  			data: struct {
  1796  				structSlicePtrString
  1797  				B *[]int `json:"b,string"`
  1798  			}{
  1799  				structSlicePtrString: structSlicePtrString{A: nil},
  1800  				B:                    sliceptr([]int{-1}),
  1801  			},
  1802  		},
  1803  
  1804  		// PtrAnonymousHeadSlicePtr
  1805  		{
  1806  			name: "PtrAnonymousHeadSlicePtr",
  1807  			data: struct {
  1808  				*structSlicePtr
  1809  				B *[]int `json:"b"`
  1810  			}{
  1811  				structSlicePtr: &structSlicePtr{A: sliceptr([]int{-1})},
  1812  				B:              nil,
  1813  			},
  1814  		},
  1815  		{
  1816  			name: "PtrAnonymousHeadSlicePtrOmitEmpty",
  1817  			data: struct {
  1818  				*structSlicePtrOmitEmpty
  1819  				B *[]int `json:"b,omitempty"`
  1820  			}{
  1821  				structSlicePtrOmitEmpty: &structSlicePtrOmitEmpty{A: sliceptr([]int{-1})},
  1822  				B:                       nil,
  1823  			},
  1824  		},
  1825  		{
  1826  			name: "PtrAnonymousHeadSlicePtrString",
  1827  			data: struct {
  1828  				*structSlicePtrString
  1829  				B *[]int `json:"b,string"`
  1830  			}{
  1831  				structSlicePtrString: &structSlicePtrString{A: sliceptr([]int{-1})},
  1832  				B:                    nil,
  1833  			},
  1834  		},
  1835  
  1836  		// NilPtrAnonymousHeadSlicePtr
  1837  		{
  1838  			name: "NilPtrAnonymousHeadSlicePtr",
  1839  			data: struct {
  1840  				*structSlicePtr
  1841  				B *[]int `json:"b"`
  1842  			}{
  1843  				structSlicePtr: nil,
  1844  				B:              sliceptr([]int{-1}),
  1845  			},
  1846  		},
  1847  		{
  1848  			name: "NilPtrAnonymousHeadSlicePtrOmitEmpty",
  1849  			data: struct {
  1850  				*structSlicePtrOmitEmpty
  1851  				B *[]int `json:"b,omitempty"`
  1852  			}{
  1853  				structSlicePtrOmitEmpty: nil,
  1854  				B:                       sliceptr([]int{-1}),
  1855  			},
  1856  		},
  1857  		{
  1858  			name: "NilPtrAnonymousHeadSlicePtrString",
  1859  			data: struct {
  1860  				*structSlicePtrString
  1861  				B *[]int `json:"b,string"`
  1862  			}{
  1863  				structSlicePtrString: nil,
  1864  				B:                    sliceptr([]int{-1}),
  1865  			},
  1866  		},
  1867  
  1868  		// AnonymousHeadSliceOnly
  1869  		{
  1870  			name: "AnonymousHeadSliceOnly",
  1871  			data: struct {
  1872  				structSlice
  1873  			}{
  1874  				structSlice: structSlice{A: []int{-1}},
  1875  			},
  1876  		},
  1877  		{
  1878  			name: "AnonymousHeadSliceOnlyOmitEmpty",
  1879  			data: struct {
  1880  				structSliceOmitEmpty
  1881  			}{
  1882  				structSliceOmitEmpty: structSliceOmitEmpty{A: []int{-1}},
  1883  			},
  1884  		},
  1885  		{
  1886  			name: "AnonymousHeadSliceOnlyString",
  1887  			data: struct {
  1888  				structSliceString
  1889  			}{
  1890  				structSliceString: structSliceString{A: []int{-1}},
  1891  			},
  1892  		},
  1893  
  1894  		// PtrAnonymousHeadSliceOnly
  1895  		{
  1896  			name: "PtrAnonymousHeadSliceOnly",
  1897  			data: struct {
  1898  				*structSlice
  1899  			}{
  1900  				structSlice: &structSlice{A: []int{-1}},
  1901  			},
  1902  		},
  1903  		{
  1904  			name: "PtrAnonymousHeadSliceOnlyOmitEmpty",
  1905  			data: struct {
  1906  				*structSliceOmitEmpty
  1907  			}{
  1908  				structSliceOmitEmpty: &structSliceOmitEmpty{A: []int{-1}},
  1909  			},
  1910  		},
  1911  		{
  1912  			name: "PtrAnonymousHeadSliceOnlyString",
  1913  			data: struct {
  1914  				*structSliceString
  1915  			}{
  1916  				structSliceString: &structSliceString{A: []int{-1}},
  1917  			},
  1918  		},
  1919  
  1920  		// NilPtrAnonymousHeadSliceOnly
  1921  		{
  1922  			name: "NilPtrAnonymousHeadSliceOnly",
  1923  			data: struct {
  1924  				*structSlice
  1925  			}{
  1926  				structSlice: nil,
  1927  			},
  1928  		},
  1929  		{
  1930  			name: "NilPtrAnonymousHeadSliceOnlyOmitEmpty",
  1931  			data: struct {
  1932  				*structSliceOmitEmpty
  1933  			}{
  1934  				structSliceOmitEmpty: nil,
  1935  			},
  1936  		},
  1937  		{
  1938  			name: "NilPtrAnonymousHeadSliceOnlyString",
  1939  			data: struct {
  1940  				*structSliceString
  1941  			}{
  1942  				structSliceString: nil,
  1943  			},
  1944  		},
  1945  
  1946  		// AnonymousHeadSlicePtrOnly
  1947  		{
  1948  			name: "AnonymousHeadSlicePtrOnly",
  1949  			data: struct {
  1950  				structSlicePtr
  1951  			}{
  1952  				structSlicePtr: structSlicePtr{A: sliceptr([]int{-1})},
  1953  			},
  1954  		},
  1955  		{
  1956  			name: "AnonymousHeadSlicePtrOnlyOmitEmpty",
  1957  			data: struct {
  1958  				structSlicePtrOmitEmpty
  1959  			}{
  1960  				structSlicePtrOmitEmpty: structSlicePtrOmitEmpty{A: sliceptr([]int{-1})},
  1961  			},
  1962  		},
  1963  		{
  1964  			name: "AnonymousHeadSlicePtrOnlyString",
  1965  			data: struct {
  1966  				structSlicePtrString
  1967  			}{
  1968  				structSlicePtrString: structSlicePtrString{A: sliceptr([]int{-1})},
  1969  			},
  1970  		},
  1971  
  1972  		// AnonymousHeadSlicePtrNilOnly
  1973  		{
  1974  			name: "AnonymousHeadSlicePtrNilOnly",
  1975  			data: struct {
  1976  				structSlicePtr
  1977  			}{
  1978  				structSlicePtr: structSlicePtr{A: nil},
  1979  			},
  1980  		},
  1981  		{
  1982  			name: "AnonymousHeadSlicePtrNilOnlyOmitEmpty",
  1983  			data: struct {
  1984  				structSlicePtrOmitEmpty
  1985  			}{
  1986  				structSlicePtrOmitEmpty: structSlicePtrOmitEmpty{A: nil},
  1987  			},
  1988  		},
  1989  		{
  1990  			name: "AnonymousHeadSlicePtrNilOnlyString",
  1991  			data: struct {
  1992  				structSlicePtrString
  1993  			}{
  1994  				structSlicePtrString: structSlicePtrString{A: nil},
  1995  			},
  1996  		},
  1997  
  1998  		// PtrAnonymousHeadSlicePtrOnly
  1999  		{
  2000  			name: "PtrAnonymousHeadSlicePtrOnly",
  2001  			data: struct {
  2002  				*structSlicePtr
  2003  			}{
  2004  				structSlicePtr: &structSlicePtr{A: sliceptr([]int{-1})},
  2005  			},
  2006  		},
  2007  		{
  2008  			name: "PtrAnonymousHeadSlicePtrOnlyOmitEmpty",
  2009  			data: struct {
  2010  				*structSlicePtrOmitEmpty
  2011  			}{
  2012  				structSlicePtrOmitEmpty: &structSlicePtrOmitEmpty{A: sliceptr([]int{-1})},
  2013  			},
  2014  		},
  2015  		{
  2016  			name: "PtrAnonymousHeadSlicePtrOnlyString",
  2017  			data: struct {
  2018  				*structSlicePtrString
  2019  			}{
  2020  				structSlicePtrString: &structSlicePtrString{A: sliceptr([]int{-1})},
  2021  			},
  2022  		},
  2023  
  2024  		// NilPtrAnonymousHeadSlicePtrOnly
  2025  		{
  2026  			name: "NilPtrAnonymousHeadSlicePtrOnly",
  2027  			data: struct {
  2028  				*structSlicePtr
  2029  			}{
  2030  				structSlicePtr: nil,
  2031  			},
  2032  		},
  2033  		{
  2034  			name: "NilPtrAnonymousHeadSlicePtrOnlyOmitEmpty",
  2035  			data: struct {
  2036  				*structSlicePtrOmitEmpty
  2037  			}{
  2038  				structSlicePtrOmitEmpty: nil,
  2039  			},
  2040  		},
  2041  		{
  2042  			name: "NilPtrAnonymousHeadSlicePtrOnlyString",
  2043  			data: struct {
  2044  				*structSlicePtrString
  2045  			}{
  2046  				structSlicePtrString: nil,
  2047  			},
  2048  		},
  2049  	}
  2050  	for _, test := range tests {
  2051  		for _, indent := range []bool{true, false} {
  2052  			for _, htmlEscape := range []bool{true, false} {
  2053  				t.Run(fmt.Sprintf("%s_indent_%t_escape_%t", test.name, indent, htmlEscape), func(t *testing.T) {
  2054  					var buf bytes.Buffer
  2055  					enc := json.NewEncoder(&buf)
  2056  					enc.SetEscapeHTML(htmlEscape)
  2057  					if indent {
  2058  						enc.SetIndent("", "  ")
  2059  					}
  2060  					if err := enc.Encode(test.data); err != nil {
  2061  						t.Fatalf("%s(htmlEscape:%v,indent:%v): %+v: %s", test.name, htmlEscape, indent, test.data, err)
  2062  					}
  2063  					stdresult := encodeByEncodingJSON(test.data, indent, htmlEscape)
  2064  					if buf.String() != stdresult {
  2065  						t.Errorf("%s(htmlEscape:%v,indent:%v): doesn't compatible with encoding/json. expected %q but got %q", test.name, htmlEscape, indent, stdresult, buf.String())
  2066  					}
  2067  				})
  2068  			}
  2069  		}
  2070  	}
  2071  }